@bitgo/wasm-utxo 1.7.0 → 1.9.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (56) hide show
  1. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +99 -0
  2. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +122 -0
  3. package/dist/cjs/js/wasm/wasm_utxo.d.ts +86 -0
  4. package/dist/cjs/js/wasm/wasm_utxo.js +276 -24
  5. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  6. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +21 -17
  7. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +99 -0
  8. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +122 -0
  9. package/dist/esm/js/wasm/wasm_utxo.d.ts +86 -0
  10. package/dist/esm/js/wasm/wasm_utxo_bg.js +276 -24
  11. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  12. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +21 -17
  13. package/package.json +3 -3
  14. package/dist/cjs/package.json +0 -1
  15. package/dist/cjs/tsconfig.cjs.tsbuildinfo +0 -1
  16. package/dist/esm/test/address/utxolibCompat.d.ts +0 -1
  17. package/dist/esm/test/address/utxolibCompat.js +0 -107
  18. package/dist/esm/test/ast/formatNode.d.ts +0 -1
  19. package/dist/esm/test/ast/formatNode.js +0 -15
  20. package/dist/esm/test/bip32.d.ts +0 -1
  21. package/dist/esm/test/bip32.js +0 -242
  22. package/dist/esm/test/descriptorFixtures.d.ts +0 -25
  23. package/dist/esm/test/descriptorFixtures.js +0 -605
  24. package/dist/esm/test/descriptorUtil.d.ts +0 -13
  25. package/dist/esm/test/descriptorUtil.js +0 -52
  26. package/dist/esm/test/ecpair.d.ts +0 -1
  27. package/dist/esm/test/ecpair.js +0 -137
  28. package/dist/esm/test/fixedScript/address.d.ts +0 -1
  29. package/dist/esm/test/fixedScript/address.js +0 -66
  30. package/dist/esm/test/fixedScript/finalizeExtract.d.ts +0 -1
  31. package/dist/esm/test/fixedScript/finalizeExtract.js +0 -66
  32. package/dist/esm/test/fixedScript/fixtureUtil.d.ts +0 -95
  33. package/dist/esm/test/fixedScript/fixtureUtil.js +0 -55
  34. package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.d.ts +0 -1
  35. package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.js +0 -168
  36. package/dist/esm/test/fixedScript/verifySignature.d.ts +0 -1
  37. package/dist/esm/test/fixedScript/verifySignature.js +0 -187
  38. package/dist/esm/test/fixedScriptToDescriptor.d.ts +0 -1
  39. package/dist/esm/test/fixedScriptToDescriptor.js +0 -93
  40. package/dist/esm/test/fixtures.d.ts +0 -1
  41. package/dist/esm/test/fixtures.js +0 -16
  42. package/dist/esm/test/opdrop.d.ts +0 -1
  43. package/dist/esm/test/opdrop.js +0 -85
  44. package/dist/esm/test/psbt.util.d.ts +0 -8
  45. package/dist/esm/test/psbt.util.js +0 -113
  46. package/dist/esm/test/psbtFixedScriptCompat.d.ts +0 -1
  47. package/dist/esm/test/psbtFixedScriptCompat.js +0 -116
  48. package/dist/esm/test/psbtFixedScriptCompatFixtures.d.ts +0 -10
  49. package/dist/esm/test/psbtFixedScriptCompatFixtures.js +0 -53
  50. package/dist/esm/test/psbtFromDescriptor.d.ts +0 -1
  51. package/dist/esm/test/psbtFromDescriptor.js +0 -104
  52. package/dist/esm/test/psbtFromDescriptor.util.d.ts +0 -63
  53. package/dist/esm/test/psbtFromDescriptor.util.js +0 -101
  54. package/dist/esm/test/test.d.ts +0 -1
  55. package/dist/esm/test/test.js +0 -123
  56. package/dist/esm/tsconfig.tsbuildinfo +0 -1
@@ -54,6 +54,18 @@ function getArrayU8FromWasm0(ptr, len) {
54
54
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
55
55
  }
56
56
 
57
+ function dropObject(idx) {
58
+ if (idx < 132) return;
59
+ heap[idx] = heap_next;
60
+ heap_next = idx;
61
+ }
62
+
63
+ function takeObject(idx) {
64
+ const ret = getObject(idx);
65
+ dropObject(idx);
66
+ return ret;
67
+ }
68
+
57
69
  function isLikeNone(x) {
58
70
  return x === undefined || x === null;
59
71
  }
@@ -121,24 +133,6 @@ function passStringToWasm0(arg, malloc, realloc) {
121
133
  return ptr;
122
134
  }
123
135
 
124
- function dropObject(idx) {
125
- if (idx < 132) return;
126
- heap[idx] = heap_next;
127
- heap_next = idx;
128
- }
129
-
130
- function takeObject(idx) {
131
- const ret = getObject(idx);
132
- dropObject(idx);
133
- return ret;
134
- }
135
-
136
- function _assertClass(instance, klass) {
137
- if (!(instance instanceof klass)) {
138
- throw new Error(`expected instance of ${klass.name}`);
139
- }
140
- }
141
-
142
136
  function passArray8ToWasm0(arg, malloc) {
143
137
  const ptr = malloc(arg.length * 1, 1) >>> 0;
144
138
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -146,12 +140,10 @@ function passArray8ToWasm0(arg, malloc) {
146
140
  return ptr;
147
141
  }
148
142
 
149
- let stack_pointer = 128;
150
-
151
- function addBorrowedObject(obj) {
152
- if (stack_pointer == 1) throw new Error('out of js stack');
153
- heap[--stack_pointer] = obj;
154
- return stack_pointer;
143
+ function _assertClass(instance, klass) {
144
+ if (!(instance instanceof klass)) {
145
+ throw new Error(`expected instance of ${klass.name}`);
146
+ }
155
147
  }
156
148
 
157
149
  function passArrayJsValueToWasm0(array, malloc) {
@@ -164,6 +156,14 @@ function passArrayJsValueToWasm0(array, malloc) {
164
156
  return ptr;
165
157
  }
166
158
 
159
+ let stack_pointer = 128;
160
+
161
+ function addBorrowedObject(obj) {
162
+ if (stack_pointer == 1) throw new Error('out of js stack');
163
+ heap[--stack_pointer] = obj;
164
+ return stack_pointer;
165
+ }
166
+
167
167
  const AddressNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
168
168
  ? { register: () => {}, unregister: () => {} }
169
169
  : new FinalizationRegistry(ptr => wasm.__wbg_addressnamespace_free(ptr >>> 0, 1));
@@ -319,6 +319,76 @@ class BitGoPsbt {
319
319
  wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
320
320
  }
321
321
  }
322
+ /**
323
+ * Sign a single input with an extended private key (xpriv)
324
+ *
325
+ * This method signs a specific input using the provided xpriv. It accepts:
326
+ * - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
327
+ *
328
+ * This method automatically detects and handles different input types:
329
+ * - For regular inputs: uses standard PSBT signing
330
+ * - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
331
+ * - For replay protection inputs: returns error (use sign_with_privkey instead)
332
+ *
333
+ * # Arguments
334
+ * - `input_index`: The index of the input to sign (0-based)
335
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
336
+ *
337
+ * # Returns
338
+ * - `Ok(())` if signing was successful
339
+ * - `Err(WasmUtxoError)` if signing fails
340
+ * @param {number} input_index
341
+ * @param {WasmBIP32} xpriv
342
+ */
343
+ sign_with_xpriv(input_index, xpriv) {
344
+ try {
345
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
346
+ _assertClass(xpriv, WasmBIP32);
347
+ wasm.bitgopsbt_sign_with_xpriv(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
348
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
349
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
350
+ if (r1) {
351
+ throw takeObject(r0);
352
+ }
353
+ } finally {
354
+ wasm.__wbindgen_add_to_stack_pointer(16);
355
+ }
356
+ }
357
+ /**
358
+ * Sign a single input with a raw private key
359
+ *
360
+ * This method signs a specific input using the provided ECPair. It accepts:
361
+ * - A raw privkey (WasmECPair) for replay protection inputs - signs directly
362
+ *
363
+ * This method automatically detects and handles different input types:
364
+ * - For replay protection inputs: signs with legacy P2SH sighash
365
+ * - For regular inputs: uses standard PSBT signing
366
+ * - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
367
+ *
368
+ * # Arguments
369
+ * - `input_index`: The index of the input to sign (0-based)
370
+ * - `ecpair`: The ECPair containing the private key
371
+ *
372
+ * # Returns
373
+ * - `Ok(())` if signing was successful
374
+ * - `Err(WasmUtxoError)` if signing fails
375
+ * @param {number} input_index
376
+ * @param {WasmECPair} ecpair
377
+ */
378
+ sign_with_privkey(input_index, ecpair) {
379
+ try {
380
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
381
+ _assertClass(ecpair, WasmECPair);
382
+ wasm.bitgopsbt_sign_with_privkey(retptr, this.__wbg_ptr, input_index, ecpair.__wbg_ptr);
383
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
384
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
385
+ if (r1) {
386
+ throw takeObject(r0);
387
+ }
388
+ } finally {
389
+ wasm.__wbindgen_add_to_stack_pointer(16);
390
+ }
391
+ }
322
392
  /**
323
393
  * Extract the final transaction from a finalized PSBT
324
394
  *
@@ -371,6 +441,83 @@ class BitGoPsbt {
371
441
  wasm.__wbindgen_add_to_stack_pointer(16);
372
442
  }
373
443
  }
444
+ /**
445
+ * Combine/merge data from another PSBT into this one
446
+ *
447
+ * This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
448
+ * source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
449
+ * and signature collection phases.
450
+ *
451
+ * # Arguments
452
+ * * `source_psbt` - The source PSBT containing data to merge
453
+ *
454
+ * # Returns
455
+ * Ok(()) if data was successfully merged
456
+ *
457
+ * # Errors
458
+ * Returns error if networks don't match
459
+ * @param {BitGoPsbt} source_psbt
460
+ */
461
+ combine_musig2_nonces(source_psbt) {
462
+ try {
463
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
464
+ _assertClass(source_psbt, BitGoPsbt);
465
+ wasm.bitgopsbt_combine_musig2_nonces(retptr, this.__wbg_ptr, source_psbt.__wbg_ptr);
466
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
467
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
468
+ if (r1) {
469
+ throw takeObject(r0);
470
+ }
471
+ } finally {
472
+ wasm.__wbindgen_add_to_stack_pointer(16);
473
+ }
474
+ }
475
+ /**
476
+ * Generate and store MuSig2 nonces for all MuSig2 inputs
477
+ *
478
+ * This method generates nonces using the State-Machine API and stores them in the PSBT.
479
+ * The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
480
+ * After ALL participants have generated their nonces, they can sign MuSig2 inputs using
481
+ * sign_with_xpriv().
482
+ *
483
+ * # Arguments
484
+ * * `xpriv` - The extended private key (xpriv) for signing
485
+ * * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
486
+ * On mainnets, a secure random session ID is always generated automatically.
487
+ * Must be unique per signing session.
488
+ *
489
+ * # Returns
490
+ * Ok(()) if nonces were successfully generated and stored
491
+ *
492
+ * # Errors
493
+ * Returns error if:
494
+ * - Nonce generation fails
495
+ * - session_id length is invalid
496
+ * - Custom session_id is provided on a mainnet (security restriction)
497
+ *
498
+ * # Security
499
+ * The session_id MUST be cryptographically random and unique for each signing session.
500
+ * Never reuse a session_id with the same key! On mainnets, session_id is always randomly
501
+ * generated for security. Custom session_id is only allowed on testnets for testing purposes.
502
+ * @param {WasmBIP32} xpriv
503
+ * @param {Uint8Array | null} [session_id_bytes]
504
+ */
505
+ generate_musig2_nonces(xpriv, session_id_bytes) {
506
+ try {
507
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
508
+ _assertClass(xpriv, WasmBIP32);
509
+ var ptr0 = isLikeNone(session_id_bytes) ? 0 : passArray8ToWasm0(session_id_bytes, wasm.__wbindgen_export_1);
510
+ var len0 = WASM_VECTOR_LEN;
511
+ wasm.bitgopsbt_generate_musig2_nonces(retptr, this.__wbg_ptr, xpriv.__wbg_ptr, ptr0, len0);
512
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
513
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
514
+ if (r1) {
515
+ throw takeObject(r0);
516
+ }
517
+ } finally {
518
+ wasm.__wbindgen_add_to_stack_pointer(16);
519
+ }
520
+ }
374
521
  /**
375
522
  * Verify if a valid signature exists for a given ECPair key at the specified input index
376
523
  *
@@ -2196,6 +2343,25 @@ exports.__wbg_Error_e17e777aac105295 = function(arg0, arg1) {
2196
2343
  return addHeapObject(ret);
2197
2344
  };
2198
2345
 
2346
+ exports.__wbg_call_13410aac570ffff7 = function() { return handleError(function (arg0, arg1) {
2347
+ const ret = getObject(arg0).call(getObject(arg1));
2348
+ return addHeapObject(ret);
2349
+ }, arguments) };
2350
+
2351
+ exports.__wbg_call_a5400b25a865cfd8 = function() { return handleError(function (arg0, arg1, arg2) {
2352
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
2353
+ return addHeapObject(ret);
2354
+ }, arguments) };
2355
+
2356
+ exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
2357
+ const ret = getObject(arg0).crypto;
2358
+ return addHeapObject(ret);
2359
+ };
2360
+
2361
+ exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
2362
+ getObject(arg0).getRandomValues(getObject(arg1));
2363
+ }, arguments) };
2364
+
2199
2365
  exports.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
2200
2366
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
2201
2367
  return addHeapObject(ret);
@@ -2206,6 +2372,11 @@ exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
2206
2372
  return ret;
2207
2373
  };
2208
2374
 
2375
+ exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
2376
+ const ret = getObject(arg0).msCrypto;
2377
+ return addHeapObject(ret);
2378
+ };
2379
+
2209
2380
  exports.__wbg_new_19c25a3f2fa63a02 = function() {
2210
2381
  const ret = new Object();
2211
2382
  return addHeapObject(ret);
@@ -2231,6 +2402,26 @@ exports.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
2231
2402
  return addHeapObject(ret);
2232
2403
  };
2233
2404
 
2405
+ exports.__wbg_newnoargs_254190557c45b4ec = function(arg0, arg1) {
2406
+ const ret = new Function(getStringFromWasm0(arg0, arg1));
2407
+ return addHeapObject(ret);
2408
+ };
2409
+
2410
+ exports.__wbg_newwithlength_a167dcc7aaa3ba77 = function(arg0) {
2411
+ const ret = new Uint8Array(arg0 >>> 0);
2412
+ return addHeapObject(ret);
2413
+ };
2414
+
2415
+ exports.__wbg_node_905d3e251edff8a2 = function(arg0) {
2416
+ const ret = getObject(arg0).node;
2417
+ return addHeapObject(ret);
2418
+ };
2419
+
2420
+ exports.__wbg_process_dc0fbacc7c1c06f7 = function(arg0) {
2421
+ const ret = getObject(arg0).process;
2422
+ return addHeapObject(ret);
2423
+ };
2424
+
2234
2425
  exports.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
2235
2426
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
2236
2427
  };
@@ -2240,16 +2431,71 @@ exports.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
2240
2431
  return ret;
2241
2432
  };
2242
2433
 
2434
+ exports.__wbg_randomFillSync_ac0988aba3254290 = function() { return handleError(function (arg0, arg1) {
2435
+ getObject(arg0).randomFillSync(takeObject(arg1));
2436
+ }, arguments) };
2437
+
2438
+ exports.__wbg_require_60cc747a6bc5215a = function() { return handleError(function () {
2439
+ const ret = module.require;
2440
+ return addHeapObject(ret);
2441
+ }, arguments) };
2442
+
2243
2443
  exports.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
2244
2444
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
2245
2445
  return ret;
2246
2446
  }, arguments) };
2247
2447
 
2448
+ exports.__wbg_static_accessor_GLOBAL_8921f820c2ce3f12 = function() {
2449
+ const ret = typeof global === 'undefined' ? null : global;
2450
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2451
+ };
2452
+
2453
+ exports.__wbg_static_accessor_GLOBAL_THIS_f0a4409105898184 = function() {
2454
+ const ret = typeof globalThis === 'undefined' ? null : globalThis;
2455
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2456
+ };
2457
+
2458
+ exports.__wbg_static_accessor_SELF_995b214ae681ff99 = function() {
2459
+ const ret = typeof self === 'undefined' ? null : self;
2460
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2461
+ };
2462
+
2463
+ exports.__wbg_static_accessor_WINDOW_cde3890479c675ea = function() {
2464
+ const ret = typeof window === 'undefined' ? null : window;
2465
+ return isLikeNone(ret) ? 0 : addHeapObject(ret);
2466
+ };
2467
+
2468
+ exports.__wbg_subarray_70fd07feefe14294 = function(arg0, arg1, arg2) {
2469
+ const ret = getObject(arg0).subarray(arg1 >>> 0, arg2 >>> 0);
2470
+ return addHeapObject(ret);
2471
+ };
2472
+
2473
+ exports.__wbg_versions_c01dfd4722a88165 = function(arg0) {
2474
+ const ret = getObject(arg0).versions;
2475
+ return addHeapObject(ret);
2476
+ };
2477
+
2478
+ exports.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
2479
+ const ret = typeof(getObject(arg0)) === 'function';
2480
+ return ret;
2481
+ };
2482
+
2248
2483
  exports.__wbg_wbindgenisnull_f3037694abe4d97a = function(arg0) {
2249
2484
  const ret = getObject(arg0) === null;
2250
2485
  return ret;
2251
2486
  };
2252
2487
 
2488
+ exports.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
2489
+ const val = getObject(arg0);
2490
+ const ret = typeof(val) === 'object' && val !== null;
2491
+ return ret;
2492
+ };
2493
+
2494
+ exports.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
2495
+ const ret = typeof(getObject(arg0)) === 'string';
2496
+ return ret;
2497
+ };
2498
+
2253
2499
  exports.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
2254
2500
  const ret = getObject(arg0) === undefined;
2255
2501
  return ret;
@@ -2287,6 +2533,12 @@ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
2287
2533
  return addHeapObject(ret);
2288
2534
  };
2289
2535
 
2536
+ exports.__wbindgen_cast_cb9088102bce6b30 = function(arg0, arg1) {
2537
+ // Cast intrinsic for `Ref(Slice(U8)) -> NamedExternref("Uint8Array")`.
2538
+ const ret = getArrayU8FromWasm0(arg0, arg1);
2539
+ return addHeapObject(ret);
2540
+ };
2541
+
2290
2542
  exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
2291
2543
  // Cast intrinsic for `F64 -> Externref`.
2292
2544
  const ret = arg0;
Binary file
@@ -2,11 +2,22 @@
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
4
4
  export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
5
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
6
+ export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
7
+ export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
8
+ export const wrapminiscript_encode: (a: number, b: number) => void;
9
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
10
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
11
+ export const wrapminiscript_node: (a: number, b: number) => void;
12
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
13
+ export const wrapminiscript_toString: (a: number, b: number) => void;
14
+ export const __wbg_addressnamespace_free: (a: number, b: number) => void;
5
15
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
6
16
  export const __wbg_wasmecpair_free: (a: number, b: number) => void;
17
+ export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
7
18
  export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
8
- export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
9
- export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
19
+ export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
20
+ export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
10
21
  export const wasmbip32_chain_code: (a: number) => number;
11
22
  export const wasmbip32_depth: (a: number) => number;
12
23
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -37,26 +48,30 @@ export const wasmecpair_public_key: (a: number) => number;
37
48
  export const wasmecpair_to_wif: (a: number, b: number) => void;
38
49
  export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
39
50
  export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
51
+ export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
52
+ export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
53
+ export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
40
54
  export const wasmrootwalletkeys_backup_key: (a: number) => number;
41
55
  export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
42
56
  export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
43
57
  export const wasmrootwalletkeys_user_key: (a: number) => number;
44
58
  export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
45
59
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
46
- export const __wbg_addressnamespace_free: (a: number, b: number) => void;
47
60
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
61
+ export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
48
62
  export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
49
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
50
63
  export const __wbg_wrappsbt_free: (a: number, b: number) => void;
51
- export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
52
- export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
64
+ export const bitgopsbt_combine_musig2_nonces: (a: number, b: number, c: number) => void;
53
65
  export const bitgopsbt_extract_transaction: (a: number, b: number) => void;
54
66
  export const bitgopsbt_finalize_all_inputs: (a: number, b: number) => void;
55
67
  export const bitgopsbt_from_bytes: (a: number, b: number, c: number, d: number, e: number) => void;
68
+ export const bitgopsbt_generate_musig2_nonces: (a: number, b: number, c: number, d: number, e: number) => void;
56
69
  export const bitgopsbt_network: (a: number, b: number) => void;
57
70
  export const bitgopsbt_parse_outputs_with_wallet_keys: (a: number, b: number, c: number) => void;
58
71
  export const bitgopsbt_parse_transaction_with_wallet_keys: (a: number, b: number, c: number, d: number) => void;
59
72
  export const bitgopsbt_serialize: (a: number, b: number) => void;
73
+ export const bitgopsbt_sign_with_privkey: (a: number, b: number, c: number, d: number) => void;
74
+ export const bitgopsbt_sign_with_xpriv: (a: number, b: number, c: number, d: number) => void;
60
75
  export const bitgopsbt_unsigned_txid: (a: number, b: number) => void;
61
76
  export const bitgopsbt_verify_replay_protection_signature: (a: number, b: number, c: number, d: number) => void;
62
77
  export const bitgopsbt_verify_signature_with_pub: (a: number, b: number, c: number, d: number) => void;
@@ -74,12 +89,6 @@ export const wrapdescriptor_node: (a: number, b: number) => void;
74
89
  export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
75
90
  export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
76
91
  export const wrapdescriptor_toString: (a: number, b: number) => void;
77
- export const wrapminiscript_encode: (a: number, b: number) => void;
78
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
79
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
80
- export const wrapminiscript_node: (a: number, b: number) => void;
81
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
82
- export const wrapminiscript_toString: (a: number, b: number) => void;
83
92
  export const wrappsbt_clone: (a: number) => number;
84
93
  export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
85
94
  export const wrappsbt_finalize: (a: number, b: number) => void;
@@ -88,11 +97,6 @@ export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number)
88
97
  export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
89
98
  export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
90
99
  export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
91
- export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
92
- export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
93
- export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
94
- export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
95
- export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
96
100
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
97
101
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
98
102
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
@@ -100,6 +100,46 @@ export declare class BitGoPsbt {
100
100
  * ```
101
101
  */
102
102
  verifySignature(inputIndex: number, key: BIP32Arg | ECPairArg): boolean;
103
+ /**
104
+ * Sign a single input with a private key
105
+ *
106
+ * This method signs a specific input using the provided key. It accepts either:
107
+ * - An xpriv (BIP32Arg: base58 string, BIP32 instance, or WasmBIP32) for wallet inputs - derives the key and signs
108
+ * - A raw privkey (ECPairArg: Buffer, ECPair instance, or WasmECPair) for replay protection inputs - signs directly
109
+ *
110
+ * This method automatically detects and handles different input types:
111
+ * - For regular inputs: uses standard PSBT signing
112
+ * - For MuSig2 inputs: uses the FirstRound state stored by generateMusig2Nonces()
113
+ * - For replay protection inputs: signs with legacy P2SH sighash
114
+ *
115
+ * @param inputIndex - The index of the input to sign (0-based)
116
+ * @param key - Either an xpriv (BIP32Arg) or a raw privkey (ECPairArg)
117
+ * @throws Error if signing fails, or if generateMusig2Nonces() was not called first for MuSig2 inputs
118
+ *
119
+ * @example
120
+ * ```typescript
121
+ * // Parse transaction to identify input types
122
+ * const parsed = psbt.parseTransactionWithWalletKeys(walletKeys, replayProtection);
123
+ *
124
+ * // Sign regular wallet inputs with xpriv
125
+ * for (let i = 0; i < parsed.inputs.length; i++) {
126
+ * const input = parsed.inputs[i];
127
+ * if (input.scriptId !== null && input.scriptType !== "p2shP2pk") {
128
+ * psbt.sign(i, userXpriv);
129
+ * }
130
+ * }
131
+ *
132
+ * // Sign replay protection inputs with raw privkey
133
+ * const userPrivkey = bip32.fromBase58(userXpriv).privateKey!;
134
+ * for (let i = 0; i < parsed.inputs.length; i++) {
135
+ * const input = parsed.inputs[i];
136
+ * if (input.scriptType === "p2shP2pk") {
137
+ * psbt.sign(i, userPrivkey);
138
+ * }
139
+ * }
140
+ * ```
141
+ */
142
+ sign(inputIndex: number, key: BIP32Arg | ECPairArg): void;
103
143
  /**
104
144
  * @deprecated - use verifySignature with the replay protection key instead
105
145
  *
@@ -127,6 +167,65 @@ export declare class BitGoPsbt {
127
167
  * @returns The serialized PSBT as a byte array
128
168
  */
129
169
  serialize(): Uint8Array;
170
+ /**
171
+ * Generate and store MuSig2 nonces for all MuSig2 inputs
172
+ *
173
+ * This method generates nonces using the State-Machine API and stores them in the PSBT.
174
+ * The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
175
+ * After ALL participants have generated their nonces, you can sign MuSig2 inputs using
176
+ * sign().
177
+ *
178
+ * @param key - The extended private key (xpriv) for signing. Can be a base58 string, BIP32 instance, or WasmBIP32
179
+ * @param sessionId - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
180
+ * On mainnets, a secure random session ID is always generated automatically.
181
+ * Must be unique per signing session.
182
+ * @throws Error if nonce generation fails, sessionId length is invalid, or custom sessionId is
183
+ * provided on a mainnet (security restriction)
184
+ *
185
+ * @security The sessionId MUST be cryptographically random and unique for each signing session.
186
+ * Never reuse a sessionId with the same key! On mainnets, sessionId is always randomly
187
+ * generated for security. Custom sessionId is only allowed on testnets for testing purposes.
188
+ *
189
+ * @example
190
+ * ```typescript
191
+ * // Phase 1: Both parties generate nonces (with auto-generated session ID)
192
+ * psbt.generateMusig2Nonces(userXpriv);
193
+ * // Nonces are stored in the PSBT
194
+ * // Send PSBT to counterparty
195
+ *
196
+ * // Phase 2: After receiving counterparty PSBT with their nonces
197
+ * const counterpartyPsbt = BitGoPsbt.fromBytes(counterpartyPsbtBytes, network);
198
+ * psbt.combineMusig2Nonces(counterpartyPsbt);
199
+ * // Sign MuSig2 key path inputs
200
+ * const parsed = psbt.parseTransactionWithWalletKeys(walletKeys, replayProtection);
201
+ * for (let i = 0; i < parsed.inputs.length; i++) {
202
+ * if (parsed.inputs[i].scriptType === "p2trMusig2KeyPath") {
203
+ * psbt.sign(i, userXpriv);
204
+ * }
205
+ * }
206
+ * ```
207
+ */
208
+ generateMusig2Nonces(key: BIP32Arg, sessionId?: Uint8Array): void;
209
+ /**
210
+ * Combine/merge data from another PSBT into this one
211
+ *
212
+ * This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
213
+ * source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
214
+ * and signature collection phases.
215
+ *
216
+ * @param sourcePsbt - The source PSBT containing data to merge
217
+ * @throws Error if networks don't match
218
+ *
219
+ * @example
220
+ * ```typescript
221
+ * // After receiving counterparty's PSBT with their nonces
222
+ * const counterpartyPsbt = BitGoPsbt.fromBytes(counterpartyPsbtBytes, network);
223
+ * psbt.combineMusig2Nonces(counterpartyPsbt);
224
+ * // Now can sign with all nonces present
225
+ * psbt.sign(0, userXpriv);
226
+ * ```
227
+ */
228
+ combineMusig2Nonces(sourcePsbt: BitGoPsbt): void;
130
229
  /**
131
230
  * Finalize all inputs in the PSBT
132
231
  *