@bitgo/wasm-utxo 1.34.0 → 1.36.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/bip32.d.ts +19 -0
- package/dist/cjs/js/bip32.js +29 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +8 -6
- package/dist/cjs/js/index.d.ts +7 -1
- package/dist/cjs/js/index.js +2 -2
- package/dist/cjs/js/message.d.ts +36 -0
- package/dist/cjs/js/message.js +47 -0
- package/dist/cjs/js/testutils/descriptor/descriptors.d.ts +27 -0
- package/dist/cjs/js/testutils/descriptor/descriptors.js +163 -0
- package/dist/cjs/js/testutils/descriptor/index.d.ts +2 -0
- package/dist/cjs/js/testutils/descriptor/index.js +18 -0
- package/dist/cjs/js/testutils/descriptor/mockPsbt.d.ts +41 -0
- package/dist/cjs/js/testutils/descriptor/mockPsbt.js +62 -0
- package/dist/cjs/js/testutils/fixtures.d.ts +35 -0
- package/dist/cjs/js/testutils/fixtures.js +244 -0
- package/dist/cjs/js/testutils/index.d.ts +2 -0
- package/dist/cjs/js/testutils/index.js +25 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +1417 -1331
- package/dist/cjs/js/wasm/wasm_utxo.js +2093 -1996
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +114 -108
- package/dist/esm/js/bip32.d.ts +19 -0
- package/dist/esm/js/bip32.js +29 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +8 -6
- package/dist/esm/js/index.d.ts +7 -1
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/message.d.ts +36 -0
- package/dist/esm/js/message.js +43 -0
- package/dist/esm/js/testutils/descriptor/descriptors.d.ts +27 -0
- package/dist/esm/js/testutils/descriptor/descriptors.js +150 -0
- package/dist/esm/js/testutils/descriptor/index.d.ts +2 -0
- package/dist/esm/js/testutils/descriptor/index.js +2 -0
- package/dist/esm/js/testutils/descriptor/mockPsbt.d.ts +41 -0
- package/dist/esm/js/testutils/descriptor/mockPsbt.js +56 -0
- package/dist/esm/js/testutils/fixtures.d.ts +35 -0
- package/dist/esm/js/testutils/fixtures.js +205 -0
- package/dist/esm/js/testutils/index.d.ts +2 -0
- package/dist/esm/js/testutils/index.js +2 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +1417 -1331
- package/dist/esm/js/wasm/wasm_utxo.js +7 -2
- package/dist/esm/js/wasm/wasm_utxo_bg.js +2096 -2008
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +114 -108
- package/package.json +11 -1
|
@@ -2,1383 +2,1469 @@
|
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
|
|
4
4
|
export class AddressNamespace {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
5
|
+
private constructor();
|
|
6
|
+
free(): void;
|
|
7
|
+
[Symbol.dispose](): void;
|
|
8
|
+
static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
|
|
9
|
+
static to_output_script_with_coin(address: string, coin: string): Uint8Array;
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
+
/**
|
|
13
|
+
* Namespace for BIP-0322 functions
|
|
14
|
+
*/
|
|
12
15
|
export class Bip322Namespace {
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
16
|
+
private constructor();
|
|
17
|
+
free(): void;
|
|
18
|
+
[Symbol.dispose](): void;
|
|
19
|
+
/**
|
|
20
|
+
* Add a BIP-0322 message input to an existing BitGoPsbt
|
|
21
|
+
*
|
|
22
|
+
* If this is the first input, also adds the OP_RETURN output.
|
|
23
|
+
* The PSBT must have version 0 per BIP-0322 specification.
|
|
24
|
+
*
|
|
25
|
+
* # Arguments
|
|
26
|
+
* * `psbt` - The BitGoPsbt to add the input to
|
|
27
|
+
* * `message` - The message to sign
|
|
28
|
+
* * `chain` - The wallet chain (e.g., 10 for external, 20 for internal)
|
|
29
|
+
* * `index` - The address index
|
|
30
|
+
* * `wallet_keys` - The wallet's root keys
|
|
31
|
+
* * `signer` - Optional signer key name for taproot (e.g., "user", "backup", "bitgo")
|
|
32
|
+
* * `cosigner` - Optional cosigner key name for taproot
|
|
33
|
+
* * `tag` - Optional custom tag for message hashing
|
|
34
|
+
*
|
|
35
|
+
* # Returns
|
|
36
|
+
* The index of the added input
|
|
37
|
+
*/
|
|
38
|
+
static add_bip322_input(psbt: BitGoPsbt, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, signer?: string | null, cosigner?: string | null, tag?: string | null): number;
|
|
39
|
+
/**
|
|
40
|
+
* Verify a single input of a BIP-0322 PSBT proof
|
|
41
|
+
*
|
|
42
|
+
* # Arguments
|
|
43
|
+
* * `psbt` - The signed BitGoPsbt
|
|
44
|
+
* * `input_index` - The index of the input to verify
|
|
45
|
+
* * `message` - The message that was signed
|
|
46
|
+
* * `chain` - The wallet chain
|
|
47
|
+
* * `index` - The address index
|
|
48
|
+
* * `wallet_keys` - The wallet's root keys
|
|
49
|
+
* * `tag` - Optional custom tag for message hashing
|
|
50
|
+
*
|
|
51
|
+
* # Returns
|
|
52
|
+
* An array of signer names ("user", "backup", "bitgo") that have valid signatures
|
|
53
|
+
*
|
|
54
|
+
* # Throws
|
|
55
|
+
* Throws an error if verification fails or no valid signatures found
|
|
56
|
+
*/
|
|
57
|
+
static verify_bip322_psbt_input(psbt: BitGoPsbt, input_index: number, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, tag?: string | null): string[];
|
|
58
|
+
/**
|
|
59
|
+
* Verify a single input of a BIP-0322 PSBT proof using pubkeys directly
|
|
60
|
+
*
|
|
61
|
+
* # Arguments
|
|
62
|
+
* * `psbt` - The signed BitGoPsbt
|
|
63
|
+
* * `input_index` - The index of the input to verify
|
|
64
|
+
* * `message` - The message that was signed
|
|
65
|
+
* * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
|
|
66
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
|
|
67
|
+
* * `is_script_path` - For taproot types, whether script path was used
|
|
68
|
+
* * `tag` - Optional custom tag for message hashing
|
|
69
|
+
*
|
|
70
|
+
* # Returns
|
|
71
|
+
* An array of pubkey indices (0, 1, 2) that have valid signatures
|
|
72
|
+
*
|
|
73
|
+
* # Throws
|
|
74
|
+
* Throws an error if verification fails or no valid signatures found
|
|
75
|
+
*/
|
|
76
|
+
static verify_bip322_psbt_input_with_pubkeys(psbt: BitGoPsbt, input_index: number, message: string, pubkeys: string[], script_type: string, is_script_path?: boolean | null, tag?: string | null): Uint32Array;
|
|
77
|
+
/**
|
|
78
|
+
* Verify a single input of a BIP-0322 transaction proof
|
|
79
|
+
*
|
|
80
|
+
* # Arguments
|
|
81
|
+
* * `tx` - The signed transaction
|
|
82
|
+
* * `input_index` - The index of the input to verify
|
|
83
|
+
* * `message` - The message that was signed
|
|
84
|
+
* * `chain` - The wallet chain
|
|
85
|
+
* * `index` - The address index
|
|
86
|
+
* * `wallet_keys` - The wallet's root keys
|
|
87
|
+
* * `network` - Network name
|
|
88
|
+
* * `tag` - Optional custom tag for message hashing
|
|
89
|
+
*
|
|
90
|
+
* # Throws
|
|
91
|
+
* Throws an error if verification fails
|
|
92
|
+
*/
|
|
93
|
+
static verify_bip322_tx_input(tx: WasmTransaction, input_index: number, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, network: string, tag?: string | null): void;
|
|
94
|
+
/**
|
|
95
|
+
* Verify a single input of a BIP-0322 transaction proof using pubkeys directly
|
|
96
|
+
*
|
|
97
|
+
* # Arguments
|
|
98
|
+
* * `tx` - The signed transaction
|
|
99
|
+
* * `input_index` - The index of the input to verify
|
|
100
|
+
* * `message` - The message that was signed
|
|
101
|
+
* * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
|
|
102
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
|
|
103
|
+
* * `is_script_path` - For taproot types, whether script path was used
|
|
104
|
+
* * `tag` - Optional custom tag for message hashing
|
|
105
|
+
*
|
|
106
|
+
* # Returns
|
|
107
|
+
* An array of pubkey indices (0, 1, 2) that have valid signatures
|
|
108
|
+
*
|
|
109
|
+
* # Throws
|
|
110
|
+
* Throws an error if verification fails
|
|
111
|
+
*/
|
|
112
|
+
static verify_bip322_tx_input_with_pubkeys(tx: WasmTransaction, input_index: number, message: string, pubkeys: string[], script_type: string, is_script_path?: boolean | null, tag?: string | null): Uint32Array;
|
|
110
113
|
}
|
|
111
114
|
|
|
112
115
|
export class BitGoPsbt {
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
|
|
336
|
-
|
|
337
|
-
|
|
338
|
-
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
|
|
342
|
-
|
|
343
|
-
|
|
344
|
-
|
|
345
|
-
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
|
|
361
|
-
|
|
362
|
-
|
|
363
|
-
|
|
364
|
-
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
|
|
376
|
-
|
|
377
|
-
|
|
378
|
-
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
382
|
-
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
403
|
-
|
|
404
|
-
|
|
405
|
-
|
|
406
|
-
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
|
|
425
|
-
|
|
426
|
-
|
|
427
|
-
|
|
428
|
-
|
|
429
|
-
|
|
430
|
-
|
|
431
|
-
|
|
432
|
-
|
|
433
|
-
|
|
434
|
-
|
|
435
|
-
|
|
436
|
-
|
|
437
|
-
|
|
438
|
-
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
446
|
-
|
|
447
|
-
|
|
448
|
-
|
|
449
|
-
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
|
|
484
|
-
|
|
485
|
-
|
|
486
|
-
|
|
487
|
-
|
|
488
|
-
|
|
489
|
-
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
|
|
494
|
-
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
|
|
498
|
-
|
|
499
|
-
|
|
500
|
-
|
|
501
|
-
|
|
502
|
-
|
|
503
|
-
|
|
504
|
-
|
|
505
|
-
|
|
506
|
-
|
|
507
|
-
|
|
508
|
-
|
|
509
|
-
|
|
510
|
-
|
|
511
|
-
|
|
512
|
-
|
|
513
|
-
|
|
514
|
-
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
|
|
522
|
-
|
|
523
|
-
|
|
524
|
-
|
|
525
|
-
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
|
|
529
|
-
|
|
530
|
-
|
|
531
|
-
|
|
532
|
-
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
560
|
-
|
|
561
|
-
|
|
562
|
-
|
|
563
|
-
|
|
564
|
-
|
|
565
|
-
|
|
566
|
-
|
|
567
|
-
|
|
568
|
-
|
|
569
|
-
|
|
570
|
-
|
|
571
|
-
|
|
572
|
-
|
|
573
|
-
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
609
|
-
|
|
610
|
-
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
|
|
615
|
-
|
|
616
|
-
|
|
617
|
-
|
|
618
|
-
|
|
619
|
-
|
|
620
|
-
|
|
621
|
-
|
|
622
|
-
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
|
|
626
|
-
|
|
627
|
-
|
|
628
|
-
|
|
629
|
-
|
|
630
|
-
|
|
631
|
-
|
|
632
|
-
|
|
633
|
-
|
|
634
|
-
|
|
635
|
-
|
|
636
|
-
|
|
637
|
-
|
|
638
|
-
|
|
639
|
-
|
|
640
|
-
|
|
641
|
-
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
|
|
645
|
-
|
|
646
|
-
|
|
647
|
-
|
|
648
|
-
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
684
|
-
|
|
685
|
-
|
|
686
|
-
|
|
687
|
-
|
|
688
|
-
|
|
689
|
-
|
|
690
|
-
|
|
691
|
-
|
|
692
|
-
|
|
693
|
-
|
|
694
|
-
|
|
695
|
-
|
|
696
|
-
|
|
116
|
+
private constructor();
|
|
117
|
+
free(): void;
|
|
118
|
+
[Symbol.dispose](): void;
|
|
119
|
+
/**
|
|
120
|
+
* Add an input to the PSBT
|
|
121
|
+
*
|
|
122
|
+
* # Arguments
|
|
123
|
+
* * `txid` - The transaction ID (hex string) of the output being spent
|
|
124
|
+
* * `vout` - The output index being spent
|
|
125
|
+
* * `value` - The value in satoshis of the output being spent
|
|
126
|
+
* * `script` - The output script (scriptPubKey) of the output being spent
|
|
127
|
+
* * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
|
|
128
|
+
*
|
|
129
|
+
* # Returns
|
|
130
|
+
* The index of the newly added input
|
|
131
|
+
*/
|
|
132
|
+
add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
|
|
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
|
+
*/
|
|
143
|
+
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
|
+
*/
|
|
154
|
+
add_output_with_address(address: string, value: bigint): number;
|
|
155
|
+
/**
|
|
156
|
+
* Add a PayGo attestation to a PSBT output
|
|
157
|
+
*
|
|
158
|
+
* # Arguments
|
|
159
|
+
* - `output_index`: The index of the output to add the attestation to
|
|
160
|
+
* - `entropy`: 64 bytes of entropy
|
|
161
|
+
* - `signature`: ECDSA signature bytes
|
|
162
|
+
*
|
|
163
|
+
* # Returns
|
|
164
|
+
* - `Ok(())` if the attestation was successfully added
|
|
165
|
+
* - `Err(WasmUtxoError)` if the output index is out of bounds or entropy is invalid
|
|
166
|
+
*/
|
|
167
|
+
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
|
+
add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | 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
|
+
*/
|
|
206
|
+
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
|
+
*/
|
|
222
|
+
add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
|
|
223
|
+
/**
|
|
224
|
+
* Combine/merge data from another PSBT into this one
|
|
225
|
+
*
|
|
226
|
+
* This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
|
|
227
|
+
* source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
|
|
228
|
+
* and signature collection phases.
|
|
229
|
+
*
|
|
230
|
+
* # Arguments
|
|
231
|
+
* * `source_psbt` - The source PSBT containing data to merge
|
|
232
|
+
*
|
|
233
|
+
* # Returns
|
|
234
|
+
* Ok(()) if data was successfully merged
|
|
235
|
+
*
|
|
236
|
+
* # Errors
|
|
237
|
+
* Returns error if networks don't match
|
|
238
|
+
*/
|
|
239
|
+
combine_musig2_nonces(source_psbt: BitGoPsbt): void;
|
|
240
|
+
/**
|
|
241
|
+
* Create an empty PSBT for the given network with wallet keys
|
|
242
|
+
*
|
|
243
|
+
* # Arguments
|
|
244
|
+
* * `network` - Network name (utxolib or coin name)
|
|
245
|
+
* * `wallet_keys` - The wallet's root keys (used to set global xpubs)
|
|
246
|
+
* * `version` - Optional transaction version (default: 2)
|
|
247
|
+
* * `lock_time` - Optional lock time (default: 0)
|
|
248
|
+
*/
|
|
249
|
+
static create_empty(network: string, wallet_keys: WasmRootWalletKeys, version?: number | null, lock_time?: number | null): BitGoPsbt;
|
|
250
|
+
/**
|
|
251
|
+
* Create an empty Zcash PSBT with the required consensus branch ID
|
|
252
|
+
*
|
|
253
|
+
* This method is specifically for Zcash networks which require additional
|
|
254
|
+
* parameters for sighash computation.
|
|
255
|
+
*
|
|
256
|
+
* # Arguments
|
|
257
|
+
* * `network` - Network name (must be "zcash" or "zcashTest")
|
|
258
|
+
* * `wallet_keys` - The wallet's root keys (used to set global xpubs)
|
|
259
|
+
* * `consensus_branch_id` - Zcash consensus branch ID (e.g., 0xC2D6D0B4 for NU5)
|
|
260
|
+
* * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
|
|
261
|
+
* * `lock_time` - Optional lock time (default: 0)
|
|
262
|
+
* * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
|
|
263
|
+
* * `expiry_height` - Optional expiry height
|
|
264
|
+
*/
|
|
265
|
+
static create_empty_zcash(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
266
|
+
/**
|
|
267
|
+
* Create an empty Zcash PSBT with consensus branch ID determined from block height
|
|
268
|
+
*
|
|
269
|
+
* This method automatically determines the correct consensus branch ID based on
|
|
270
|
+
* the network and block height using the network upgrade activation heights.
|
|
271
|
+
*
|
|
272
|
+
* # Arguments
|
|
273
|
+
* * `network` - Network name (must be "zcash" or "zcashTest")
|
|
274
|
+
* * `wallet_keys` - The wallet's root keys (used to set global xpubs)
|
|
275
|
+
* * `block_height` - Block height to determine consensus rules
|
|
276
|
+
* * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
|
|
277
|
+
* * `lock_time` - Optional lock time (default: 0)
|
|
278
|
+
* * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
|
|
279
|
+
* * `expiry_height` - Optional expiry height
|
|
280
|
+
*
|
|
281
|
+
* # Errors
|
|
282
|
+
* Returns error if block height is before Overwinter activation
|
|
283
|
+
*/
|
|
284
|
+
static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
|
|
285
|
+
/**
|
|
286
|
+
* Get the Zcash expiry height (returns None for non-Zcash PSBTs)
|
|
287
|
+
*/
|
|
288
|
+
expiry_height(): number | undefined;
|
|
289
|
+
/**
|
|
290
|
+
* Extract the final transaction as a WasmTransaction (for BitcoinLike networks)
|
|
291
|
+
*
|
|
292
|
+
* This avoids re-parsing bytes by returning the transaction directly.
|
|
293
|
+
* Only valid for Bitcoin-like networks (not Dash or Zcash).
|
|
294
|
+
*/
|
|
295
|
+
extract_bitcoin_transaction(): WasmTransaction;
|
|
296
|
+
/**
|
|
297
|
+
* Extract the final transaction as a WasmDashTransaction (for Dash networks)
|
|
298
|
+
*
|
|
299
|
+
* This avoids re-parsing bytes by returning the transaction directly.
|
|
300
|
+
* Only valid for Dash networks.
|
|
301
|
+
*/
|
|
302
|
+
extract_dash_transaction(): WasmDashTransaction;
|
|
303
|
+
/**
|
|
304
|
+
* Extract a half-signed transaction in legacy format for p2ms-based script types.
|
|
305
|
+
*
|
|
306
|
+
* This method extracts a transaction where each input has exactly one signature,
|
|
307
|
+
* formatted in the legacy style used by utxo-lib and bitcoinjs-lib. The legacy
|
|
308
|
+
* format places signatures in the correct position (0, 1, or 2) based on which
|
|
309
|
+
* key signed, with empty placeholders for unsigned positions.
|
|
310
|
+
*
|
|
311
|
+
* # Requirements
|
|
312
|
+
* - All inputs must be p2ms-based (p2sh, p2shP2wsh, or p2wsh)
|
|
313
|
+
* - Each input must have exactly 1 partial signature
|
|
314
|
+
*
|
|
315
|
+
* # Returns
|
|
316
|
+
* - `Ok(Vec<u8>)` containing the serialized half-signed transaction bytes
|
|
317
|
+
* - `Err(WasmUtxoError)` if validation fails or extraction fails
|
|
318
|
+
*
|
|
319
|
+
* # Errors
|
|
320
|
+
* - Returns error if any input is not a p2ms type (Taproot, replay protection, etc.)
|
|
321
|
+
* - Returns error if any input has 0 or more than 1 partial signature
|
|
322
|
+
*/
|
|
323
|
+
extract_half_signed_legacy_tx(): Uint8Array;
|
|
324
|
+
/**
|
|
325
|
+
* Extract the final transaction from a finalized PSBT
|
|
326
|
+
*
|
|
327
|
+
* This method should be called after all inputs have been finalized.
|
|
328
|
+
* It extracts the fully signed transaction as a WASM transaction instance
|
|
329
|
+
* appropriate for the network (WasmTransaction, WasmDashTransaction, or WasmZcashTransaction).
|
|
330
|
+
*
|
|
331
|
+
* # Returns
|
|
332
|
+
* - `Ok(JsValue)` containing the WASM transaction instance
|
|
333
|
+
* - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
|
|
334
|
+
*/
|
|
335
|
+
extract_transaction(): any;
|
|
336
|
+
/**
|
|
337
|
+
* Extract the final transaction as a WasmZcashTransaction (for Zcash networks)
|
|
338
|
+
*
|
|
339
|
+
* This avoids re-parsing bytes by returning the transaction directly.
|
|
340
|
+
* Only valid for Zcash networks.
|
|
341
|
+
*/
|
|
342
|
+
extract_zcash_transaction(): WasmZcashTransaction;
|
|
343
|
+
/**
|
|
344
|
+
* Finalize all inputs in the PSBT
|
|
345
|
+
*
|
|
346
|
+
* This method attempts to finalize all inputs in the PSBT, computing the final
|
|
347
|
+
* scriptSig and witness data for each input.
|
|
348
|
+
*
|
|
349
|
+
* # Returns
|
|
350
|
+
* - `Ok(())` if all inputs were successfully finalized
|
|
351
|
+
* - `Err(WasmUtxoError)` if any input failed to finalize
|
|
352
|
+
*/
|
|
353
|
+
finalize_all_inputs(): void;
|
|
354
|
+
/**
|
|
355
|
+
* Deserialize a PSBT from bytes with network-specific logic
|
|
356
|
+
*/
|
|
357
|
+
static from_bytes(bytes: Uint8Array, network: string): BitGoPsbt;
|
|
358
|
+
/**
|
|
359
|
+
* Generate and store MuSig2 nonces for all MuSig2 inputs
|
|
360
|
+
*
|
|
361
|
+
* This method generates nonces using the State-Machine API and stores them in the PSBT.
|
|
362
|
+
* The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
|
|
363
|
+
* After ALL participants have generated their nonces, they can sign MuSig2 inputs using
|
|
364
|
+
* sign_with_xpriv().
|
|
365
|
+
*
|
|
366
|
+
* # Arguments
|
|
367
|
+
* * `xpriv` - The extended private key (xpriv) for signing
|
|
368
|
+
* * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
|
|
369
|
+
* On mainnets, a secure random session ID is always generated automatically.
|
|
370
|
+
* Must be unique per signing session.
|
|
371
|
+
*
|
|
372
|
+
* # Returns
|
|
373
|
+
* Ok(()) if nonces were successfully generated and stored
|
|
374
|
+
*
|
|
375
|
+
* # Errors
|
|
376
|
+
* Returns error if:
|
|
377
|
+
* - Nonce generation fails
|
|
378
|
+
* - session_id length is invalid
|
|
379
|
+
* - Custom session_id is provided on a mainnet (security restriction)
|
|
380
|
+
*
|
|
381
|
+
* # Security
|
|
382
|
+
* The session_id MUST be cryptographically random and unique for each signing session.
|
|
383
|
+
* Never reuse a session_id with the same key! On mainnets, session_id is always randomly
|
|
384
|
+
* generated for security. Custom session_id is only allowed on testnets for testing purposes.
|
|
385
|
+
*/
|
|
386
|
+
generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
|
|
387
|
+
/**
|
|
388
|
+
* Get the network type for transaction extraction
|
|
389
|
+
*
|
|
390
|
+
* Returns "bitcoin", "dash", or "zcash" to indicate which transaction
|
|
391
|
+
* wrapper class should be used in TypeScript.
|
|
392
|
+
*/
|
|
393
|
+
get_network_type(): string;
|
|
394
|
+
/**
|
|
395
|
+
* Check if an input is a MuSig2 keypath input.
|
|
396
|
+
*
|
|
397
|
+
* MuSig2 inputs require special handling: nonces must be generated first with
|
|
398
|
+
* `generate_musig2_nonces()`, then signed with `sign_musig2_input()`.
|
|
399
|
+
*
|
|
400
|
+
* # Arguments
|
|
401
|
+
* - `input_index`: The index of the input to check (0-based)
|
|
402
|
+
*
|
|
403
|
+
* # Returns
|
|
404
|
+
* - `true` if the input is a MuSig2 keypath input
|
|
405
|
+
* - `false` otherwise (or if input_index is out of bounds)
|
|
406
|
+
*/
|
|
407
|
+
is_musig2_input(input_index: number): boolean;
|
|
408
|
+
/**
|
|
409
|
+
* Get the transaction lock time
|
|
410
|
+
*/
|
|
411
|
+
lock_time(): number;
|
|
412
|
+
/**
|
|
413
|
+
* Get the network of the PSBT
|
|
414
|
+
*/
|
|
415
|
+
network(): string;
|
|
416
|
+
/**
|
|
417
|
+
* Parse outputs with wallet keys to identify which outputs belong to a wallet
|
|
418
|
+
*
|
|
419
|
+
* Note: This method does NOT validate wallet inputs. It only parses outputs.
|
|
420
|
+
*/
|
|
421
|
+
parse_outputs_with_wallet_keys(wallet_keys: WasmRootWalletKeys, paygo_pubkeys?: WasmECPair[] | null): any;
|
|
422
|
+
/**
|
|
423
|
+
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
424
|
+
*/
|
|
425
|
+
parse_transaction_with_wallet_keys(wallet_keys: WasmRootWalletKeys, replay_protection: WasmReplayProtection, paygo_pubkeys?: WasmECPair[] | null): any;
|
|
426
|
+
/**
|
|
427
|
+
* Serialize the PSBT to bytes
|
|
428
|
+
*
|
|
429
|
+
* # Returns
|
|
430
|
+
* The serialized PSBT as a byte array
|
|
431
|
+
*/
|
|
432
|
+
serialize(): Uint8Array;
|
|
433
|
+
/**
|
|
434
|
+
* Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
|
|
435
|
+
*
|
|
436
|
+
* This is more efficient than calling `sign_musig2_input()` for each input because
|
|
437
|
+
* it reuses the SighashCache across all inputs, avoiding redundant computation of
|
|
438
|
+
* sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs.
|
|
439
|
+
*
|
|
440
|
+
* Each MuSig2 input requires a FirstRound from `generate_musig2_nonces()`.
|
|
441
|
+
* FirstRounds that have already been consumed (signed) are skipped.
|
|
442
|
+
*
|
|
443
|
+
* # Arguments
|
|
444
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
445
|
+
*
|
|
446
|
+
* # Returns
|
|
447
|
+
* - `Ok(JsValue)` with an array of input indices that were signed
|
|
448
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
449
|
+
*/
|
|
450
|
+
sign_all_musig2_inputs(xpriv: WasmBIP32): any;
|
|
451
|
+
/**
|
|
452
|
+
* Sign all replay protection inputs with a raw private key.
|
|
453
|
+
*
|
|
454
|
+
* This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
|
|
455
|
+
* that match the provided public key and signs them.
|
|
456
|
+
*
|
|
457
|
+
* # Arguments
|
|
458
|
+
* - `ecpair`: The ECPair containing the private key
|
|
459
|
+
*
|
|
460
|
+
* # Returns
|
|
461
|
+
* - `Ok(JsValue)` with an array of input indices that were signed
|
|
462
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
463
|
+
*/
|
|
464
|
+
sign_all_replay_protection_inputs(ecpair: WasmECPair): any;
|
|
465
|
+
/**
|
|
466
|
+
* Sign all non-MuSig2 wallet inputs in a single efficient pass.
|
|
467
|
+
*
|
|
468
|
+
* This signs all ECDSA (P2SH, P2SH-P2WSH, P2WSH) and Taproot script path (P2TR)
|
|
469
|
+
* inputs that match the provided xpriv. MuSig2 keypath inputs are skipped.
|
|
470
|
+
*
|
|
471
|
+
* This is the most efficient way to sign wallet inputs. After calling this,
|
|
472
|
+
* sign any MuSig2 inputs using `sign_all_musig2_inputs()` or `sign_musig2_input()`.
|
|
473
|
+
*
|
|
474
|
+
* # Arguments
|
|
475
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
476
|
+
*
|
|
477
|
+
* # Returns
|
|
478
|
+
* - `Ok(JsValue)` with an array of input indices that were signed
|
|
479
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
480
|
+
*/
|
|
481
|
+
sign_all_wallet_inputs(xpriv: WasmBIP32): any;
|
|
482
|
+
/**
|
|
483
|
+
* Sign all non-MuSig2 inputs with an extended private key (xpriv) in a single pass.
|
|
484
|
+
*
|
|
485
|
+
* This is more efficient than calling `sign_with_xpriv` for each input individually.
|
|
486
|
+
* The underlying miniscript library's `sign` method signs all matching inputs at once.
|
|
487
|
+
*
|
|
488
|
+
* **Note:** MuSig2 inputs are skipped by this method because they require FirstRound
|
|
489
|
+
* state from nonce generation. After calling this method, sign MuSig2 inputs
|
|
490
|
+
* individually using `sign_with_xpriv`.
|
|
491
|
+
*
|
|
492
|
+
* # Arguments
|
|
493
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
494
|
+
*
|
|
495
|
+
* # Returns
|
|
496
|
+
* - `Ok(JsValue)` with an array of input indices that were signed
|
|
497
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
498
|
+
*/
|
|
499
|
+
sign_all_with_xpriv(xpriv: WasmBIP32): any;
|
|
500
|
+
/**
|
|
501
|
+
* Sign a single MuSig2 keypath input.
|
|
502
|
+
*
|
|
503
|
+
* This uses the FirstRound state generated by `generate_musig2_nonces()`.
|
|
504
|
+
* Each FirstRound can only be used once (nonce reuse is a security risk).
|
|
505
|
+
*
|
|
506
|
+
* For non-MuSig2 inputs, returns an error (use `sign_wallet_input` instead).
|
|
507
|
+
*
|
|
508
|
+
* # Arguments
|
|
509
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
510
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
511
|
+
*
|
|
512
|
+
* # Returns
|
|
513
|
+
* - `Ok(())` if signing was successful
|
|
514
|
+
* - `Err(WasmUtxoError)` if signing fails, no FirstRound exists, or not a MuSig2 input
|
|
515
|
+
*/
|
|
516
|
+
sign_musig2_input(input_index: number, xpriv: WasmBIP32): void;
|
|
517
|
+
/**
|
|
518
|
+
* Sign all replay protection inputs with a raw private key.
|
|
519
|
+
*
|
|
520
|
+
* This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
|
|
521
|
+
* that match the provided public key and signs them.
|
|
522
|
+
*
|
|
523
|
+
* # Arguments
|
|
524
|
+
* - `ecpair`: The ECPair containing the private key
|
|
525
|
+
*
|
|
526
|
+
* # Returns
|
|
527
|
+
* - `Ok(JsValue)` with an array of input indices that were signed
|
|
528
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
529
|
+
*/
|
|
530
|
+
sign_replay_protection_inputs(ecpair: WasmECPair): any;
|
|
531
|
+
/**
|
|
532
|
+
* Sign a single input with a raw private key, using save/restore for regular inputs.
|
|
533
|
+
*
|
|
534
|
+
* For replay protection inputs (P2SH-P2PK), this uses direct signing which is
|
|
535
|
+
* already single-input. For regular inputs, this clones the PSBT, signs all,
|
|
536
|
+
* then copies only the target input's signatures back.
|
|
537
|
+
*
|
|
538
|
+
* **Important:** This is NOT faster than signing all inputs for regular (non-RP) inputs.
|
|
539
|
+
* The underlying miniscript library signs all inputs regardless.
|
|
540
|
+
*
|
|
541
|
+
* # Arguments
|
|
542
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
543
|
+
* - `ecpair`: The ECPair containing the private key
|
|
544
|
+
*
|
|
545
|
+
* # Returns
|
|
546
|
+
* - `Ok(())` if the input was signed
|
|
547
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
548
|
+
*/
|
|
549
|
+
sign_single_input_with_privkey(input_index: number, ecpair: WasmECPair): void;
|
|
550
|
+
/**
|
|
551
|
+
* Sign a single input with an extended private key, using save/restore for ECDSA inputs.
|
|
552
|
+
*
|
|
553
|
+
* For MuSig2 inputs, this returns an error (use sign_with_xpriv which handles FirstRound).
|
|
554
|
+
* For ECDSA inputs, this clones the PSBT, signs all, then copies only the target
|
|
555
|
+
* input's signatures back.
|
|
556
|
+
*
|
|
557
|
+
* **Important:** This is NOT faster than `sign_all_with_xpriv` for ECDSA inputs.
|
|
558
|
+
* The underlying miniscript library signs all inputs regardless. This method
|
|
559
|
+
* just prevents signatures from being added to other inputs.
|
|
560
|
+
*
|
|
561
|
+
* # Arguments
|
|
562
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
563
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
564
|
+
*
|
|
565
|
+
* # Returns
|
|
566
|
+
* - `Ok(())` if the input was signed
|
|
567
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
568
|
+
*/
|
|
569
|
+
sign_single_input_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
|
|
570
|
+
/**
|
|
571
|
+
* Sign a single non-MuSig2 wallet input using save/restore pattern.
|
|
572
|
+
*
|
|
573
|
+
* For MuSig2 inputs, returns an error (use `sign_musig2_input` instead).
|
|
574
|
+
* For ECDSA inputs, this uses a save/restore pattern: clones the PSBT,
|
|
575
|
+
* signs all inputs on the clone, then copies only the target input's
|
|
576
|
+
* signatures back.
|
|
577
|
+
*
|
|
578
|
+
* **Important:** This is NOT faster than `sign_all_wallet_inputs()` for ECDSA inputs.
|
|
579
|
+
* The underlying library signs all inputs regardless. This method just ensures
|
|
580
|
+
* that only the specified input gets signatures added to the PSBT.
|
|
581
|
+
* Use `sign_all_wallet_inputs()` when signing multiple inputs with the same key.
|
|
582
|
+
*
|
|
583
|
+
* # Arguments
|
|
584
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
585
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
586
|
+
*
|
|
587
|
+
* # Returns
|
|
588
|
+
* - `Ok(())` if the input was signed
|
|
589
|
+
* - `Err(WasmUtxoError)` if signing fails or input is MuSig2
|
|
590
|
+
*/
|
|
591
|
+
sign_wallet_input(input_index: number, xpriv: WasmBIP32): void;
|
|
592
|
+
/**
|
|
593
|
+
* Sign a single input with a raw private key
|
|
594
|
+
*
|
|
595
|
+
* This method signs a specific input using the provided ECPair. It accepts:
|
|
596
|
+
* - A raw privkey (WasmECPair) for replay protection inputs - signs directly
|
|
597
|
+
*
|
|
598
|
+
* This method automatically detects and handles different input types:
|
|
599
|
+
* - For replay protection inputs: signs with legacy P2SH sighash
|
|
600
|
+
* - For regular inputs: uses standard PSBT signing
|
|
601
|
+
* - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
|
|
602
|
+
*
|
|
603
|
+
* # Arguments
|
|
604
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
605
|
+
* - `ecpair`: The ECPair containing the private key
|
|
606
|
+
*
|
|
607
|
+
* # Returns
|
|
608
|
+
* - `Ok(())` if signing was successful
|
|
609
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
610
|
+
*/
|
|
611
|
+
sign_with_privkey(input_index: number, ecpair: WasmECPair): void;
|
|
612
|
+
/**
|
|
613
|
+
* Sign a single input with an extended private key (xpriv)
|
|
614
|
+
*
|
|
615
|
+
* This method signs a specific input using the provided xpriv. It accepts:
|
|
616
|
+
* - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
|
|
617
|
+
*
|
|
618
|
+
* This method automatically detects and handles different input types:
|
|
619
|
+
* - For regular inputs: uses standard PSBT signing
|
|
620
|
+
* - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
|
|
621
|
+
* - For replay protection inputs: returns error (use sign_with_privkey instead)
|
|
622
|
+
*
|
|
623
|
+
* # Arguments
|
|
624
|
+
* - `input_index`: The index of the input to sign (0-based)
|
|
625
|
+
* - `xpriv`: The extended private key as a WasmBIP32 instance
|
|
626
|
+
*
|
|
627
|
+
* # Returns
|
|
628
|
+
* - `Ok(())` if signing was successful
|
|
629
|
+
* - `Err(WasmUtxoError)` if signing fails
|
|
630
|
+
*/
|
|
631
|
+
sign_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
|
|
632
|
+
/**
|
|
633
|
+
* Get the unsigned transaction ID
|
|
634
|
+
*/
|
|
635
|
+
unsigned_txid(): string;
|
|
636
|
+
/**
|
|
637
|
+
* Verify if a replay protection input has a valid signature
|
|
638
|
+
*
|
|
639
|
+
* This method checks if a given input is a replay protection input and cryptographically verifies
|
|
640
|
+
* the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
|
|
641
|
+
* so this method verifies signatures without deriving from xpub.
|
|
642
|
+
*
|
|
643
|
+
* # Arguments
|
|
644
|
+
* - `input_index`: The index of the input to check
|
|
645
|
+
* - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
|
|
646
|
+
* Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
|
|
647
|
+
*
|
|
648
|
+
* # Returns
|
|
649
|
+
* - `Ok(true)` if the input is a replay protection input and has a valid signature
|
|
650
|
+
* - `Ok(false)` if the input is a replay protection input but has no valid signature
|
|
651
|
+
* - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
|
|
652
|
+
*/
|
|
653
|
+
verify_replay_protection_signature(input_index: number, replay_protection: WasmReplayProtection): boolean;
|
|
654
|
+
/**
|
|
655
|
+
* Verify if a valid signature exists for a given ECPair key at the specified input index
|
|
656
|
+
*
|
|
657
|
+
* This method verifies the signature directly with the provided ECPair's public key. It supports:
|
|
658
|
+
* - ECDSA signatures (for legacy/SegWit inputs)
|
|
659
|
+
* - Schnorr signatures (for Taproot script path inputs)
|
|
660
|
+
*
|
|
661
|
+
* Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
|
|
662
|
+
* Use `verify_signature_with_xpub` for MuSig2 inputs.
|
|
663
|
+
*
|
|
664
|
+
* # Arguments
|
|
665
|
+
* - `input_index`: The index of the input to check
|
|
666
|
+
* - `ecpair`: The ECPair key (uses the public key for verification)
|
|
667
|
+
*
|
|
668
|
+
* # Returns
|
|
669
|
+
* - `Ok(true)` if a valid signature exists for the public key
|
|
670
|
+
* - `Ok(false)` if no signature exists for the public key
|
|
671
|
+
* - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
|
|
672
|
+
*/
|
|
673
|
+
verify_signature_with_pub(input_index: number, ecpair: WasmECPair): boolean;
|
|
674
|
+
/**
|
|
675
|
+
* Verify if a valid signature exists for a given xpub at the specified input index
|
|
676
|
+
*
|
|
677
|
+
* This method derives the public key from the xpub using the derivation path found in the
|
|
678
|
+
* PSBT input, then verifies the signature. It supports:
|
|
679
|
+
* - ECDSA signatures (for legacy/SegWit inputs)
|
|
680
|
+
* - Schnorr signatures (for Taproot script path inputs)
|
|
681
|
+
* - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
|
|
682
|
+
*
|
|
683
|
+
* # Arguments
|
|
684
|
+
* - `input_index`: The index of the input to check
|
|
685
|
+
* - `xpub`: The extended public key as a WasmBIP32 instance
|
|
686
|
+
*
|
|
687
|
+
* # Returns
|
|
688
|
+
* - `Ok(true)` if a valid signature exists for the derived public key
|
|
689
|
+
* - `Ok(false)` if no signature exists for the derived public key
|
|
690
|
+
* - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
|
|
691
|
+
*/
|
|
692
|
+
verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
|
|
693
|
+
/**
|
|
694
|
+
* Get the transaction version
|
|
695
|
+
*/
|
|
696
|
+
version(): number;
|
|
697
|
+
/**
|
|
698
|
+
* Get the Zcash version group ID (returns None for non-Zcash PSBTs)
|
|
699
|
+
*/
|
|
700
|
+
version_group_id(): number | undefined;
|
|
697
701
|
}
|
|
698
702
|
|
|
699
703
|
export class FixedScriptWalletNamespace {
|
|
700
|
-
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
717
|
-
|
|
718
|
-
|
|
719
|
-
|
|
720
|
-
|
|
721
|
-
|
|
722
|
-
|
|
723
|
-
|
|
724
|
-
|
|
725
|
-
|
|
726
|
-
|
|
727
|
-
|
|
728
|
-
|
|
729
|
-
|
|
730
|
-
|
|
731
|
-
|
|
732
|
-
|
|
733
|
-
|
|
734
|
-
|
|
735
|
-
|
|
736
|
-
|
|
737
|
-
|
|
738
|
-
|
|
739
|
-
|
|
740
|
-
|
|
741
|
-
|
|
704
|
+
private constructor();
|
|
705
|
+
free(): void;
|
|
706
|
+
[Symbol.dispose](): void;
|
|
707
|
+
static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
|
|
708
|
+
static address_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string, address_format?: string | null): string;
|
|
709
|
+
/**
|
|
710
|
+
* Get all chain code metadata for building TypeScript lookup tables
|
|
711
|
+
*
|
|
712
|
+
* Returns an array of [chainCode, scriptType, scope] tuples where:
|
|
713
|
+
* - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
|
|
714
|
+
* - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
|
|
715
|
+
* - scope: string ("external" or "internal")
|
|
716
|
+
*/
|
|
717
|
+
static chain_code_table(): any;
|
|
718
|
+
/**
|
|
719
|
+
* Create an OP_RETURN output script with optional data
|
|
720
|
+
*
|
|
721
|
+
* # Arguments
|
|
722
|
+
* * `data` - Optional data bytes to include in the OP_RETURN script
|
|
723
|
+
*
|
|
724
|
+
* # Returns
|
|
725
|
+
* The OP_RETURN script as bytes
|
|
726
|
+
*/
|
|
727
|
+
static create_op_return_script(data?: Uint8Array | null): Uint8Array;
|
|
728
|
+
static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
|
|
729
|
+
static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
|
|
730
|
+
/**
|
|
731
|
+
* Check if a network supports a given fixed-script wallet script type
|
|
732
|
+
*
|
|
733
|
+
* # Arguments
|
|
734
|
+
* * `coin` - Coin name (e.g., "btc", "ltc", "doge")
|
|
735
|
+
* * `script_type` - Script type name: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
|
|
736
|
+
*
|
|
737
|
+
* # Returns
|
|
738
|
+
* `true` if the network supports the script type, `false` otherwise
|
|
739
|
+
*
|
|
740
|
+
* # Examples
|
|
741
|
+
* - Bitcoin supports all script types (p2sh, p2shP2wsh, p2wsh, p2tr, p2trMusig2)
|
|
742
|
+
* - Litecoin supports segwit but not taproot (p2sh, p2shP2wsh, p2wsh)
|
|
743
|
+
* - Dogecoin only supports legacy scripts (p2sh)
|
|
744
|
+
*/
|
|
745
|
+
static supports_script_type(coin: string, script_type: string): boolean;
|
|
742
746
|
}
|
|
743
747
|
|
|
748
|
+
/**
|
|
749
|
+
* Namespace for inscription-related functions
|
|
750
|
+
*/
|
|
744
751
|
export class InscriptionsNamespace {
|
|
745
|
-
|
|
746
|
-
|
|
747
|
-
|
|
748
|
-
|
|
749
|
-
|
|
750
|
-
|
|
751
|
-
|
|
752
|
-
|
|
753
|
-
|
|
754
|
-
|
|
755
|
-
|
|
756
|
-
|
|
757
|
-
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
|
|
761
|
-
|
|
762
|
-
|
|
763
|
-
|
|
764
|
-
|
|
765
|
-
|
|
766
|
-
|
|
767
|
-
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
752
|
+
private constructor();
|
|
753
|
+
free(): void;
|
|
754
|
+
[Symbol.dispose](): void;
|
|
755
|
+
/**
|
|
756
|
+
* Create inscription reveal data including the commit output script and tap leaf script
|
|
757
|
+
*
|
|
758
|
+
* # Arguments
|
|
759
|
+
* * `x_only_pubkey` - The x-only public key (32 bytes)
|
|
760
|
+
* * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
|
|
761
|
+
* * `inscription_data` - The inscription data bytes
|
|
762
|
+
*
|
|
763
|
+
* # Returns
|
|
764
|
+
* An object containing:
|
|
765
|
+
* - `output_script`: The commit output script (P2TR, network-agnostic)
|
|
766
|
+
* - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
|
|
767
|
+
* - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
|
|
768
|
+
*/
|
|
769
|
+
static create_inscription_reveal_data(x_only_pubkey: Uint8Array, content_type: string, inscription_data: Uint8Array): any;
|
|
770
|
+
/**
|
|
771
|
+
* Sign a reveal transaction
|
|
772
|
+
*
|
|
773
|
+
* # Arguments
|
|
774
|
+
* * `private_key` - The private key (32 bytes)
|
|
775
|
+
* * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
|
|
776
|
+
* * `commit_tx` - The commit transaction
|
|
777
|
+
* * `commit_output_script` - The commit output script (P2TR)
|
|
778
|
+
* * `recipient_output_script` - Where to send the inscription (output script)
|
|
779
|
+
* * `output_value_sats` - Value in satoshis for the inscription output
|
|
780
|
+
*
|
|
781
|
+
* # Returns
|
|
782
|
+
* The signed PSBT as bytes
|
|
783
|
+
*/
|
|
784
|
+
static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
|
|
785
|
+
}
|
|
786
|
+
|
|
787
|
+
export class MessageNamespace {
|
|
788
|
+
private constructor();
|
|
789
|
+
free(): void;
|
|
790
|
+
[Symbol.dispose](): void;
|
|
791
|
+
/**
|
|
792
|
+
* Sign a message using Bitcoin message signing (BIP-137)
|
|
793
|
+
*
|
|
794
|
+
* Returns 65-byte signature (1-byte header + 64-byte signature).
|
|
795
|
+
* The key must have a private key (cannot sign with public key only).
|
|
796
|
+
*/
|
|
797
|
+
static sign_message(key: WasmECPair, message_str: string): Uint8Array;
|
|
798
|
+
/**
|
|
799
|
+
* Verify a Bitcoin message signature (BIP-137)
|
|
800
|
+
*
|
|
801
|
+
* Signature must be 65 bytes (1-byte header + 64-byte signature).
|
|
802
|
+
* Returns true if the signature is valid for this key.
|
|
803
|
+
*/
|
|
804
|
+
static verify_message(key: WasmECPair, message_str: string, signature: Uint8Array): boolean;
|
|
778
805
|
}
|
|
779
806
|
|
|
780
807
|
export class UtxolibCompatNamespace {
|
|
781
|
-
|
|
782
|
-
|
|
783
|
-
|
|
784
|
-
|
|
785
|
-
|
|
786
|
-
|
|
787
|
-
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
792
|
-
|
|
793
|
-
|
|
794
|
-
|
|
795
|
-
|
|
796
|
-
|
|
797
|
-
|
|
798
|
-
|
|
799
|
-
|
|
800
|
-
|
|
801
|
-
|
|
808
|
+
private constructor();
|
|
809
|
+
free(): void;
|
|
810
|
+
[Symbol.dispose](): void;
|
|
811
|
+
/**
|
|
812
|
+
* Convert output script to address string
|
|
813
|
+
*
|
|
814
|
+
* # Arguments
|
|
815
|
+
* * `script` - The output script as a byte array
|
|
816
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
817
|
+
* * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
|
|
818
|
+
*/
|
|
819
|
+
static from_output_script(script: Uint8Array, network: any, format?: string | null): string;
|
|
820
|
+
/**
|
|
821
|
+
* Convert address string to output script
|
|
822
|
+
*
|
|
823
|
+
* # Arguments
|
|
824
|
+
* * `address` - The address string
|
|
825
|
+
* * `network` - The UtxolibNetwork object from JavaScript
|
|
826
|
+
* * `format` - Optional address format (currently unused for decoding as all formats are accepted)
|
|
827
|
+
*/
|
|
828
|
+
static to_output_script(address: string, network: any, format?: string | null): Uint8Array;
|
|
802
829
|
}
|
|
803
830
|
|
|
831
|
+
/**
|
|
832
|
+
* WASM wrapper for BIP32 extended keys (Xpub/Xpriv)
|
|
833
|
+
* Implements the BIP32Interface TypeScript interface
|
|
834
|
+
*/
|
|
804
835
|
export class WasmBIP32 {
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
|
|
820
|
-
|
|
821
|
-
|
|
822
|
-
|
|
823
|
-
|
|
824
|
-
|
|
825
|
-
|
|
826
|
-
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
848
|
-
|
|
849
|
-
|
|
850
|
-
|
|
851
|
-
|
|
852
|
-
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
856
|
-
|
|
857
|
-
|
|
858
|
-
|
|
859
|
-
|
|
860
|
-
|
|
861
|
-
|
|
862
|
-
|
|
863
|
-
|
|
864
|
-
|
|
865
|
-
|
|
866
|
-
|
|
867
|
-
|
|
868
|
-
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
|
|
874
|
-
|
|
875
|
-
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
|
|
879
|
-
|
|
880
|
-
|
|
881
|
-
|
|
882
|
-
|
|
883
|
-
|
|
884
|
-
|
|
885
|
-
|
|
886
|
-
|
|
887
|
-
|
|
888
|
-
|
|
889
|
-
|
|
890
|
-
|
|
891
|
-
|
|
892
|
-
|
|
893
|
-
|
|
894
|
-
|
|
895
|
-
|
|
896
|
-
|
|
897
|
-
|
|
898
|
-
|
|
899
|
-
|
|
836
|
+
private constructor();
|
|
837
|
+
free(): void;
|
|
838
|
+
[Symbol.dispose](): void;
|
|
839
|
+
/**
|
|
840
|
+
* Derive a normal (non-hardened) child key
|
|
841
|
+
*/
|
|
842
|
+
derive(index: number): WasmBIP32;
|
|
843
|
+
/**
|
|
844
|
+
* Derive a hardened child key (only works for private keys)
|
|
845
|
+
*/
|
|
846
|
+
derive_hardened(index: number): WasmBIP32;
|
|
847
|
+
/**
|
|
848
|
+
* Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
|
|
849
|
+
*/
|
|
850
|
+
derive_path(path: string): WasmBIP32;
|
|
851
|
+
/**
|
|
852
|
+
* Check equality with another WasmBIP32 key.
|
|
853
|
+
* Two keys are equal if they have the same type (public/private) and identical
|
|
854
|
+
* BIP32 metadata (depth, parent fingerprint, child index, chain code, key data).
|
|
855
|
+
*/
|
|
856
|
+
equals(other: WasmBIP32): boolean;
|
|
857
|
+
/**
|
|
858
|
+
* Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
|
|
859
|
+
*/
|
|
860
|
+
static from_base58(base58_str: string): WasmBIP32;
|
|
861
|
+
/**
|
|
862
|
+
* Create a BIP32 key from a BIP32Interface JavaScript object properties
|
|
863
|
+
* Expects an object with: network.bip32.public, depth, parentFingerprint,
|
|
864
|
+
* index, chainCode, and publicKey properties
|
|
865
|
+
*/
|
|
866
|
+
static from_bip32_interface(bip32_key: any): WasmBIP32;
|
|
867
|
+
/**
|
|
868
|
+
* Create a BIP32 key from BIP32 properties
|
|
869
|
+
* Extracts properties from a JavaScript object and constructs an xpub or xprv
|
|
870
|
+
*/
|
|
871
|
+
static from_bip32_properties(bip32_key: any): WasmBIP32;
|
|
872
|
+
/**
|
|
873
|
+
* Create a BIP32 master key from a seed
|
|
874
|
+
*/
|
|
875
|
+
static from_seed(seed: Uint8Array, network?: string | null): WasmBIP32;
|
|
876
|
+
/**
|
|
877
|
+
* Create a BIP32 master key from a string by hashing it with SHA256.
|
|
878
|
+
* This is useful for deterministic test key generation.
|
|
879
|
+
*/
|
|
880
|
+
static from_seed_sha256(seed_string: string, network?: string | null): WasmBIP32;
|
|
881
|
+
/**
|
|
882
|
+
* Create a BIP32 key from an xprv string (base58-encoded)
|
|
883
|
+
*/
|
|
884
|
+
static from_xprv(xprv_str: string): WasmBIP32;
|
|
885
|
+
/**
|
|
886
|
+
* Create a BIP32 key from an xpub string (base58-encoded)
|
|
887
|
+
*/
|
|
888
|
+
static from_xpub(xpub_str: string): WasmBIP32;
|
|
889
|
+
/**
|
|
890
|
+
* Check if this is a neutered (public) key
|
|
891
|
+
*/
|
|
892
|
+
is_neutered(): boolean;
|
|
893
|
+
/**
|
|
894
|
+
* Get the neutered (public) version of this key
|
|
895
|
+
*/
|
|
896
|
+
neutered(): WasmBIP32;
|
|
897
|
+
/**
|
|
898
|
+
* Serialize to base58 string
|
|
899
|
+
*/
|
|
900
|
+
to_base58(): string;
|
|
901
|
+
/**
|
|
902
|
+
* Get the WIF encoding of the private key
|
|
903
|
+
*/
|
|
904
|
+
to_wif(): string;
|
|
905
|
+
/**
|
|
906
|
+
* Get the chain code as a Uint8Array
|
|
907
|
+
*/
|
|
908
|
+
readonly chain_code: Uint8Array;
|
|
909
|
+
/**
|
|
910
|
+
* Get the depth
|
|
911
|
+
*/
|
|
912
|
+
readonly depth: number;
|
|
913
|
+
/**
|
|
914
|
+
* Get the fingerprint as a Uint8Array
|
|
915
|
+
*/
|
|
916
|
+
readonly fingerprint: Uint8Array;
|
|
917
|
+
/**
|
|
918
|
+
* Get the identifier as a Uint8Array
|
|
919
|
+
*/
|
|
920
|
+
readonly identifier: Uint8Array;
|
|
921
|
+
/**
|
|
922
|
+
* Get the child index
|
|
923
|
+
*/
|
|
924
|
+
readonly index: number;
|
|
925
|
+
/**
|
|
926
|
+
* Get the parent fingerprint
|
|
927
|
+
*/
|
|
928
|
+
readonly parent_fingerprint: number;
|
|
929
|
+
/**
|
|
930
|
+
* Get the private key as a Uint8Array (if available)
|
|
931
|
+
*/
|
|
932
|
+
readonly private_key: Uint8Array | undefined;
|
|
933
|
+
/**
|
|
934
|
+
* Get the public key as a Uint8Array
|
|
935
|
+
*/
|
|
936
|
+
readonly public_key: Uint8Array;
|
|
900
937
|
}
|
|
901
938
|
|
|
939
|
+
/**
|
|
940
|
+
* Dash transaction wrapper that supports Dash special transactions (EVO) by preserving extra payload.
|
|
941
|
+
*/
|
|
902
942
|
export class WasmDashTransaction {
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
|
|
908
|
-
|
|
909
|
-
|
|
910
|
-
|
|
911
|
-
|
|
912
|
-
|
|
913
|
-
|
|
914
|
-
|
|
915
|
-
|
|
916
|
-
|
|
917
|
-
|
|
918
|
-
|
|
919
|
-
|
|
920
|
-
|
|
921
|
-
|
|
922
|
-
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
943
|
+
private constructor();
|
|
944
|
+
free(): void;
|
|
945
|
+
[Symbol.dispose](): void;
|
|
946
|
+
/**
|
|
947
|
+
* Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
|
|
948
|
+
*/
|
|
949
|
+
static from_bytes(bytes: Uint8Array): WasmDashTransaction;
|
|
950
|
+
/**
|
|
951
|
+
* Get the transaction ID (txid)
|
|
952
|
+
*
|
|
953
|
+
* The txid is the double SHA256 of the full Dash transaction bytes,
|
|
954
|
+
* displayed in reverse byte order (big-endian) as is standard.
|
|
955
|
+
*
|
|
956
|
+
* # Returns
|
|
957
|
+
* The transaction ID as a hex string
|
|
958
|
+
*
|
|
959
|
+
* # Errors
|
|
960
|
+
* Returns an error if the transaction cannot be serialized
|
|
961
|
+
*/
|
|
962
|
+
get_txid(): string;
|
|
963
|
+
/**
|
|
964
|
+
* Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
|
|
965
|
+
*/
|
|
966
|
+
to_bytes(): Uint8Array;
|
|
927
967
|
}
|
|
928
968
|
|
|
969
|
+
/**
|
|
970
|
+
* Dimensions for estimating transaction virtual size.
|
|
971
|
+
*
|
|
972
|
+
* Tracks weight internally with min/max bounds to handle ECDSA signature variance.
|
|
973
|
+
* Schnorr signatures have no variance (always 64 bytes).
|
|
974
|
+
*/
|
|
929
975
|
export class WasmDimensions {
|
|
930
|
-
|
|
931
|
-
|
|
932
|
-
|
|
933
|
-
|
|
934
|
-
|
|
935
|
-
|
|
936
|
-
|
|
937
|
-
|
|
938
|
-
|
|
939
|
-
|
|
940
|
-
|
|
941
|
-
|
|
942
|
-
|
|
943
|
-
|
|
944
|
-
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
|
|
950
|
-
|
|
951
|
-
|
|
952
|
-
|
|
953
|
-
|
|
954
|
-
|
|
955
|
-
|
|
956
|
-
|
|
957
|
-
|
|
958
|
-
|
|
959
|
-
|
|
960
|
-
|
|
961
|
-
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
|
|
967
|
-
|
|
968
|
-
|
|
969
|
-
|
|
970
|
-
|
|
971
|
-
|
|
972
|
-
|
|
973
|
-
|
|
974
|
-
|
|
975
|
-
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
|
|
980
|
-
|
|
981
|
-
|
|
982
|
-
|
|
983
|
-
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
|
|
993
|
-
|
|
994
|
-
|
|
995
|
-
|
|
996
|
-
|
|
997
|
-
|
|
998
|
-
|
|
999
|
-
|
|
1000
|
-
|
|
1001
|
-
|
|
1002
|
-
|
|
1003
|
-
|
|
1004
|
-
|
|
1005
|
-
|
|
1006
|
-
|
|
1007
|
-
|
|
1008
|
-
|
|
1009
|
-
|
|
1010
|
-
|
|
1011
|
-
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1018
|
-
|
|
1019
|
-
|
|
1020
|
-
|
|
1021
|
-
|
|
1022
|
-
|
|
976
|
+
private constructor();
|
|
977
|
+
free(): void;
|
|
978
|
+
[Symbol.dispose](): void;
|
|
979
|
+
/**
|
|
980
|
+
* Create empty dimensions (zero weight)
|
|
981
|
+
*/
|
|
982
|
+
static empty(): WasmDimensions;
|
|
983
|
+
/**
|
|
984
|
+
* Create dimensions for a single input from chain code
|
|
985
|
+
*
|
|
986
|
+
* # Arguments
|
|
987
|
+
* * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
|
|
988
|
+
* * `signer` - Optional signer key ("user", "backup", "bitgo")
|
|
989
|
+
* * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
|
|
990
|
+
* * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
|
|
991
|
+
*/
|
|
992
|
+
static from_input(chain: number, signer?: string | null, cosigner?: string | null, compat?: boolean | null): WasmDimensions;
|
|
993
|
+
/**
|
|
994
|
+
* Create dimensions for a single input from script type string
|
|
995
|
+
*
|
|
996
|
+
* # Arguments
|
|
997
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
|
|
998
|
+
* "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
|
|
999
|
+
* * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
|
|
1000
|
+
*/
|
|
1001
|
+
static from_input_script_type(script_type: string, compat?: boolean | null): WasmDimensions;
|
|
1002
|
+
/**
|
|
1003
|
+
* Create dimensions for a single output from script length
|
|
1004
|
+
*/
|
|
1005
|
+
static from_output_script_length(length: number): WasmDimensions;
|
|
1006
|
+
/**
|
|
1007
|
+
* Create dimensions for a single output from script type string
|
|
1008
|
+
*
|
|
1009
|
+
* # Arguments
|
|
1010
|
+
* * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
|
|
1011
|
+
*/
|
|
1012
|
+
static from_output_script_type(script_type: string): WasmDimensions;
|
|
1013
|
+
/**
|
|
1014
|
+
* Create dimensions from a BitGoPsbt
|
|
1015
|
+
*
|
|
1016
|
+
* Parses PSBT inputs and outputs to compute weight bounds without
|
|
1017
|
+
* requiring wallet keys. Input types are detected from BIP32 derivation
|
|
1018
|
+
* paths stored in the PSBT.
|
|
1019
|
+
*/
|
|
1020
|
+
static from_psbt(psbt: BitGoPsbt): WasmDimensions;
|
|
1021
|
+
/**
|
|
1022
|
+
* Get input virtual size (min or max)
|
|
1023
|
+
*
|
|
1024
|
+
* # Arguments
|
|
1025
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1026
|
+
*/
|
|
1027
|
+
get_input_vsize(size?: string | null): number;
|
|
1028
|
+
/**
|
|
1029
|
+
* Get input weight only (min or max)
|
|
1030
|
+
*
|
|
1031
|
+
* # Arguments
|
|
1032
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1033
|
+
*/
|
|
1034
|
+
get_input_weight(size?: string | null): number;
|
|
1035
|
+
/**
|
|
1036
|
+
* Get output virtual size
|
|
1037
|
+
*/
|
|
1038
|
+
get_output_vsize(): number;
|
|
1039
|
+
/**
|
|
1040
|
+
* Get output weight
|
|
1041
|
+
*/
|
|
1042
|
+
get_output_weight(): number;
|
|
1043
|
+
/**
|
|
1044
|
+
* Get virtual size (min or max)
|
|
1045
|
+
*
|
|
1046
|
+
* # Arguments
|
|
1047
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1048
|
+
*/
|
|
1049
|
+
get_vsize(size?: string | null): number;
|
|
1050
|
+
/**
|
|
1051
|
+
* Get total weight (min or max)
|
|
1052
|
+
*
|
|
1053
|
+
* # Arguments
|
|
1054
|
+
* * `size` - "min" or "max", defaults to "max"
|
|
1055
|
+
*/
|
|
1056
|
+
get_weight(size?: string | null): number;
|
|
1057
|
+
/**
|
|
1058
|
+
* Whether any inputs are segwit (affects overhead calculation)
|
|
1059
|
+
*/
|
|
1060
|
+
has_segwit(): boolean;
|
|
1061
|
+
/**
|
|
1062
|
+
* Combine with another Dimensions instance
|
|
1063
|
+
*/
|
|
1064
|
+
plus(other: WasmDimensions): WasmDimensions;
|
|
1065
|
+
/**
|
|
1066
|
+
* Multiply dimensions by a scalar
|
|
1067
|
+
*/
|
|
1068
|
+
times(n: number): WasmDimensions;
|
|
1023
1069
|
}
|
|
1024
1070
|
|
|
1071
|
+
/**
|
|
1072
|
+
* WASM wrapper for elliptic curve key pairs (always uses compressed keys)
|
|
1073
|
+
*/
|
|
1025
1074
|
export class WasmECPair {
|
|
1026
|
-
|
|
1027
|
-
|
|
1028
|
-
|
|
1029
|
-
|
|
1030
|
-
|
|
1031
|
-
|
|
1032
|
-
|
|
1033
|
-
|
|
1034
|
-
|
|
1035
|
-
|
|
1036
|
-
|
|
1037
|
-
|
|
1038
|
-
|
|
1039
|
-
|
|
1040
|
-
|
|
1041
|
-
|
|
1042
|
-
|
|
1043
|
-
|
|
1044
|
-
|
|
1045
|
-
|
|
1046
|
-
|
|
1047
|
-
|
|
1048
|
-
|
|
1049
|
-
|
|
1050
|
-
|
|
1051
|
-
|
|
1052
|
-
|
|
1053
|
-
|
|
1054
|
-
|
|
1055
|
-
|
|
1056
|
-
|
|
1057
|
-
|
|
1058
|
-
|
|
1059
|
-
|
|
1060
|
-
|
|
1061
|
-
|
|
1062
|
-
|
|
1063
|
-
|
|
1064
|
-
|
|
1065
|
-
|
|
1066
|
-
|
|
1067
|
-
|
|
1068
|
-
|
|
1075
|
+
private constructor();
|
|
1076
|
+
free(): void;
|
|
1077
|
+
[Symbol.dispose](): void;
|
|
1078
|
+
/**
|
|
1079
|
+
* Create an ECPair from a private key (always uses compressed keys)
|
|
1080
|
+
*/
|
|
1081
|
+
static from_private_key(private_key: Uint8Array): WasmECPair;
|
|
1082
|
+
/**
|
|
1083
|
+
* Create an ECPair from a public key (always uses compressed keys)
|
|
1084
|
+
*/
|
|
1085
|
+
static from_public_key(public_key: Uint8Array): WasmECPair;
|
|
1086
|
+
/**
|
|
1087
|
+
* Create an ECPair from a WIF string (auto-detects network)
|
|
1088
|
+
*/
|
|
1089
|
+
static from_wif(wif_string: string): WasmECPair;
|
|
1090
|
+
/**
|
|
1091
|
+
* Create an ECPair from a mainnet WIF string
|
|
1092
|
+
*/
|
|
1093
|
+
static from_wif_mainnet(wif_string: string): WasmECPair;
|
|
1094
|
+
/**
|
|
1095
|
+
* Create an ECPair from a testnet WIF string
|
|
1096
|
+
*/
|
|
1097
|
+
static from_wif_testnet(wif_string: string): WasmECPair;
|
|
1098
|
+
/**
|
|
1099
|
+
* Convert to WIF string (mainnet)
|
|
1100
|
+
*/
|
|
1101
|
+
to_wif(): string;
|
|
1102
|
+
/**
|
|
1103
|
+
* Convert to mainnet WIF string
|
|
1104
|
+
*/
|
|
1105
|
+
to_wif_mainnet(): string;
|
|
1106
|
+
/**
|
|
1107
|
+
* Convert to testnet WIF string
|
|
1108
|
+
*/
|
|
1109
|
+
to_wif_testnet(): string;
|
|
1110
|
+
/**
|
|
1111
|
+
* Get the private key as a Uint8Array (if available)
|
|
1112
|
+
*/
|
|
1113
|
+
readonly private_key: Uint8Array | undefined;
|
|
1114
|
+
/**
|
|
1115
|
+
* Get the compressed public key as a Uint8Array (always 33 bytes)
|
|
1116
|
+
*/
|
|
1117
|
+
readonly public_key: Uint8Array;
|
|
1069
1118
|
}
|
|
1070
1119
|
|
|
1120
|
+
/**
|
|
1121
|
+
* WASM wrapper for ReplayProtection
|
|
1122
|
+
*/
|
|
1071
1123
|
export class WasmReplayProtection {
|
|
1072
|
-
|
|
1073
|
-
|
|
1074
|
-
|
|
1075
|
-
|
|
1076
|
-
|
|
1077
|
-
|
|
1078
|
-
|
|
1079
|
-
|
|
1080
|
-
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1124
|
+
private constructor();
|
|
1125
|
+
free(): void;
|
|
1126
|
+
[Symbol.dispose](): void;
|
|
1127
|
+
/**
|
|
1128
|
+
* Create from addresses (requires network for decoding)
|
|
1129
|
+
*/
|
|
1130
|
+
static from_addresses(addresses: any[], network: string): WasmReplayProtection;
|
|
1131
|
+
/**
|
|
1132
|
+
* Create from output scripts directly
|
|
1133
|
+
*/
|
|
1134
|
+
static from_output_scripts(output_scripts: Uint8Array[]): WasmReplayProtection;
|
|
1135
|
+
/**
|
|
1136
|
+
* Create from public keys (derives P2SH-P2PK output scripts)
|
|
1137
|
+
*/
|
|
1138
|
+
static from_public_keys(public_keys: Uint8Array[]): WasmReplayProtection;
|
|
1087
1139
|
}
|
|
1088
1140
|
|
|
1141
|
+
/**
|
|
1142
|
+
* WASM wrapper for RootWalletKeys
|
|
1143
|
+
* Represents a set of three extended public keys with their derivation prefixes
|
|
1144
|
+
*/
|
|
1089
1145
|
export class WasmRootWalletKeys {
|
|
1090
|
-
|
|
1091
|
-
|
|
1092
|
-
|
|
1093
|
-
|
|
1094
|
-
|
|
1095
|
-
|
|
1096
|
-
|
|
1097
|
-
|
|
1098
|
-
|
|
1099
|
-
|
|
1100
|
-
|
|
1101
|
-
|
|
1102
|
-
|
|
1103
|
-
|
|
1104
|
-
|
|
1105
|
-
|
|
1106
|
-
|
|
1107
|
-
|
|
1108
|
-
|
|
1109
|
-
|
|
1110
|
-
|
|
1111
|
-
|
|
1112
|
-
|
|
1113
|
-
|
|
1114
|
-
|
|
1115
|
-
|
|
1116
|
-
|
|
1117
|
-
|
|
1118
|
-
|
|
1119
|
-
|
|
1120
|
-
|
|
1121
|
-
|
|
1122
|
-
|
|
1123
|
-
|
|
1124
|
-
|
|
1125
|
-
|
|
1146
|
+
free(): void;
|
|
1147
|
+
[Symbol.dispose](): void;
|
|
1148
|
+
/**
|
|
1149
|
+
* Get the backup key (second xpub)
|
|
1150
|
+
*/
|
|
1151
|
+
backup_key(): WasmBIP32;
|
|
1152
|
+
/**
|
|
1153
|
+
* Get the bitgo key (third xpub)
|
|
1154
|
+
*/
|
|
1155
|
+
bitgo_key(): WasmBIP32;
|
|
1156
|
+
/**
|
|
1157
|
+
* Create a RootWalletKeys from three BIP32 keys
|
|
1158
|
+
* Uses default derivation prefix of m/0/0 for all three keys
|
|
1159
|
+
*
|
|
1160
|
+
* # Arguments
|
|
1161
|
+
* - `user`: User key (first xpub)
|
|
1162
|
+
* - `backup`: Backup key (second xpub)
|
|
1163
|
+
* - `bitgo`: BitGo key (third xpub)
|
|
1164
|
+
*/
|
|
1165
|
+
constructor(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32);
|
|
1166
|
+
/**
|
|
1167
|
+
* Get the user key (first xpub)
|
|
1168
|
+
*/
|
|
1169
|
+
user_key(): WasmBIP32;
|
|
1170
|
+
/**
|
|
1171
|
+
* Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
|
|
1172
|
+
*
|
|
1173
|
+
* # Arguments
|
|
1174
|
+
* - `user`: User key (first xpub)
|
|
1175
|
+
* - `backup`: Backup key (second xpub)
|
|
1176
|
+
* - `bitgo`: BitGo key (third xpub)
|
|
1177
|
+
* - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
|
|
1178
|
+
* - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
|
|
1179
|
+
* - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
|
|
1180
|
+
*/
|
|
1181
|
+
static with_derivation_prefixes(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32, user_derivation: string, backup_derivation: string, bitgo_derivation: string): WasmRootWalletKeys;
|
|
1126
1182
|
}
|
|
1127
1183
|
|
|
1184
|
+
/**
|
|
1185
|
+
* A Bitcoin-like transaction (for all networks except Zcash)
|
|
1186
|
+
*
|
|
1187
|
+
* This class provides basic transaction parsing and serialization for testing
|
|
1188
|
+
* compatibility with third-party transaction fixtures.
|
|
1189
|
+
*/
|
|
1128
1190
|
export class WasmTransaction {
|
|
1129
|
-
|
|
1130
|
-
|
|
1131
|
-
|
|
1132
|
-
|
|
1133
|
-
|
|
1134
|
-
|
|
1135
|
-
|
|
1136
|
-
|
|
1137
|
-
|
|
1138
|
-
|
|
1139
|
-
|
|
1140
|
-
|
|
1141
|
-
|
|
1142
|
-
|
|
1143
|
-
|
|
1144
|
-
|
|
1145
|
-
|
|
1146
|
-
|
|
1147
|
-
|
|
1148
|
-
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
|
|
1155
|
-
|
|
1156
|
-
|
|
1157
|
-
|
|
1158
|
-
|
|
1159
|
-
|
|
1160
|
-
|
|
1161
|
-
|
|
1162
|
-
|
|
1163
|
-
|
|
1164
|
-
|
|
1165
|
-
|
|
1166
|
-
|
|
1167
|
-
|
|
1168
|
-
|
|
1169
|
-
|
|
1170
|
-
|
|
1171
|
-
|
|
1172
|
-
|
|
1191
|
+
private constructor();
|
|
1192
|
+
free(): void;
|
|
1193
|
+
[Symbol.dispose](): void;
|
|
1194
|
+
/**
|
|
1195
|
+
* Deserialize a transaction from bytes
|
|
1196
|
+
*
|
|
1197
|
+
* # Arguments
|
|
1198
|
+
* * `bytes` - The serialized transaction bytes
|
|
1199
|
+
*
|
|
1200
|
+
* # Returns
|
|
1201
|
+
* A WasmTransaction instance
|
|
1202
|
+
*
|
|
1203
|
+
* # Errors
|
|
1204
|
+
* Returns an error if the bytes cannot be parsed as a valid transaction
|
|
1205
|
+
*/
|
|
1206
|
+
static from_bytes(bytes: Uint8Array): WasmTransaction;
|
|
1207
|
+
/**
|
|
1208
|
+
* Get the transaction ID (txid)
|
|
1209
|
+
*
|
|
1210
|
+
* The txid is the double SHA256 of the transaction bytes (excluding witness
|
|
1211
|
+
* data for segwit transactions), displayed in reverse byte order (big-endian)
|
|
1212
|
+
* as is standard for Bitcoin.
|
|
1213
|
+
*
|
|
1214
|
+
* # Returns
|
|
1215
|
+
* The transaction ID as a hex string
|
|
1216
|
+
*/
|
|
1217
|
+
get_txid(): string;
|
|
1218
|
+
/**
|
|
1219
|
+
* Get the virtual size of the transaction
|
|
1220
|
+
*
|
|
1221
|
+
* Virtual size is calculated as ceil(weight / 4), where weight accounts
|
|
1222
|
+
* for the segwit discount on witness data.
|
|
1223
|
+
*
|
|
1224
|
+
* # Returns
|
|
1225
|
+
* The virtual size in virtual bytes (vbytes)
|
|
1226
|
+
*/
|
|
1227
|
+
get_vsize(): number;
|
|
1228
|
+
/**
|
|
1229
|
+
* Serialize the transaction to bytes
|
|
1230
|
+
*
|
|
1231
|
+
* # Returns
|
|
1232
|
+
* The serialized transaction bytes
|
|
1233
|
+
*/
|
|
1234
|
+
to_bytes(): Uint8Array;
|
|
1173
1235
|
}
|
|
1174
1236
|
|
|
1237
|
+
/**
|
|
1238
|
+
* A Zcash transaction with network-specific fields
|
|
1239
|
+
*
|
|
1240
|
+
* This class provides basic transaction parsing and serialization for Zcash
|
|
1241
|
+
* transactions, which use the Overwinter transaction format.
|
|
1242
|
+
*/
|
|
1175
1243
|
export class WasmZcashTransaction {
|
|
1176
|
-
|
|
1177
|
-
|
|
1178
|
-
|
|
1179
|
-
|
|
1180
|
-
|
|
1181
|
-
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1185
|
-
|
|
1186
|
-
|
|
1187
|
-
|
|
1188
|
-
|
|
1189
|
-
|
|
1190
|
-
|
|
1191
|
-
|
|
1192
|
-
|
|
1193
|
-
|
|
1194
|
-
|
|
1195
|
-
|
|
1196
|
-
|
|
1197
|
-
|
|
1198
|
-
|
|
1199
|
-
|
|
1200
|
-
|
|
1201
|
-
|
|
1202
|
-
|
|
1203
|
-
|
|
1204
|
-
|
|
1205
|
-
|
|
1206
|
-
|
|
1207
|
-
|
|
1208
|
-
|
|
1209
|
-
|
|
1210
|
-
|
|
1211
|
-
|
|
1244
|
+
private constructor();
|
|
1245
|
+
free(): void;
|
|
1246
|
+
[Symbol.dispose](): void;
|
|
1247
|
+
/**
|
|
1248
|
+
* Deserialize a Zcash transaction from bytes
|
|
1249
|
+
*
|
|
1250
|
+
* # Arguments
|
|
1251
|
+
* * `bytes` - The serialized transaction bytes
|
|
1252
|
+
*
|
|
1253
|
+
* # Returns
|
|
1254
|
+
* A WasmZcashTransaction instance
|
|
1255
|
+
*
|
|
1256
|
+
* # Errors
|
|
1257
|
+
* Returns an error if the bytes cannot be parsed as a valid Zcash transaction
|
|
1258
|
+
*/
|
|
1259
|
+
static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
|
|
1260
|
+
/**
|
|
1261
|
+
* Get the transaction ID (txid)
|
|
1262
|
+
*
|
|
1263
|
+
* The txid is the double SHA256 of the full Zcash transaction bytes,
|
|
1264
|
+
* displayed in reverse byte order (big-endian) as is standard.
|
|
1265
|
+
*
|
|
1266
|
+
* # Returns
|
|
1267
|
+
* The transaction ID as a hex string
|
|
1268
|
+
*
|
|
1269
|
+
* # Errors
|
|
1270
|
+
* Returns an error if the transaction cannot be serialized
|
|
1271
|
+
*/
|
|
1272
|
+
get_txid(): string;
|
|
1273
|
+
/**
|
|
1274
|
+
* Serialize the transaction to bytes
|
|
1275
|
+
*
|
|
1276
|
+
* # Returns
|
|
1277
|
+
* The serialized transaction bytes
|
|
1278
|
+
*/
|
|
1279
|
+
to_bytes(): Uint8Array;
|
|
1212
1280
|
}
|
|
1213
1281
|
|
|
1214
1282
|
export class WrapDescriptor {
|
|
1215
|
-
|
|
1216
|
-
|
|
1217
|
-
|
|
1218
|
-
|
|
1219
|
-
|
|
1220
|
-
|
|
1221
|
-
|
|
1222
|
-
|
|
1223
|
-
|
|
1224
|
-
|
|
1225
|
-
|
|
1226
|
-
|
|
1283
|
+
private constructor();
|
|
1284
|
+
free(): void;
|
|
1285
|
+
[Symbol.dispose](): void;
|
|
1286
|
+
atDerivationIndex(index: number): WrapDescriptor;
|
|
1287
|
+
descType(): any;
|
|
1288
|
+
encode(): Uint8Array;
|
|
1289
|
+
hasWildcard(): boolean;
|
|
1290
|
+
maxWeightToSatisfy(): number;
|
|
1291
|
+
node(): any;
|
|
1292
|
+
scriptPubkey(): Uint8Array;
|
|
1293
|
+
toAsmString(): string;
|
|
1294
|
+
toString(): string;
|
|
1227
1295
|
}
|
|
1228
1296
|
|
|
1229
1297
|
export class WrapMiniscript {
|
|
1230
|
-
|
|
1231
|
-
|
|
1232
|
-
|
|
1233
|
-
|
|
1234
|
-
|
|
1235
|
-
|
|
1236
|
-
|
|
1298
|
+
private constructor();
|
|
1299
|
+
free(): void;
|
|
1300
|
+
[Symbol.dispose](): void;
|
|
1301
|
+
encode(): Uint8Array;
|
|
1302
|
+
node(): any;
|
|
1303
|
+
toAsmString(): string;
|
|
1304
|
+
toString(): string;
|
|
1237
1305
|
}
|
|
1238
1306
|
|
|
1239
1307
|
export class WrapPsbt {
|
|
1240
|
-
|
|
1241
|
-
|
|
1242
|
-
|
|
1243
|
-
|
|
1244
|
-
|
|
1245
|
-
|
|
1246
|
-
|
|
1247
|
-
|
|
1248
|
-
|
|
1249
|
-
|
|
1250
|
-
|
|
1251
|
-
|
|
1252
|
-
|
|
1253
|
-
|
|
1254
|
-
|
|
1255
|
-
|
|
1256
|
-
|
|
1257
|
-
|
|
1258
|
-
|
|
1259
|
-
|
|
1260
|
-
|
|
1261
|
-
|
|
1262
|
-
|
|
1263
|
-
|
|
1264
|
-
|
|
1265
|
-
|
|
1266
|
-
|
|
1267
|
-
|
|
1268
|
-
|
|
1269
|
-
|
|
1270
|
-
|
|
1271
|
-
|
|
1272
|
-
|
|
1273
|
-
|
|
1274
|
-
|
|
1275
|
-
|
|
1276
|
-
|
|
1277
|
-
|
|
1278
|
-
|
|
1279
|
-
|
|
1280
|
-
|
|
1281
|
-
|
|
1282
|
-
|
|
1283
|
-
|
|
1284
|
-
|
|
1285
|
-
|
|
1286
|
-
|
|
1287
|
-
|
|
1288
|
-
|
|
1289
|
-
|
|
1290
|
-
|
|
1291
|
-
|
|
1292
|
-
|
|
1293
|
-
|
|
1294
|
-
|
|
1295
|
-
|
|
1296
|
-
|
|
1297
|
-
|
|
1298
|
-
|
|
1299
|
-
|
|
1300
|
-
|
|
1301
|
-
|
|
1302
|
-
|
|
1303
|
-
|
|
1304
|
-
|
|
1305
|
-
|
|
1306
|
-
|
|
1307
|
-
|
|
1308
|
-
|
|
1309
|
-
|
|
1310
|
-
|
|
1311
|
-
|
|
1312
|
-
|
|
1313
|
-
|
|
1314
|
-
|
|
1315
|
-
|
|
1316
|
-
|
|
1317
|
-
|
|
1318
|
-
|
|
1319
|
-
|
|
1320
|
-
|
|
1321
|
-
|
|
1322
|
-
|
|
1323
|
-
|
|
1324
|
-
|
|
1325
|
-
|
|
1326
|
-
|
|
1327
|
-
|
|
1328
|
-
|
|
1329
|
-
|
|
1330
|
-
|
|
1331
|
-
|
|
1332
|
-
|
|
1333
|
-
|
|
1334
|
-
|
|
1335
|
-
|
|
1336
|
-
|
|
1337
|
-
|
|
1338
|
-
|
|
1339
|
-
|
|
1340
|
-
|
|
1341
|
-
|
|
1342
|
-
|
|
1343
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
1350
|
-
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
|
|
1357
|
-
|
|
1358
|
-
|
|
1359
|
-
|
|
1360
|
-
|
|
1361
|
-
|
|
1362
|
-
|
|
1363
|
-
|
|
1364
|
-
|
|
1365
|
-
|
|
1366
|
-
|
|
1367
|
-
|
|
1368
|
-
|
|
1369
|
-
|
|
1370
|
-
|
|
1371
|
-
|
|
1372
|
-
|
|
1373
|
-
|
|
1374
|
-
|
|
1375
|
-
|
|
1376
|
-
|
|
1377
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
1380
|
-
|
|
1381
|
-
|
|
1382
|
-
|
|
1383
|
-
|
|
1308
|
+
free(): void;
|
|
1309
|
+
[Symbol.dispose](): void;
|
|
1310
|
+
/**
|
|
1311
|
+
* Add an input to the PSBT
|
|
1312
|
+
*
|
|
1313
|
+
* # Arguments
|
|
1314
|
+
* * `txid` - Transaction ID (hex string, 32 bytes reversed)
|
|
1315
|
+
* * `vout` - Output index being spent
|
|
1316
|
+
* * `value` - Value in satoshis of the output being spent
|
|
1317
|
+
* * `script` - The scriptPubKey of the output being spent
|
|
1318
|
+
* * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
|
|
1319
|
+
*
|
|
1320
|
+
* # Returns
|
|
1321
|
+
* The index of the newly added input
|
|
1322
|
+
*/
|
|
1323
|
+
addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
|
|
1324
|
+
/**
|
|
1325
|
+
* Add an output to the PSBT
|
|
1326
|
+
*
|
|
1327
|
+
* # Arguments
|
|
1328
|
+
* * `script` - The output script (scriptPubKey)
|
|
1329
|
+
* * `value` - Value in satoshis
|
|
1330
|
+
*
|
|
1331
|
+
* # Returns
|
|
1332
|
+
* The index of the newly added output
|
|
1333
|
+
*/
|
|
1334
|
+
addOutput(script: Uint8Array, value: bigint): number;
|
|
1335
|
+
clone(): WrapPsbt;
|
|
1336
|
+
static deserialize(psbt: Uint8Array): WrapPsbt;
|
|
1337
|
+
/**
|
|
1338
|
+
* Extract the final transaction from a finalized PSBT
|
|
1339
|
+
*
|
|
1340
|
+
* This method should be called after all inputs have been finalized.
|
|
1341
|
+
* It extracts the fully signed transaction as a WasmTransaction instance.
|
|
1342
|
+
*
|
|
1343
|
+
* # Returns
|
|
1344
|
+
* - `Ok(WasmTransaction)` containing the extracted transaction
|
|
1345
|
+
* - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
|
|
1346
|
+
*/
|
|
1347
|
+
extractTransaction(): WasmTransaction;
|
|
1348
|
+
finalize(): void;
|
|
1349
|
+
/**
|
|
1350
|
+
* Get all PSBT inputs as an array of PsbtInputData
|
|
1351
|
+
*
|
|
1352
|
+
* Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
|
|
1353
|
+
* for each input. This is useful for introspecting the PSBT structure.
|
|
1354
|
+
*/
|
|
1355
|
+
getInputs(): any;
|
|
1356
|
+
/**
|
|
1357
|
+
* Get all PSBT outputs as an array of PsbtOutputData
|
|
1358
|
+
*
|
|
1359
|
+
* Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
|
|
1360
|
+
* for each output. This is useful for introspecting the PSBT structure.
|
|
1361
|
+
*/
|
|
1362
|
+
getOutputs(): any;
|
|
1363
|
+
/**
|
|
1364
|
+
* Get all PSBT outputs with resolved address strings.
|
|
1365
|
+
*
|
|
1366
|
+
* Like `getOutputs()` but each element also includes an `address` field
|
|
1367
|
+
* derived from the output script using the given coin name (e.g. "btc", "tbtc").
|
|
1368
|
+
*/
|
|
1369
|
+
getOutputsWithAddress(coin: string): any;
|
|
1370
|
+
/**
|
|
1371
|
+
* Get partial signatures for an input
|
|
1372
|
+
* Returns array of { pubkey: Uint8Array, signature: Uint8Array }
|
|
1373
|
+
*/
|
|
1374
|
+
getPartialSignatures(input_index: number): any;
|
|
1375
|
+
/**
|
|
1376
|
+
* Get the unsigned transaction bytes
|
|
1377
|
+
*
|
|
1378
|
+
* # Returns
|
|
1379
|
+
* The serialized unsigned transaction
|
|
1380
|
+
*/
|
|
1381
|
+
getUnsignedTx(): Uint8Array;
|
|
1382
|
+
/**
|
|
1383
|
+
* Check if an input has any partial signatures
|
|
1384
|
+
*/
|
|
1385
|
+
hasPartialSignatures(input_index: number): boolean;
|
|
1386
|
+
/**
|
|
1387
|
+
* Get the number of inputs in the PSBT
|
|
1388
|
+
*/
|
|
1389
|
+
inputCount(): number;
|
|
1390
|
+
/**
|
|
1391
|
+
* Get the transaction lock time
|
|
1392
|
+
*/
|
|
1393
|
+
lockTime(): number;
|
|
1394
|
+
/**
|
|
1395
|
+
* Create an empty PSBT
|
|
1396
|
+
*
|
|
1397
|
+
* # Arguments
|
|
1398
|
+
* * `version` - Transaction version (default: 2)
|
|
1399
|
+
* * `lock_time` - Transaction lock time (default: 0)
|
|
1400
|
+
*/
|
|
1401
|
+
constructor(version?: number | null, lock_time?: number | null);
|
|
1402
|
+
/**
|
|
1403
|
+
* Get the number of outputs in the PSBT
|
|
1404
|
+
*/
|
|
1405
|
+
outputCount(): number;
|
|
1406
|
+
serialize(): Uint8Array;
|
|
1407
|
+
/**
|
|
1408
|
+
* Sign all inputs with a WasmBIP32 key
|
|
1409
|
+
*
|
|
1410
|
+
* This method signs all inputs that match the BIP32 derivation paths in the PSBT.
|
|
1411
|
+
* Returns a map of input indices to the public keys that were signed.
|
|
1412
|
+
*
|
|
1413
|
+
* # Arguments
|
|
1414
|
+
* * `key` - The WasmBIP32 key to sign with
|
|
1415
|
+
*
|
|
1416
|
+
* # Returns
|
|
1417
|
+
* A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
|
|
1418
|
+
*/
|
|
1419
|
+
signAll(key: WasmBIP32): any;
|
|
1420
|
+
/**
|
|
1421
|
+
* Sign all inputs with a WasmECPair key
|
|
1422
|
+
*
|
|
1423
|
+
* This method signs all inputs using the private key from the ECPair.
|
|
1424
|
+
* Returns a map of input indices to the public keys that were signed.
|
|
1425
|
+
*
|
|
1426
|
+
* # Arguments
|
|
1427
|
+
* * `key` - The WasmECPair key to sign with
|
|
1428
|
+
*
|
|
1429
|
+
* # Returns
|
|
1430
|
+
* A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
|
|
1431
|
+
*/
|
|
1432
|
+
signAllWithEcpair(key: WasmECPair): any;
|
|
1433
|
+
signWithPrv(prv: Uint8Array): any;
|
|
1434
|
+
signWithXprv(xprv: string): any;
|
|
1435
|
+
/**
|
|
1436
|
+
* Get the unsigned transaction ID as a hex string
|
|
1437
|
+
*/
|
|
1438
|
+
unsignedTxId(): string;
|
|
1439
|
+
updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
|
|
1440
|
+
updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
|
|
1441
|
+
/**
|
|
1442
|
+
* Validate a signature at a specific input against a pubkey
|
|
1443
|
+
* Returns true if the signature is valid
|
|
1444
|
+
*
|
|
1445
|
+
* This method handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
|
|
1446
|
+
* The pubkey should be provided as bytes (33 bytes for compressed ECDSA, 32 bytes for x-only Schnorr).
|
|
1447
|
+
*/
|
|
1448
|
+
validateSignatureAtInput(input_index: number, pubkey: Uint8Array): boolean;
|
|
1449
|
+
/**
|
|
1450
|
+
* Verify a signature at a specific input using a WasmBIP32 key
|
|
1451
|
+
*
|
|
1452
|
+
* This method verifies if a valid signature exists for the given BIP32 key at the specified input.
|
|
1453
|
+
* It handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
|
|
1454
|
+
*
|
|
1455
|
+
* Note: This method checks if the key's public key matches any signature in the input.
|
|
1456
|
+
* For proper BIP32 verification, the key should be derived to the correct path first.
|
|
1457
|
+
*
|
|
1458
|
+
* # Arguments
|
|
1459
|
+
* * `input_index` - The index of the input to check
|
|
1460
|
+
* * `key` - The WasmBIP32 key to verify against
|
|
1461
|
+
*
|
|
1462
|
+
* # Returns
|
|
1463
|
+
* `true` if a valid signature exists for the key, `false` otherwise
|
|
1464
|
+
*/
|
|
1465
|
+
verifySignatureWithKey(input_index: number, key: WasmBIP32): boolean;
|
|
1466
|
+
/**
|
|
1467
|
+
* Get the transaction version
|
|
1468
|
+
*/
|
|
1469
|
+
version(): number;
|
|
1384
1470
|
}
|