@btc-vision/wallet-sdk 1.0.0

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.
Files changed (131) hide show
  1. package/LICENSE +15 -0
  2. package/README.md +24 -0
  3. package/es/bundle.js +2 -0
  4. package/es/bundle.js.LICENSE.txt +48 -0
  5. package/lib/address/index.d.ts +37 -0
  6. package/lib/address/index.js +235 -0
  7. package/lib/bitcoin-core.d.ts +5 -0
  8. package/lib/bitcoin-core.js +37 -0
  9. package/lib/constants.d.ts +1 -0
  10. package/lib/constants.js +5 -0
  11. package/lib/error.d.ts +20 -0
  12. package/lib/error.js +29 -0
  13. package/lib/index.d.ts +14 -0
  14. package/lib/index.js +50 -0
  15. package/lib/keyring/hd-keyring.d.ts +50 -0
  16. package/lib/keyring/hd-keyring.js +238 -0
  17. package/lib/keyring/index.d.ts +4 -0
  18. package/lib/keyring/index.js +20 -0
  19. package/lib/keyring/interfaces/SimpleKeyringOptions.d.ts +53 -0
  20. package/lib/keyring/interfaces/SimpleKeyringOptions.js +85 -0
  21. package/lib/keyring/keystone-keyring.d.ts +82 -0
  22. package/lib/keyring/keystone-keyring.js +377 -0
  23. package/lib/keyring/simple-keyring.d.ts +11 -0
  24. package/lib/keyring/simple-keyring.js +66 -0
  25. package/lib/message/bip322-simple.d.ts +19 -0
  26. package/lib/message/bip322-simple.js +182 -0
  27. package/lib/message/deterministic-ecdsa.d.ts +2 -0
  28. package/lib/message/deterministic-ecdsa.js +83 -0
  29. package/lib/message/ecdsa.d.ts +3 -0
  30. package/lib/message/ecdsa.js +32 -0
  31. package/lib/message/index.d.ts +3 -0
  32. package/lib/message/index.js +19 -0
  33. package/lib/network/index.d.ts +14 -0
  34. package/lib/network/index.js +40 -0
  35. package/lib/runes/index.d.ts +1 -0
  36. package/lib/runes/index.js +17 -0
  37. package/lib/runes/rund_id.d.ts +11 -0
  38. package/lib/runes/rund_id.js +30 -0
  39. package/lib/runes/varint.d.ts +15 -0
  40. package/lib/runes/varint.js +45 -0
  41. package/lib/src/address/index.d.ts +37 -0
  42. package/lib/src/bitcoin-core.d.ts +5 -0
  43. package/lib/src/constants.d.ts +1 -0
  44. package/lib/src/error.d.ts +20 -0
  45. package/lib/src/index.d.ts +14 -0
  46. package/lib/src/keyring/hd-keyring.d.ts +50 -0
  47. package/lib/src/keyring/index.d.ts +4 -0
  48. package/lib/src/keyring/interfaces/SimpleKeyringOptions.d.ts +53 -0
  49. package/lib/src/keyring/keystone-keyring.d.ts +82 -0
  50. package/lib/src/keyring/simple-keyring.d.ts +11 -0
  51. package/lib/src/message/bip322-simple.d.ts +19 -0
  52. package/lib/src/message/deterministic-ecdsa.d.ts +2 -0
  53. package/lib/src/message/ecdsa.d.ts +3 -0
  54. package/lib/src/message/index.d.ts +3 -0
  55. package/lib/src/network/index.d.ts +14 -0
  56. package/lib/src/runes/index.d.ts +1 -0
  57. package/lib/src/runes/rund_id.d.ts +11 -0
  58. package/lib/src/runes/varint.d.ts +15 -0
  59. package/lib/src/transaction/index.d.ts +3 -0
  60. package/lib/src/transaction/inscription-utxo.d.ts +33 -0
  61. package/lib/src/transaction/transaction.d.ts +52 -0
  62. package/lib/src/transaction/utxo.d.ts +35 -0
  63. package/lib/src/tx-helpers/index.d.ts +8 -0
  64. package/lib/src/tx-helpers/send-atomicals-ft.d.ts +16 -0
  65. package/lib/src/tx-helpers/send-atomicals-nft.d.ts +14 -0
  66. package/lib/src/tx-helpers/send-btc.d.ts +28 -0
  67. package/lib/src/tx-helpers/send-inscription.d.ts +16 -0
  68. package/lib/src/tx-helpers/send-inscriptions.d.ts +14 -0
  69. package/lib/src/tx-helpers/send-runes.d.ts +19 -0
  70. package/lib/src/tx-helpers/split-inscription-utxo.d.ts +15 -0
  71. package/lib/src/types.d.ts +59 -0
  72. package/lib/src/utils.d.ts +23 -0
  73. package/lib/src/wallet/abstract-wallet.d.ts +6 -0
  74. package/lib/src/wallet/estimate-wallet.d.ts +23 -0
  75. package/lib/src/wallet/index.d.ts +3 -0
  76. package/lib/src/wallet/local-wallet.d.ts +23 -0
  77. package/lib/test/address/address.test.d.ts +1 -0
  78. package/lib/test/keyring/hd-keyring.test.d.ts +1 -0
  79. package/lib/test/keyring/keystone-keyring.test.d.ts +1 -0
  80. package/lib/test/keyring/simple-keyring.test.d.ts +1 -0
  81. package/lib/test/message/message.test.d.ts +1 -0
  82. package/lib/test/runes/varint.test.d.ts +1 -0
  83. package/lib/test/transaction/transaction.test.d.ts +1 -0
  84. package/lib/test/transaction/utxo.test.d.ts +1 -0
  85. package/lib/test/tx-helpers/send-atomicals-ft.test.d.ts +1 -0
  86. package/lib/test/tx-helpers/send-atomicals-nft.test.d.ts +1 -0
  87. package/lib/test/tx-helpers/send-btc.test.d.ts +1 -0
  88. package/lib/test/tx-helpers/send-inscription.test.d.ts +1 -0
  89. package/lib/test/tx-helpers/send-inscriptions.test.d.ts +1 -0
  90. package/lib/test/tx-helpers/send-runes.test.d.ts +1 -0
  91. package/lib/test/tx-helpers/split-inscription-utxo.test.d.ts +1 -0
  92. package/lib/test/tx-helpers/utils.d.ts +217 -0
  93. package/lib/test/utils.d.ts +4 -0
  94. package/lib/test/wallet/local-wallet.test.d.ts +1 -0
  95. package/lib/transaction/index.d.ts +3 -0
  96. package/lib/transaction/index.js +19 -0
  97. package/lib/transaction/inscription-utxo.d.ts +33 -0
  98. package/lib/transaction/inscription-utxo.js +120 -0
  99. package/lib/transaction/transaction.d.ts +52 -0
  100. package/lib/transaction/transaction.js +358 -0
  101. package/lib/transaction/utxo.d.ts +35 -0
  102. package/lib/transaction/utxo.js +107 -0
  103. package/lib/tx-helpers/index.d.ts +8 -0
  104. package/lib/tx-helpers/index.js +18 -0
  105. package/lib/tx-helpers/send-atomicals-ft.d.ts +16 -0
  106. package/lib/tx-helpers/send-atomicals-ft.js +66 -0
  107. package/lib/tx-helpers/send-atomicals-nft.d.ts +14 -0
  108. package/lib/tx-helpers/send-atomicals-nft.js +45 -0
  109. package/lib/tx-helpers/send-btc.d.ts +28 -0
  110. package/lib/tx-helpers/send-btc.js +78 -0
  111. package/lib/tx-helpers/send-inscription.d.ts +16 -0
  112. package/lib/tx-helpers/send-inscription.js +49 -0
  113. package/lib/tx-helpers/send-inscriptions.d.ts +14 -0
  114. package/lib/tx-helpers/send-inscriptions.js +45 -0
  115. package/lib/tx-helpers/send-runes.d.ts +19 -0
  116. package/lib/tx-helpers/send-runes.js +101 -0
  117. package/lib/tx-helpers/split-inscription-utxo.d.ts +15 -0
  118. package/lib/tx-helpers/split-inscription-utxo.js +58 -0
  119. package/lib/types.d.ts +59 -0
  120. package/lib/types.js +15 -0
  121. package/lib/utils.d.ts +23 -0
  122. package/lib/utils.js +71 -0
  123. package/lib/wallet/abstract-wallet.d.ts +6 -0
  124. package/lib/wallet/abstract-wallet.js +2 -0
  125. package/lib/wallet/estimate-wallet.d.ts +23 -0
  126. package/lib/wallet/estimate-wallet.js +174 -0
  127. package/lib/wallet/index.d.ts +3 -0
  128. package/lib/wallet/index.js +19 -0
  129. package/lib/wallet/local-wallet.d.ts +23 -0
  130. package/lib/wallet/local-wallet.js +183 -0
  131. package/package.json +97 -0
@@ -0,0 +1,217 @@
1
+ import { AddressType, UnspentOutput } from '../../src/types';
2
+ import { LocalWallet } from '../../src/wallet';
3
+ /**
4
+ * generate dummy utxos
5
+ */
6
+ export declare function genDummyUtxos(wallet: LocalWallet, satoshisArray: number[], assetsArray?: {
7
+ inscriptions?: {
8
+ inscriptionId: string;
9
+ offset: number;
10
+ }[];
11
+ atomicals?: {
12
+ atomicalId: string;
13
+ atomicalNumber: number;
14
+ type: 'NFT' | 'FT';
15
+ ticker?: string;
16
+ atomicalValue: number;
17
+ }[];
18
+ }[]): UnspentOutput[];
19
+ /**
20
+ * generate a dummy utxo
21
+ */
22
+ export declare function genDummyUtxo(wallet: LocalWallet, satoshis: number, assets?: {
23
+ inscriptions?: {
24
+ inscriptionId: string;
25
+ offset: number;
26
+ }[];
27
+ atomicals?: {
28
+ atomicalId: string;
29
+ atomicalNumber: number;
30
+ type: 'NFT' | 'FT';
31
+ ticker?: string;
32
+ atomicalValue?: number;
33
+ }[];
34
+ runes?: {
35
+ runeid: string;
36
+ amount: string;
37
+ }[];
38
+ }, txid?: string, vout?: number): UnspentOutput;
39
+ /**
40
+ * generate a dummy atomical ft
41
+ */
42
+ export declare function genDummyAtomicalsFT(ticker: string, atomicalValue: number): {
43
+ atomicalId: string;
44
+ atomicalNumber: number;
45
+ type: 'NFT' | 'FT';
46
+ ticker: string;
47
+ atomicalValue: number;
48
+ };
49
+ /**
50
+ * generate a dummy atomical nft
51
+ */
52
+ export declare function genDummyAtomicalsNFT(): {
53
+ atomicalId: string;
54
+ atomicalNumber: number;
55
+ type: 'NFT' | 'FT';
56
+ };
57
+ /**
58
+ * For P2PKH, the signature length is not fixed, so we need to handle it specially
59
+ */
60
+ export declare function expectFeeRate(addressType: AddressType, feeRateA: number, feeRateB: number): void;
61
+ /**
62
+ * create a dummy send btc psbt for test
63
+ */
64
+ export declare function dummySendBTC({ wallet, btcUtxos, tos, feeRate, dump, enableRBF, memo, memos }: {
65
+ wallet: LocalWallet;
66
+ btcUtxos: UnspentOutput[];
67
+ tos: {
68
+ address: string;
69
+ satoshis: number;
70
+ }[];
71
+ feeRate: number;
72
+ dump?: boolean;
73
+ enableRBF?: boolean;
74
+ memo?: string;
75
+ memos?: string[];
76
+ }): Promise<{
77
+ psbt: import("bitcoinjs-lib").Psbt;
78
+ txid: string;
79
+ inputCount: number;
80
+ outputCount: number;
81
+ feeRate: number;
82
+ }>;
83
+ /**
84
+ * create a dummy send all btc psbt for test
85
+ */
86
+ export declare function dummySendAllBTC({ wallet, btcUtxos, toAddress, feeRate, dump, enableRBF }: {
87
+ wallet: LocalWallet;
88
+ btcUtxos: UnspentOutput[];
89
+ toAddress: string;
90
+ feeRate: number;
91
+ dump?: boolean;
92
+ enableRBF?: boolean;
93
+ }): Promise<{
94
+ psbt: import("bitcoinjs-lib").Psbt;
95
+ txid: string;
96
+ inputCount: number;
97
+ outputCount: number;
98
+ feeRate: number;
99
+ }>;
100
+ /**
101
+ * create a dummy send inscription psbt for test
102
+ */
103
+ export declare function dummySendInscription({ assetWallet, assetUtxo, btcWallet, btcUtxos, feeRate, toAddress, outputValue, dump, enableRBF, enableMixed }: {
104
+ assetWallet: LocalWallet;
105
+ assetUtxo: UnspentOutput;
106
+ btcWallet: LocalWallet;
107
+ btcUtxos: UnspentOutput[];
108
+ outputValue: number;
109
+ feeRate: number;
110
+ toAddress: string;
111
+ dump?: boolean;
112
+ enableRBF?: boolean;
113
+ enableMixed?: boolean;
114
+ }): Promise<{
115
+ psbt: import("bitcoinjs-lib").Psbt;
116
+ txid: string;
117
+ inputCount: number;
118
+ outputCount: number;
119
+ feeRate: number;
120
+ }>;
121
+ /**
122
+ * create a dummy send inscriptions psbt for test
123
+ */
124
+ export declare function dummySendInscriptions({ assetWallet, assetUtxos, btcWallet, btcUtxos, feeRate, toAddress, dump, enableRBF }: {
125
+ assetWallet: LocalWallet;
126
+ assetUtxos: UnspentOutput[];
127
+ btcWallet: LocalWallet;
128
+ btcUtxos: UnspentOutput[];
129
+ feeRate: number;
130
+ toAddress: string;
131
+ dump?: boolean;
132
+ enableRBF?: boolean;
133
+ }): Promise<{
134
+ psbt: import("bitcoinjs-lib").Psbt;
135
+ txid: string;
136
+ inputCount: number;
137
+ outputCount: number;
138
+ feeRate: number;
139
+ }>;
140
+ /**
141
+ * create a dummy split inscription psbt for test
142
+ */
143
+ export declare function dummySplitOrdUtxo({ assetWallet, assetUtxo, btcWallet, btcUtxos, feeRate, outputValue, dump, enableRBF }: {
144
+ assetWallet: LocalWallet;
145
+ assetUtxo: UnspentOutput;
146
+ btcWallet: LocalWallet;
147
+ btcUtxos: UnspentOutput[];
148
+ outputValue?: number;
149
+ feeRate: number;
150
+ dump?: boolean;
151
+ enableRBF?: boolean;
152
+ }): Promise<{
153
+ psbt: import("bitcoinjs-lib").Psbt;
154
+ txid: string;
155
+ inputCount: number;
156
+ outputCount: number;
157
+ feeRate: number;
158
+ splitedCount: number;
159
+ }>;
160
+ /**
161
+ * create a dummy send atomical ft psbt for test
162
+ */
163
+ export declare function dummySendAtomicalsFT({ assetWallet, assetUtxo, btcWallet, btcUtxos, feeRate, toAddress, dump, enableRBF, sendAmount }: {
164
+ assetWallet: LocalWallet;
165
+ assetUtxo: UnspentOutput;
166
+ btcWallet: LocalWallet;
167
+ btcUtxos: UnspentOutput[];
168
+ feeRate: number;
169
+ toAddress: string;
170
+ dump?: boolean;
171
+ enableRBF?: boolean;
172
+ sendAmount: number;
173
+ }): Promise<{
174
+ psbt: import("bitcoinjs-lib").Psbt;
175
+ txid: string;
176
+ inputCount: number;
177
+ outputCount: number;
178
+ feeRate: number;
179
+ }>;
180
+ /**
181
+ * create a dummy send atomical nft psbt for test
182
+ */
183
+ export declare function dummySendAtomical({ assetWallet, assetUtxo, btcWallet, btcUtxos, feeRate, toAddress, dump, enableRBF }: {
184
+ assetWallet: LocalWallet;
185
+ assetUtxo: UnspentOutput;
186
+ btcWallet: LocalWallet;
187
+ btcUtxos: UnspentOutput[];
188
+ feeRate: number;
189
+ toAddress: string;
190
+ dump?: boolean;
191
+ enableRBF?: boolean;
192
+ }): Promise<{
193
+ psbt: import("bitcoinjs-lib").Psbt;
194
+ txid: string;
195
+ inputCount: number;
196
+ outputCount: number;
197
+ feeRate: number;
198
+ }>;
199
+ export declare function dummySendRunes({ assetWallet, assetUtxo, btcWallet, btcUtxos, feeRate, toAddress, dump, enableRBF, runeid, runeAmount, outputValue }: {
200
+ assetWallet: LocalWallet;
201
+ assetUtxo: UnspentOutput;
202
+ btcWallet: LocalWallet;
203
+ btcUtxos: UnspentOutput[];
204
+ feeRate: number;
205
+ toAddress: string;
206
+ dump?: boolean;
207
+ enableRBF?: boolean;
208
+ runeid: string;
209
+ runeAmount: string;
210
+ outputValue: number;
211
+ }): Promise<{
212
+ psbt: import("bitcoinjs-lib").Psbt;
213
+ txid: string;
214
+ inputCount: number;
215
+ outputCount: number;
216
+ feeRate: number;
217
+ }>;
@@ -0,0 +1,4 @@
1
+ export declare function expectThrowError(func: any, errorMsg: any): Promise<void>;
2
+ import { bitcoin } from '../src/bitcoin-core';
3
+ export declare function printTx(rawtx: string): void;
4
+ export declare function printPsbt(psbtData: string | bitcoin.Psbt): void;
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,3 @@
1
+ export * from './inscription-utxo';
2
+ export * from './transaction';
3
+ export * from './utxo';
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./inscription-utxo"), exports);
18
+ __exportStar(require("./transaction"), exports);
19
+ __exportStar(require("./utxo"), exports);
@@ -0,0 +1,33 @@
1
+ import { UnspentOutput } from '../types';
2
+ export declare class InscriptionUnit {
3
+ satoshis: number;
4
+ inscriptions: {
5
+ id: string;
6
+ outputOffset: number;
7
+ unitOffset: number;
8
+ }[];
9
+ constructor(satoshis: number, inscriptions: {
10
+ id: string;
11
+ outputOffset: number;
12
+ unitOffset: number;
13
+ }[]);
14
+ hasInscriptions(): boolean;
15
+ }
16
+ export declare class InscriptionUnspendOutput {
17
+ inscriptionUnits: InscriptionUnit[];
18
+ utxo: UnspentOutput;
19
+ constructor(utxo: UnspentOutput, outputValue?: number);
20
+ private split;
21
+ /**
22
+ * Get non-Ord satoshis for spending
23
+ */
24
+ getNonInscriptionSatoshis(): number;
25
+ /**
26
+ * Get last non-ord satoshis for spending.
27
+ * Only the last one is available
28
+ * @returns
29
+ */
30
+ getLastUnitSatoshis(): number;
31
+ hasInscriptions(): boolean;
32
+ dump(): void;
33
+ }
@@ -0,0 +1,120 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.InscriptionUnspendOutput = exports.InscriptionUnit = void 0;
4
+ const constants_1 = require("../constants");
5
+ class InscriptionUnit {
6
+ constructor(satoshis, inscriptions) {
7
+ this.satoshis = satoshis;
8
+ this.inscriptions = inscriptions;
9
+ }
10
+ hasInscriptions() {
11
+ return this.inscriptions.length > 0;
12
+ }
13
+ }
14
+ exports.InscriptionUnit = InscriptionUnit;
15
+ class InscriptionUnspendOutput {
16
+ constructor(utxo, outputValue) {
17
+ this.utxo = utxo;
18
+ this.split(utxo.satoshis, utxo.inscriptions, outputValue);
19
+ }
20
+ // split the UTXO to units
21
+ split(satoshis, inscriptions, splitOutputValue = constants_1.UTXO_DUST) {
22
+ const inscriptionUnits = [];
23
+ let leftAmount = satoshis;
24
+ for (let i = 0; i < inscriptions.length; i++) {
25
+ const id = inscriptions[i].inscriptionId;
26
+ const offset = inscriptions[i].offset;
27
+ const usedSatoshis = satoshis - leftAmount;
28
+ const curOffset = offset - usedSatoshis;
29
+ if (curOffset < 0 || leftAmount < splitOutputValue) {
30
+ if (inscriptionUnits.length == 0) {
31
+ inscriptionUnits.push(new InscriptionUnit(leftAmount, [
32
+ {
33
+ id: id,
34
+ outputOffset: offset,
35
+ unitOffset: curOffset
36
+ }
37
+ ]));
38
+ leftAmount = 0;
39
+ }
40
+ else {
41
+ // injected to previous
42
+ const preUnit = inscriptionUnits[inscriptionUnits.length - 1];
43
+ preUnit.inscriptions.push({
44
+ id,
45
+ outputOffset: offset,
46
+ unitOffset: preUnit.satoshis + curOffset
47
+ });
48
+ continue;
49
+ }
50
+ }
51
+ if (leftAmount >= curOffset) {
52
+ if (leftAmount > splitOutputValue * 2) {
53
+ if (curOffset >= splitOutputValue) {
54
+ inscriptionUnits.push(new InscriptionUnit(curOffset, []));
55
+ inscriptionUnits.push(new InscriptionUnit(splitOutputValue, [
56
+ {
57
+ id,
58
+ outputOffset: offset,
59
+ unitOffset: 0
60
+ }
61
+ ]));
62
+ }
63
+ else {
64
+ inscriptionUnits.push(new InscriptionUnit(curOffset + splitOutputValue, [
65
+ {
66
+ id,
67
+ outputOffset: offset,
68
+ unitOffset: curOffset
69
+ }
70
+ ]));
71
+ }
72
+ }
73
+ else {
74
+ inscriptionUnits.push(new InscriptionUnit(curOffset + splitOutputValue, [{ id, outputOffset: offset, unitOffset: curOffset }]));
75
+ }
76
+ }
77
+ leftAmount -= curOffset + splitOutputValue;
78
+ }
79
+ if (leftAmount > constants_1.UTXO_DUST) {
80
+ inscriptionUnits.push(new InscriptionUnit(leftAmount, []));
81
+ }
82
+ else if (leftAmount > 0) {
83
+ if (inscriptionUnits.length > 0) {
84
+ inscriptionUnits[inscriptionUnits.length - 1].satoshis += leftAmount;
85
+ }
86
+ else {
87
+ inscriptionUnits.push(new InscriptionUnit(leftAmount, []));
88
+ }
89
+ }
90
+ this.inscriptionUnits = inscriptionUnits;
91
+ }
92
+ /**
93
+ * Get non-Ord satoshis for spending
94
+ */
95
+ getNonInscriptionSatoshis() {
96
+ return this.inscriptionUnits.filter((v) => v.inscriptions.length == 0).reduce((pre, cur) => pre + cur.satoshis, 0);
97
+ }
98
+ /**
99
+ * Get last non-ord satoshis for spending.
100
+ * Only the last one is available
101
+ * @returns
102
+ */
103
+ getLastUnitSatoshis() {
104
+ const last = this.inscriptionUnits[this.inscriptionUnits.length - 1];
105
+ if (last.inscriptions.length == 0) {
106
+ return last.satoshis;
107
+ }
108
+ return 0;
109
+ }
110
+ hasInscriptions() {
111
+ return this.utxo.inscriptions.length > 0;
112
+ }
113
+ // print each units
114
+ dump() {
115
+ this.inscriptionUnits.forEach((v) => {
116
+ console.log('satoshis:', v.satoshis, 'inscriptions:', v.inscriptions);
117
+ });
118
+ }
119
+ }
120
+ exports.InscriptionUnspendOutput = InscriptionUnspendOutput;
@@ -0,0 +1,52 @@
1
+ /// <reference types="node" />
2
+ import { bitcoin } from '../bitcoin-core';
3
+ import { NetworkType } from '../network';
4
+ import { ToSignInput, UnspentOutput } from '../types';
5
+ interface TxOutput {
6
+ address?: string;
7
+ script?: Buffer;
8
+ value: number;
9
+ }
10
+ /**
11
+ * Transaction
12
+ */
13
+ export declare class Transaction {
14
+ private utxos;
15
+ private inputs;
16
+ outputs: TxOutput[];
17
+ private changeOutputIndex;
18
+ changedAddress: string;
19
+ private networkType;
20
+ private feeRate;
21
+ private enableRBF;
22
+ private _cacheNetworkFee;
23
+ private _cacheBtcUtxos;
24
+ private _cacheToSignInputs;
25
+ constructor();
26
+ setNetworkType(network: NetworkType): void;
27
+ setEnableRBF(enable: boolean): void;
28
+ setFeeRate(feeRate: number): void;
29
+ setChangeAddress(address: string): void;
30
+ addInput(utxo: UnspentOutput): void;
31
+ removeLastInput(): void;
32
+ getTotalInput(): number;
33
+ getTotalOutput(): number;
34
+ getUnspent(): number;
35
+ calNetworkFee(): Promise<number>;
36
+ addOutput(address: string, value: number): void;
37
+ addOpreturn(data: Buffer[]): void;
38
+ addScriptOutput(script: Buffer, value: number): void;
39
+ getOutput(index: number): TxOutput;
40
+ addChangeOutput(value: number): void;
41
+ getChangeOutput(): TxOutput;
42
+ getChangeAmount(): number;
43
+ removeChangeOutput(): void;
44
+ removeRecentOutputs(count: number): void;
45
+ toPsbt(): bitcoin.Psbt;
46
+ clone(): Transaction;
47
+ createEstimatePsbt(): Promise<bitcoin.Psbt>;
48
+ private selectBtcUtxos;
49
+ addSufficientUtxosForFee(btcUtxos: UnspentOutput[], forceAsFee?: boolean): Promise<ToSignInput[]>;
50
+ dumpTx(psbt: any): Promise<void>;
51
+ }
52
+ export {};