@bitgo/wasm-utxo 1.44.0 → 2.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.
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -48
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +49 -32
- package/dist/cjs/js/index.d.ts +5 -1
- package/dist/cjs/js/psbt.d.ts +13 -6
- package/dist/cjs/js/transaction.d.ts +2 -6
- package/dist/cjs/js/transaction.js +6 -6
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +18 -86
- package/dist/cjs/js/wasm/wasm_utxo.js +414 -81
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +85 -71
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -48
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +49 -32
- package/dist/esm/js/index.d.ts +5 -1
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/psbt.d.ts +13 -6
- package/dist/esm/js/transaction.d.ts +2 -6
- package/dist/esm/js/transaction.js +6 -6
- package/dist/esm/js/wasm/wasm_utxo.d.ts +18 -86
- package/dist/esm/js/wasm/wasm_utxo_bg.js +414 -81
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +85 -71
- package/package.json +11 -4
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { BitGoPsbt as WasmBitGoPsbt, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
|
|
2
|
-
import type {
|
|
2
|
+
import type { IPsbtWithAddress } from "../psbt.js";
|
|
3
3
|
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
4
4
|
import { type ReplayProtectionArg } from "./ReplayProtection.js";
|
|
5
5
|
import { type BIP32Arg } from "../bip32.js";
|
|
@@ -98,7 +98,7 @@ export type ParseTransactionOptions = {
|
|
|
98
98
|
export type ParseOutputsOptions = {
|
|
99
99
|
payGoPubkeys?: ECPairArg[];
|
|
100
100
|
};
|
|
101
|
-
export declare class BitGoPsbt implements
|
|
101
|
+
export declare class BitGoPsbt implements IPsbtWithAddress {
|
|
102
102
|
protected _wasm: WasmBitGoPsbt;
|
|
103
103
|
protected constructor(_wasm: WasmBitGoPsbt);
|
|
104
104
|
/**
|
|
@@ -155,6 +155,8 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
155
155
|
* }, outputScript);
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
159
|
+
addInputAtIndex(index: number, options: AddInputOptions, script: Uint8Array): number;
|
|
158
160
|
addInput(options: AddInputOptions, script: Uint8Array): number;
|
|
159
161
|
/**
|
|
160
162
|
* Add an output to the PSBT
|
|
@@ -168,41 +170,11 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
168
170
|
* const outputIndex = psbt.addOutput(outputScript, 50000n);
|
|
169
171
|
* ```
|
|
170
172
|
*/
|
|
173
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
174
|
+
addOutputAtIndex(index: number, address: string, value: bigint): number;
|
|
175
|
+
addOutputAtIndex(index: number, options: AddOutputOptions): number;
|
|
171
176
|
addOutput(script: Uint8Array, value: bigint): number;
|
|
172
|
-
/**
|
|
173
|
-
* Add an output to the PSBT by address
|
|
174
|
-
*
|
|
175
|
-
* @param address - The destination address
|
|
176
|
-
* @param value - Value in satoshis
|
|
177
|
-
* @returns The index of the newly added output
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* const outputIndex = psbt.addOutput("bc1q...", 50000n);
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
177
|
addOutput(address: string, value: bigint): number;
|
|
185
|
-
/**
|
|
186
|
-
* Add an output to the PSBT
|
|
187
|
-
*
|
|
188
|
-
* @param options - Output options (script or address, and value)
|
|
189
|
-
* @returns The index of the newly added output
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* // Using script
|
|
194
|
-
* const outputIndex = psbt.addOutput({
|
|
195
|
-
* script: outputScript,
|
|
196
|
-
* value: 50000n,
|
|
197
|
-
* });
|
|
198
|
-
*
|
|
199
|
-
* // Using address
|
|
200
|
-
* const outputIndex = psbt.addOutput({
|
|
201
|
-
* address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
|
|
202
|
-
* value: 50000n,
|
|
203
|
-
* });
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
178
|
addOutput(options: AddOutputOptions): number;
|
|
207
179
|
/**
|
|
208
180
|
* Add a wallet input with full PSBT metadata
|
|
@@ -243,6 +215,7 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
243
215
|
* );
|
|
244
216
|
* ```
|
|
245
217
|
*/
|
|
218
|
+
addWalletInputAtIndex(index: number, inputOptions: AddInputOptions, walletKeys: WalletKeysArg, walletOptions: AddWalletInputOptions): number;
|
|
246
219
|
addWalletInput(inputOptions: AddInputOptions, walletKeys: WalletKeysArg, walletOptions: AddWalletInputOptions): number;
|
|
247
220
|
/**
|
|
248
221
|
* Add a wallet output with full PSBT metadata
|
|
@@ -274,6 +247,7 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
274
247
|
* });
|
|
275
248
|
* ```
|
|
276
249
|
*/
|
|
250
|
+
addWalletOutputAtIndex(index: number, walletKeys: WalletKeysArg, options: AddWalletOutputOptions): number;
|
|
277
251
|
addWalletOutput(walletKeys: WalletKeysArg, options: AddWalletOutputOptions): number;
|
|
278
252
|
/**
|
|
279
253
|
* Add a replay protection input to the PSBT
|
|
@@ -294,22 +268,21 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
294
268
|
* );
|
|
295
269
|
* ```
|
|
296
270
|
*/
|
|
271
|
+
addReplayProtectionInputAtIndex(index: number, inputOptions: AddInputOptions, key: ECPairArg): number;
|
|
297
272
|
addReplayProtectionInput(inputOptions: AddInputOptions, key: ECPairArg): number;
|
|
273
|
+
removeInput(index: number): void;
|
|
274
|
+
removeOutput(index: number): void;
|
|
298
275
|
/**
|
|
299
276
|
* Get the unsigned transaction ID
|
|
300
277
|
* @returns The unsigned transaction ID
|
|
301
278
|
*/
|
|
302
|
-
|
|
279
|
+
unsignedTxId(): string;
|
|
303
280
|
/**
|
|
304
281
|
* Get the transaction version
|
|
305
282
|
* @returns The transaction version number
|
|
306
283
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
* Get the transaction lock time
|
|
310
|
-
* @returns The transaction lock time
|
|
311
|
-
*/
|
|
312
|
-
get lockTime(): number;
|
|
284
|
+
version(): number;
|
|
285
|
+
lockTime(): number;
|
|
313
286
|
/**
|
|
314
287
|
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
315
288
|
* @param walletKeys - The wallet keys to use for identification
|
|
@@ -584,12 +557,8 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
584
557
|
* Get the number of inputs in the PSBT
|
|
585
558
|
* @returns The number of inputs
|
|
586
559
|
*/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
* Get the number of outputs in the PSBT
|
|
590
|
-
* @returns The number of outputs
|
|
591
|
-
*/
|
|
592
|
-
get outputCount(): number;
|
|
560
|
+
inputCount(): number;
|
|
561
|
+
outputCount(): number;
|
|
593
562
|
/**
|
|
594
563
|
* Get all PSBT inputs as an array
|
|
595
564
|
*
|
|
@@ -56,28 +56,35 @@ class BitGoPsbt {
|
|
|
56
56
|
const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
|
|
57
57
|
return new BitGoPsbt(wasm);
|
|
58
58
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param script - Output script of the UTXO being spent
|
|
67
|
-
* @returns The index of the newly added input
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const inputIndex = psbt.addInput({
|
|
72
|
-
* txid: "abc123...",
|
|
73
|
-
* vout: 0,
|
|
74
|
-
* value: 100000n,
|
|
75
|
-
* }, outputScript);
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
59
|
+
addInputAtIndex(index, txidOrOptions, voutOrScript, value, script, sequence) {
|
|
60
|
+
if (typeof txidOrOptions === "string") {
|
|
61
|
+
return this._wasm.add_input_at_index(index, txidOrOptions, voutOrScript, value, script, sequence);
|
|
62
|
+
}
|
|
63
|
+
const options = txidOrOptions;
|
|
64
|
+
return this._wasm.add_input_at_index(index, options.txid, options.vout, options.value, voutOrScript, options.sequence, options.prevTx);
|
|
65
|
+
}
|
|
78
66
|
addInput(options, script) {
|
|
79
67
|
return this._wasm.add_input(options.txid, options.vout, options.value, script, options.sequence, options.prevTx);
|
|
80
68
|
}
|
|
69
|
+
addOutputAtIndex(index, scriptOrOptions, value) {
|
|
70
|
+
if (scriptOrOptions instanceof Uint8Array || typeof scriptOrOptions === "string") {
|
|
71
|
+
if (value === undefined) {
|
|
72
|
+
throw new Error("Value is required when passing a script or address");
|
|
73
|
+
}
|
|
74
|
+
if (scriptOrOptions instanceof Uint8Array) {
|
|
75
|
+
return this._wasm.add_output_at_index(index, scriptOrOptions, value);
|
|
76
|
+
}
|
|
77
|
+
return this._wasm.add_output_with_address_at_index(index, scriptOrOptions, value);
|
|
78
|
+
}
|
|
79
|
+
const options = scriptOrOptions;
|
|
80
|
+
if ("script" in options) {
|
|
81
|
+
return this._wasm.add_output_at_index(index, options.script, options.value);
|
|
82
|
+
}
|
|
83
|
+
if ("address" in options) {
|
|
84
|
+
return this._wasm.add_output_with_address_at_index(index, options.address, options.value);
|
|
85
|
+
}
|
|
86
|
+
throw new Error("Invalid output options");
|
|
87
|
+
}
|
|
81
88
|
addOutput(scriptOrOptions, value) {
|
|
82
89
|
if (scriptOrOptions instanceof Uint8Array || typeof scriptOrOptions === "string") {
|
|
83
90
|
if (value === undefined) {
|
|
@@ -136,6 +143,10 @@ class BitGoPsbt {
|
|
|
136
143
|
* );
|
|
137
144
|
* ```
|
|
138
145
|
*/
|
|
146
|
+
addWalletInputAtIndex(index, inputOptions, walletKeys, walletOptions) {
|
|
147
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
148
|
+
return this._wasm.add_wallet_input_at_index(index, inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
|
|
149
|
+
}
|
|
139
150
|
addWalletInput(inputOptions, walletKeys, walletOptions) {
|
|
140
151
|
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
141
152
|
return this._wasm.add_wallet_input(inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
|
|
@@ -170,6 +181,10 @@ class BitGoPsbt {
|
|
|
170
181
|
* });
|
|
171
182
|
* ```
|
|
172
183
|
*/
|
|
184
|
+
addWalletOutputAtIndex(index, walletKeys, options) {
|
|
185
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
186
|
+
return this._wasm.add_wallet_output_at_index(index, options.chain, options.index, options.value, keys.wasm);
|
|
187
|
+
}
|
|
173
188
|
addWalletOutput(walletKeys, options) {
|
|
174
189
|
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
175
190
|
return this._wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
|
|
@@ -193,29 +208,35 @@ class BitGoPsbt {
|
|
|
193
208
|
* );
|
|
194
209
|
* ```
|
|
195
210
|
*/
|
|
211
|
+
addReplayProtectionInputAtIndex(index, inputOptions, key) {
|
|
212
|
+
const ecpair = ecpair_js_1.ECPair.from(key);
|
|
213
|
+
return this._wasm.add_replay_protection_input_at_index(index, ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
|
|
214
|
+
}
|
|
196
215
|
addReplayProtectionInput(inputOptions, key) {
|
|
197
216
|
const ecpair = ecpair_js_1.ECPair.from(key);
|
|
198
217
|
return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
|
|
199
218
|
}
|
|
219
|
+
removeInput(index) {
|
|
220
|
+
this._wasm.remove_input(index);
|
|
221
|
+
}
|
|
222
|
+
removeOutput(index) {
|
|
223
|
+
this._wasm.remove_output(index);
|
|
224
|
+
}
|
|
200
225
|
/**
|
|
201
226
|
* Get the unsigned transaction ID
|
|
202
227
|
* @returns The unsigned transaction ID
|
|
203
228
|
*/
|
|
204
|
-
|
|
229
|
+
unsignedTxId() {
|
|
205
230
|
return this._wasm.unsigned_txid();
|
|
206
231
|
}
|
|
207
232
|
/**
|
|
208
233
|
* Get the transaction version
|
|
209
234
|
* @returns The transaction version number
|
|
210
235
|
*/
|
|
211
|
-
|
|
236
|
+
version() {
|
|
212
237
|
return this._wasm.version();
|
|
213
238
|
}
|
|
214
|
-
|
|
215
|
-
* Get the transaction lock time
|
|
216
|
-
* @returns The transaction lock time
|
|
217
|
-
*/
|
|
218
|
-
get lockTime() {
|
|
239
|
+
lockTime() {
|
|
219
240
|
return this._wasm.lock_time();
|
|
220
241
|
}
|
|
221
242
|
/**
|
|
@@ -541,14 +562,10 @@ class BitGoPsbt {
|
|
|
541
562
|
* Get the number of inputs in the PSBT
|
|
542
563
|
* @returns The number of inputs
|
|
543
564
|
*/
|
|
544
|
-
|
|
565
|
+
inputCount() {
|
|
545
566
|
return this._wasm.input_count();
|
|
546
567
|
}
|
|
547
|
-
|
|
548
|
-
* Get the number of outputs in the PSBT
|
|
549
|
-
* @returns The number of outputs
|
|
550
|
-
*/
|
|
551
|
-
get outputCount() {
|
|
568
|
+
outputCount() {
|
|
552
569
|
return this._wasm.output_count();
|
|
553
570
|
}
|
|
554
571
|
/**
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -82,6 +82,10 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
82
82
|
validateSignatureAtInput(inputIndex: number, pubkey: Uint8Array): boolean;
|
|
83
83
|
verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
|
|
84
84
|
extractTransaction(): WasmTransaction;
|
|
85
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
86
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
87
|
+
removeInput(index: number): void;
|
|
88
|
+
removeOutput(index: number): void;
|
|
85
89
|
unsignedTxId(): string;
|
|
86
90
|
lockTime(): number;
|
|
87
91
|
version(): number;
|
|
@@ -91,4 +95,4 @@ export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
|
91
95
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
92
96
|
export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
|
|
93
97
|
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
94
|
-
export { hasPsbtMagic, type
|
|
98
|
+
export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
|
package/dist/cjs/js/psbt.d.ts
CHANGED
|
@@ -1,13 +1,20 @@
|
|
|
1
1
|
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
|
-
/** Common interface for PSBT
|
|
3
|
-
export interface
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
/** Common interface for PSBT types */
|
|
3
|
+
export interface IPsbt {
|
|
4
|
+
inputCount(): number;
|
|
5
|
+
outputCount(): number;
|
|
6
6
|
getInputs(): PsbtInputData[];
|
|
7
7
|
getOutputs(): PsbtOutputData[];
|
|
8
|
+
version(): number;
|
|
9
|
+
lockTime(): number;
|
|
10
|
+
unsignedTxId(): string;
|
|
11
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
12
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
13
|
+
removeInput(index: number): void;
|
|
14
|
+
removeOutput(index: number): void;
|
|
8
15
|
}
|
|
9
|
-
/** Extended
|
|
10
|
-
export interface
|
|
16
|
+
/** Extended PSBT with address resolution (no coin parameter needed) */
|
|
17
|
+
export interface IPsbtWithAddress extends IPsbt {
|
|
11
18
|
getOutputsWithAddress(): PsbtOutputDataWithAddress[];
|
|
12
19
|
}
|
|
13
20
|
/**
|
|
@@ -30,13 +30,9 @@ export declare class Transaction implements ITransaction {
|
|
|
30
30
|
* @param sequence - Optional sequence number (default: 0xFFFFFFFF)
|
|
31
31
|
* @returns The index of the newly added input
|
|
32
32
|
*/
|
|
33
|
+
addInputAtIndex(index: number, txid: string, vout: number, sequence?: number): number;
|
|
33
34
|
addInput(txid: string, vout: number, sequence?: number): number;
|
|
34
|
-
|
|
35
|
-
* Add an output to the transaction
|
|
36
|
-
* @param script - Output script (scriptPubKey)
|
|
37
|
-
* @param value - Value in satoshis
|
|
38
|
-
* @returns The index of the newly added output
|
|
39
|
-
*/
|
|
35
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
40
36
|
addOutput(script: Uint8Array, value: bigint): number;
|
|
41
37
|
toBytes(): Uint8Array;
|
|
42
38
|
/**
|
|
@@ -34,15 +34,15 @@ class Transaction {
|
|
|
34
34
|
* @param sequence - Optional sequence number (default: 0xFFFFFFFF)
|
|
35
35
|
* @returns The index of the newly added input
|
|
36
36
|
*/
|
|
37
|
+
addInputAtIndex(index, txid, vout, sequence) {
|
|
38
|
+
return this._wasm.add_input_at_index(index, txid, vout, sequence);
|
|
39
|
+
}
|
|
37
40
|
addInput(txid, vout, sequence) {
|
|
38
41
|
return this._wasm.add_input(txid, vout, sequence);
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @param value - Value in satoshis
|
|
44
|
-
* @returns The index of the newly added output
|
|
45
|
-
*/
|
|
43
|
+
addOutputAtIndex(index, script, value) {
|
|
44
|
+
return this._wasm.add_output_at_index(index, script, value);
|
|
45
|
+
}
|
|
46
46
|
addOutput(script, value) {
|
|
47
47
|
return this._wasm.add_output(script, value);
|
|
48
48
|
}
|
|
@@ -116,6 +116,7 @@ export class BitGoPsbt {
|
|
|
116
116
|
private constructor();
|
|
117
117
|
free(): void;
|
|
118
118
|
[Symbol.dispose](): void;
|
|
119
|
+
add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
119
120
|
/**
|
|
120
121
|
* Add an input to the PSBT
|
|
121
122
|
*
|
|
@@ -129,29 +130,11 @@ export class BitGoPsbt {
|
|
|
129
130
|
* # Returns
|
|
130
131
|
* The index of the newly added input
|
|
131
132
|
*/
|
|
132
|
-
|
|
133
|
-
/**
|
|
134
|
-
* Add an output to the PSBT
|
|
135
|
-
*
|
|
136
|
-
* # Arguments
|
|
137
|
-
* * `script` - The output script (scriptPubKey)
|
|
138
|
-
* * `value` - The value in satoshis
|
|
139
|
-
*
|
|
140
|
-
* # Returns
|
|
141
|
-
* The index of the newly added output
|
|
142
|
-
*/
|
|
133
|
+
add_input_at_index(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
143
134
|
add_output(script: Uint8Array, value: bigint): number;
|
|
144
|
-
|
|
145
|
-
* Add an output to the PSBT by address
|
|
146
|
-
*
|
|
147
|
-
* # Arguments
|
|
148
|
-
* * `address` - The destination address
|
|
149
|
-
* * `value` - The value in satoshis
|
|
150
|
-
*
|
|
151
|
-
* # Returns
|
|
152
|
-
* The index of the newly added output
|
|
153
|
-
*/
|
|
135
|
+
add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
|
|
154
136
|
add_output_with_address(address: string, value: bigint): number;
|
|
137
|
+
add_output_with_address_at_index(index: number, address: string, value: bigint): number;
|
|
155
138
|
/**
|
|
156
139
|
* Add a PayGo attestation to a PSBT output
|
|
157
140
|
*
|
|
@@ -165,61 +148,12 @@ export class BitGoPsbt {
|
|
|
165
148
|
* - `Err(WasmUtxoError)` if the output index is out of bounds or entropy is invalid
|
|
166
149
|
*/
|
|
167
150
|
add_paygo_attestation(output_index: number, entropy: Uint8Array, signature: Uint8Array): void;
|
|
168
|
-
/**
|
|
169
|
-
* Add a replay protection input to the PSBT
|
|
170
|
-
*
|
|
171
|
-
* Replay protection inputs are P2SH-P2PK inputs used on forked networks to prevent
|
|
172
|
-
* transaction replay attacks. They use a simple pubkey script without wallet derivation.
|
|
173
|
-
*
|
|
174
|
-
* # Arguments
|
|
175
|
-
* * `ecpair` - The ECPair containing the public key for the replay protection input
|
|
176
|
-
* * `txid` - The transaction ID (hex string) of the output being spent
|
|
177
|
-
* * `vout` - The output index being spent
|
|
178
|
-
* * `value` - The value in satoshis
|
|
179
|
-
* * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
|
|
180
|
-
*
|
|
181
|
-
* # Returns
|
|
182
|
-
* The index of the newly added input
|
|
183
|
-
*/
|
|
184
151
|
add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
185
|
-
|
|
186
|
-
* Add a wallet input with full PSBT metadata
|
|
187
|
-
*
|
|
188
|
-
* This is a higher-level method that adds an input and populates all required
|
|
189
|
-
* PSBT fields (scripts, derivation info, etc.) based on the wallet's chain type.
|
|
190
|
-
*
|
|
191
|
-
* # Arguments
|
|
192
|
-
* * `txid` - The transaction ID (hex string)
|
|
193
|
-
* * `vout` - The output index being spent
|
|
194
|
-
* * `value` - The value in satoshis
|
|
195
|
-
* * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
|
|
196
|
-
* * `index` - The derivation index
|
|
197
|
-
* * `wallet_keys` - The root wallet keys
|
|
198
|
-
* * `signer` - The key that will sign ("user", "backup", or "bitgo") - required for p2tr/p2trMusig2
|
|
199
|
-
* * `cosigner` - The key that will co-sign - required for p2tr/p2trMusig2
|
|
200
|
-
* * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
|
|
201
|
-
* * `prev_tx` - Optional full previous transaction bytes (for non-segwit)
|
|
202
|
-
*
|
|
203
|
-
* # Returns
|
|
204
|
-
* The index of the newly added input
|
|
205
|
-
*/
|
|
152
|
+
add_replay_protection_input_at_index(index: number, ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
206
153
|
add_wallet_input(txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
207
|
-
|
|
208
|
-
* Add a wallet output with full PSBT metadata
|
|
209
|
-
*
|
|
210
|
-
* This creates a verifiable wallet output (typically for change) with all required
|
|
211
|
-
* PSBT fields (scripts, derivation info) based on the wallet's chain type.
|
|
212
|
-
*
|
|
213
|
-
* # Arguments
|
|
214
|
-
* * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
|
|
215
|
-
* * `index` - The derivation index
|
|
216
|
-
* * `value` - The value in satoshis
|
|
217
|
-
* * `wallet_keys` - The root wallet keys
|
|
218
|
-
*
|
|
219
|
-
* # Returns
|
|
220
|
-
* The index of the newly added output
|
|
221
|
-
*/
|
|
154
|
+
add_wallet_input_at_index(index: number, txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, derivation_index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
222
155
|
add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
|
|
156
|
+
add_wallet_output_at_index(index: number, chain: number, derivation_index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
|
|
223
157
|
/**
|
|
224
158
|
* Combine/merge data from another PSBT into this one
|
|
225
159
|
*
|
|
@@ -452,6 +386,8 @@ export class BitGoPsbt {
|
|
|
452
386
|
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
453
387
|
*/
|
|
454
388
|
parse_transaction_with_wallet_keys(wallet_keys: WasmRootWalletKeys, replay_protection: WasmReplayProtection, paygo_pubkeys?: WasmECPair[] | null): any;
|
|
389
|
+
remove_input(index: number): void;
|
|
390
|
+
remove_output(index: number): void;
|
|
455
391
|
/**
|
|
456
392
|
* Serialize the PSBT to bytes
|
|
457
393
|
*
|
|
@@ -1230,6 +1166,7 @@ export class WasmTransaction {
|
|
|
1230
1166
|
private constructor();
|
|
1231
1167
|
free(): void;
|
|
1232
1168
|
[Symbol.dispose](): void;
|
|
1169
|
+
add_input(txid: string, vout: number, sequence?: number | null): number;
|
|
1233
1170
|
/**
|
|
1234
1171
|
* Add an input to the transaction
|
|
1235
1172
|
*
|
|
@@ -1241,18 +1178,9 @@ export class WasmTransaction {
|
|
|
1241
1178
|
* # Returns
|
|
1242
1179
|
* The index of the newly added input
|
|
1243
1180
|
*/
|
|
1244
|
-
|
|
1245
|
-
/**
|
|
1246
|
-
* Add an output to the transaction
|
|
1247
|
-
*
|
|
1248
|
-
* # Arguments
|
|
1249
|
-
* * `script` - The output script (scriptPubKey)
|
|
1250
|
-
* * `value` - The value in satoshis
|
|
1251
|
-
*
|
|
1252
|
-
* # Returns
|
|
1253
|
-
* The index of the newly added output
|
|
1254
|
-
*/
|
|
1181
|
+
add_input_at_index(index: number, txid: string, vout: number, sequence?: number | null): number;
|
|
1255
1182
|
add_output(script: Uint8Array, value: bigint): number;
|
|
1183
|
+
add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
|
|
1256
1184
|
/**
|
|
1257
1185
|
* Create an empty transaction (version 1, locktime 0)
|
|
1258
1186
|
*/
|
|
@@ -1373,6 +1301,7 @@ export class WrapMiniscript {
|
|
|
1373
1301
|
export class WrapPsbt {
|
|
1374
1302
|
free(): void;
|
|
1375
1303
|
[Symbol.dispose](): void;
|
|
1304
|
+
addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
|
|
1376
1305
|
/**
|
|
1377
1306
|
* Add an input to the PSBT
|
|
1378
1307
|
*
|
|
@@ -1386,7 +1315,8 @@ export class WrapPsbt {
|
|
|
1386
1315
|
* # Returns
|
|
1387
1316
|
* The index of the newly added input
|
|
1388
1317
|
*/
|
|
1389
|
-
|
|
1318
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
|
|
1319
|
+
addOutput(script: Uint8Array, value: bigint): number;
|
|
1390
1320
|
/**
|
|
1391
1321
|
* Add an output to the PSBT
|
|
1392
1322
|
*
|
|
@@ -1397,7 +1327,7 @@ export class WrapPsbt {
|
|
|
1397
1327
|
* # Returns
|
|
1398
1328
|
* The index of the newly added output
|
|
1399
1329
|
*/
|
|
1400
|
-
|
|
1330
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
1401
1331
|
clone(): WrapPsbt;
|
|
1402
1332
|
static deserialize(psbt: Uint8Array): WrapPsbt;
|
|
1403
1333
|
/**
|
|
@@ -1469,6 +1399,8 @@ export class WrapPsbt {
|
|
|
1469
1399
|
* Get the number of outputs in the PSBT
|
|
1470
1400
|
*/
|
|
1471
1401
|
outputCount(): number;
|
|
1402
|
+
removeInput(index: number): void;
|
|
1403
|
+
removeOutput(index: number): void;
|
|
1472
1404
|
serialize(): Uint8Array;
|
|
1473
1405
|
/**
|
|
1474
1406
|
* Sign all inputs with a WasmBIP32 key
|