dxs-stas-sdk 1.0.0 → 1.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./src"
|
package/package.json
CHANGED
|
@@ -1,12 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dxs-stas-sdk",
|
|
3
|
-
"version": "1.0.
|
|
4
|
-
"description": "",
|
|
3
|
+
"version": "1.0.2",
|
|
4
|
+
"description": "BSV Stas",
|
|
5
5
|
"main": "dxs.stas.sdk.ts",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "https://github.com/dxsapp/dxs-stas-sdk"
|
|
9
|
+
},
|
|
6
10
|
"scripts": {
|
|
7
11
|
"test": "jest",
|
|
8
12
|
"start": "tsnd ./src/index.ts",
|
|
9
|
-
"
|
|
13
|
+
"rollup": "rollup -c rollup.config.ts -w --configPlugin typescript"
|
|
10
14
|
},
|
|
11
15
|
"directories": {
|
|
12
16
|
"test": "tests"
|
|
@@ -26,6 +26,7 @@ export type TStasPayoutBundle = {
|
|
|
26
26
|
transactions?: string[];
|
|
27
27
|
feeSatoshis: number;
|
|
28
28
|
message?: string;
|
|
29
|
+
devMessage?: string;
|
|
29
30
|
};
|
|
30
31
|
|
|
31
32
|
export class StasBundleFactory {
|
|
@@ -86,6 +87,7 @@ export class StasBundleFactory {
|
|
|
86
87
|
if (estimatedFee > feeSatoshis) {
|
|
87
88
|
return {
|
|
88
89
|
message: "Insufficient balance to pay fee",
|
|
90
|
+
devMessage: `Insufficient balance to pay fee. Estimated: ${estimatedFee}; balance: ${feeSatoshis}`,
|
|
89
91
|
feeSatoshis: 0,
|
|
90
92
|
};
|
|
91
93
|
}
|
|
@@ -14,6 +14,12 @@ import { InputBilder } from "./input-builder";
|
|
|
14
14
|
import { OutputBuilder } from "./output-builder";
|
|
15
15
|
import { Wallet } from "../../bitcoin";
|
|
16
16
|
|
|
17
|
+
export class TransactionBuilderError extends Error {
|
|
18
|
+
constructor(message: string, public devMessage: string) {
|
|
19
|
+
super(message);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
|
|
17
23
|
export class TransactionBuilder {
|
|
18
24
|
static DefaultSequence = 0xffffffff;
|
|
19
25
|
static DefaultSighashType =
|
|
@@ -84,7 +90,11 @@ export class TransactionBuilder {
|
|
|
84
90
|
|
|
85
91
|
let fee = this.getFee(satoshisPerByte);
|
|
86
92
|
|
|
87
|
-
if (fee >= change)
|
|
93
|
+
if (fee >= change)
|
|
94
|
+
throw new TransactionBuilderError(
|
|
95
|
+
`Insufficient satoshis to pay fee`,
|
|
96
|
+
`Insufficient satoshis to pay fee. Change: ${change}; Fee: ${fee}`
|
|
97
|
+
);
|
|
88
98
|
|
|
89
99
|
output.Satoshis = change - fee;
|
|
90
100
|
|