@bitgo/wasm-utxo 1.27.0 → 1.29.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 (41) hide show
  1. package/dist/cjs/js/bip32.d.ts +7 -0
  2. package/dist/cjs/js/bip32.js +16 -0
  3. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +60 -26
  4. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +56 -36
  5. package/dist/cjs/js/fixedScriptWallet/chains.d.ts +5 -0
  6. package/dist/cjs/js/fixedScriptWallet/chains.js +6 -2
  7. package/dist/cjs/js/fixedScriptWallet/index.d.ts +19 -2
  8. package/dist/cjs/js/fixedScriptWallet/index.js +25 -1
  9. package/dist/cjs/js/fixedScriptWallet/scriptType.d.ts +15 -5
  10. package/dist/cjs/js/fixedScriptWallet/scriptType.js +28 -0
  11. package/dist/cjs/js/testutils/AcidTest.d.ts +132 -0
  12. package/dist/cjs/js/testutils/AcidTest.js +306 -0
  13. package/dist/cjs/js/testutils/index.d.ts +2 -0
  14. package/dist/cjs/js/testutils/index.js +18 -0
  15. package/dist/cjs/js/testutils/keys.d.ts +76 -0
  16. package/dist/cjs/js/testutils/keys.js +154 -0
  17. package/dist/cjs/js/wasm/wasm_utxo.d.ts +183 -0
  18. package/dist/cjs/js/wasm/wasm_utxo.js +354 -0
  19. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  20. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +67 -56
  21. package/dist/esm/js/bip32.d.ts +7 -0
  22. package/dist/esm/js/bip32.js +15 -0
  23. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +60 -26
  24. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +57 -37
  25. package/dist/esm/js/fixedScriptWallet/chains.d.ts +5 -0
  26. package/dist/esm/js/fixedScriptWallet/chains.js +6 -3
  27. package/dist/esm/js/fixedScriptWallet/index.d.ts +19 -2
  28. package/dist/esm/js/fixedScriptWallet/index.js +21 -1
  29. package/dist/esm/js/fixedScriptWallet/scriptType.d.ts +15 -5
  30. package/dist/esm/js/fixedScriptWallet/scriptType.js +27 -1
  31. package/dist/esm/js/testutils/AcidTest.d.ts +132 -0
  32. package/dist/esm/js/testutils/AcidTest.js +302 -0
  33. package/dist/esm/js/testutils/index.d.ts +2 -0
  34. package/dist/esm/js/testutils/index.js +2 -0
  35. package/dist/esm/js/testutils/keys.d.ts +76 -0
  36. package/dist/esm/js/testutils/keys.js +113 -0
  37. package/dist/esm/js/wasm/wasm_utxo.d.ts +183 -0
  38. package/dist/esm/js/wasm/wasm_utxo_bg.js +354 -0
  39. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  40. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +67 -56
  41. package/package.json +2 -1
@@ -146,6 +146,20 @@ export class BitGoPsbt {
146
146
  * Get the unsigned transaction ID
147
147
  */
148
148
  unsigned_txid(): string;
149
+ /**
150
+ * Check if an input is a MuSig2 keypath input.
151
+ *
152
+ * MuSig2 inputs require special handling: nonces must be generated first with
153
+ * `generate_musig2_nonces()`, then signed with `sign_musig2_input()`.
154
+ *
155
+ * # Arguments
156
+ * - `input_index`: The index of the input to check (0-based)
157
+ *
158
+ * # Returns
159
+ * - `true` if the input is a MuSig2 keypath input
160
+ * - `false` otherwise (or if input_index is out of bounds)
161
+ */
162
+ is_musig2_input(input_index: number): boolean;
149
163
  /**
150
164
  * Sign a single input with an extended private key (xpriv)
151
165
  *
@@ -208,6 +222,45 @@ export class BitGoPsbt {
208
222
  * The index of the newly added output
209
223
  */
210
224
  add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
225
+ /**
226
+ * Sign a single MuSig2 keypath input.
227
+ *
228
+ * This uses the FirstRound state generated by `generate_musig2_nonces()`.
229
+ * Each FirstRound can only be used once (nonce reuse is a security risk).
230
+ *
231
+ * For non-MuSig2 inputs, returns an error (use `sign_wallet_input` instead).
232
+ *
233
+ * # Arguments
234
+ * - `input_index`: The index of the input to sign (0-based)
235
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
236
+ *
237
+ * # Returns
238
+ * - `Ok(())` if signing was successful
239
+ * - `Err(WasmUtxoError)` if signing fails, no FirstRound exists, or not a MuSig2 input
240
+ */
241
+ sign_musig2_input(input_index: number, xpriv: WasmBIP32): void;
242
+ /**
243
+ * Sign a single non-MuSig2 wallet input using save/restore pattern.
244
+ *
245
+ * For MuSig2 inputs, returns an error (use `sign_musig2_input` instead).
246
+ * For ECDSA inputs, this uses a save/restore pattern: clones the PSBT,
247
+ * signs all inputs on the clone, then copies only the target input's
248
+ * signatures back.
249
+ *
250
+ * **Important:** This is NOT faster than `sign_all_wallet_inputs()` for ECDSA inputs.
251
+ * The underlying library signs all inputs regardless. This method just ensures
252
+ * that only the specified input gets signatures added to the PSBT.
253
+ * Use `sign_all_wallet_inputs()` when signing multiple inputs with the same key.
254
+ *
255
+ * # Arguments
256
+ * - `input_index`: The index of the input to sign (0-based)
257
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
258
+ *
259
+ * # Returns
260
+ * - `Ok(())` if the input was signed
261
+ * - `Err(WasmUtxoError)` if signing fails or input is MuSig2
262
+ */
263
+ sign_wallet_input(input_index: number, xpriv: WasmBIP32): void;
211
264
  /**
212
265
  * Sign a single input with a raw private key
213
266
  *
@@ -266,6 +319,24 @@ export class BitGoPsbt {
266
319
  * - `Err(WasmUtxoError)` if any input failed to finalize
267
320
  */
268
321
  finalize_all_inputs(): void;
322
+ /**
323
+ * Sign all non-MuSig2 inputs with an extended private key (xpriv) in a single pass.
324
+ *
325
+ * This is more efficient than calling `sign_with_xpriv` for each input individually.
326
+ * The underlying miniscript library's `sign` method signs all matching inputs at once.
327
+ *
328
+ * **Note:** MuSig2 inputs are skipped by this method because they require FirstRound
329
+ * state from nonce generation. After calling this method, sign MuSig2 inputs
330
+ * individually using `sign_with_xpriv`.
331
+ *
332
+ * # Arguments
333
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
334
+ *
335
+ * # Returns
336
+ * - `Ok(JsValue)` with an array of input indices that were signed
337
+ * - `Err(WasmUtxoError)` if signing fails
338
+ */
339
+ sign_all_with_xpriv(xpriv: WasmBIP32): any;
269
340
  /**
270
341
  * Add a PayGo attestation to a PSBT output
271
342
  *
@@ -325,6 +396,41 @@ export class BitGoPsbt {
325
396
  * generated for security. Custom session_id is only allowed on testnets for testing purposes.
326
397
  */
327
398
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
399
+ /**
400
+ * Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
401
+ *
402
+ * This is more efficient than calling `sign_musig2_input()` for each input because
403
+ * it reuses the SighashCache across all inputs, avoiding redundant computation of
404
+ * sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs.
405
+ *
406
+ * Each MuSig2 input requires a FirstRound from `generate_musig2_nonces()`.
407
+ * FirstRounds that have already been consumed (signed) are skipped.
408
+ *
409
+ * # Arguments
410
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
411
+ *
412
+ * # Returns
413
+ * - `Ok(JsValue)` with an array of input indices that were signed
414
+ * - `Err(WasmUtxoError)` if signing fails
415
+ */
416
+ sign_all_musig2_inputs(xpriv: WasmBIP32): any;
417
+ /**
418
+ * Sign all non-MuSig2 wallet inputs in a single efficient pass.
419
+ *
420
+ * This signs all ECDSA (P2SH, P2SH-P2WSH, P2WSH) and Taproot script path (P2TR)
421
+ * inputs that match the provided xpriv. MuSig2 keypath inputs are skipped.
422
+ *
423
+ * This is the most efficient way to sign wallet inputs. After calling this,
424
+ * sign any MuSig2 inputs using `sign_all_musig2_inputs()` or `sign_musig2_input()`.
425
+ *
426
+ * # Arguments
427
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
428
+ *
429
+ * # Returns
430
+ * - `Ok(JsValue)` with an array of input indices that were signed
431
+ * - `Err(WasmUtxoError)` if signing fails
432
+ */
433
+ sign_all_wallet_inputs(xpriv: WasmBIP32): any;
328
434
  /**
329
435
  * Add an output to the PSBT by address
330
436
  *
@@ -411,12 +517,79 @@ export class BitGoPsbt {
411
517
  * Returns error if block height is before Overwinter activation
412
518
  */
413
519
  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;
520
+ /**
521
+ * Sign a single input with an extended private key, using save/restore for ECDSA inputs.
522
+ *
523
+ * For MuSig2 inputs, this returns an error (use sign_with_xpriv which handles FirstRound).
524
+ * For ECDSA inputs, this clones the PSBT, signs all, then copies only the target
525
+ * input's signatures back.
526
+ *
527
+ * **Important:** This is NOT faster than `sign_all_with_xpriv` for ECDSA inputs.
528
+ * The underlying miniscript library signs all inputs regardless. This method
529
+ * just prevents signatures from being added to other inputs.
530
+ *
531
+ * # Arguments
532
+ * - `input_index`: The index of the input to sign (0-based)
533
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
534
+ *
535
+ * # Returns
536
+ * - `Ok(())` if the input was signed
537
+ * - `Err(WasmUtxoError)` if signing fails
538
+ */
539
+ sign_single_input_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
540
+ /**
541
+ * Sign all replay protection inputs with a raw private key.
542
+ *
543
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
544
+ * that match the provided public key and signs them.
545
+ *
546
+ * # Arguments
547
+ * - `ecpair`: The ECPair containing the private key
548
+ *
549
+ * # Returns
550
+ * - `Ok(JsValue)` with an array of input indices that were signed
551
+ * - `Err(WasmUtxoError)` if signing fails
552
+ */
553
+ sign_replay_protection_inputs(ecpair: WasmECPair): any;
414
554
  /**
415
555
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
416
556
  *
417
557
  * Note: This method does NOT validate wallet inputs. It only parses outputs.
418
558
  */
419
559
  parse_outputs_with_wallet_keys(wallet_keys: WasmRootWalletKeys, paygo_pubkeys?: WasmECPair[] | null): any;
560
+ /**
561
+ * Sign a single input with a raw private key, using save/restore for regular inputs.
562
+ *
563
+ * For replay protection inputs (P2SH-P2PK), this uses direct signing which is
564
+ * already single-input. For regular inputs, this clones the PSBT, signs all,
565
+ * then copies only the target input's signatures back.
566
+ *
567
+ * **Important:** This is NOT faster than signing all inputs for regular (non-RP) inputs.
568
+ * The underlying miniscript library signs all inputs regardless.
569
+ *
570
+ * # Arguments
571
+ * - `input_index`: The index of the input to sign (0-based)
572
+ * - `ecpair`: The ECPair containing the private key
573
+ *
574
+ * # Returns
575
+ * - `Ok(())` if the input was signed
576
+ * - `Err(WasmUtxoError)` if signing fails
577
+ */
578
+ sign_single_input_with_privkey(input_index: number, ecpair: WasmECPair): void;
579
+ /**
580
+ * Sign all replay protection inputs with a raw private key.
581
+ *
582
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
583
+ * that match the provided public key and signs them.
584
+ *
585
+ * # Arguments
586
+ * - `ecpair`: The ECPair containing the private key
587
+ *
588
+ * # Returns
589
+ * - `Ok(JsValue)` with an array of input indices that were signed
590
+ * - `Err(WasmUtxoError)` if signing fails
591
+ */
592
+ sign_all_replay_protection_inputs(ecpair: WasmECPair): any;
420
593
  /**
421
594
  * Parse transaction with wallet keys to identify wallet inputs/outputs
422
595
  */
@@ -504,6 +677,16 @@ export class FixedScriptWalletNamespace {
504
677
  * - Dogecoin only supports legacy scripts (p2sh)
505
678
  */
506
679
  static supports_script_type(coin: string, script_type: string): boolean;
680
+ /**
681
+ * Create an OP_RETURN output script with optional data
682
+ *
683
+ * # Arguments
684
+ * * `data` - Optional data bytes to include in the OP_RETURN script
685
+ *
686
+ * # Returns
687
+ * The OP_RETURN script as bytes
688
+ */
689
+ static create_op_return_script(data?: Uint8Array | null): Uint8Array;
507
690
  static address_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string, address_format?: string | null): string;
508
691
  static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
509
692
  static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
@@ -738,6 +738,25 @@ export class BitGoPsbt {
738
738
  wasm.__wbindgen_export4(deferred1_0, deferred1_1, 1);
739
739
  }
740
740
  }
741
+ /**
742
+ * Check if an input is a MuSig2 keypath input.
743
+ *
744
+ * MuSig2 inputs require special handling: nonces must be generated first with
745
+ * `generate_musig2_nonces()`, then signed with `sign_musig2_input()`.
746
+ *
747
+ * # Arguments
748
+ * - `input_index`: The index of the input to check (0-based)
749
+ *
750
+ * # Returns
751
+ * - `true` if the input is a MuSig2 keypath input
752
+ * - `false` otherwise (or if input_index is out of bounds)
753
+ * @param {number} input_index
754
+ * @returns {boolean}
755
+ */
756
+ is_musig2_input(input_index) {
757
+ const ret = wasm.bitgopsbt_is_musig2_input(this.__wbg_ptr, input_index);
758
+ return ret !== 0;
759
+ }
741
760
  /**
742
761
  * Sign a single input with an extended private key (xpriv)
743
762
  *
@@ -873,6 +892,75 @@ export class BitGoPsbt {
873
892
  wasm.__wbindgen_add_to_stack_pointer(16);
874
893
  }
875
894
  }
895
+ /**
896
+ * Sign a single MuSig2 keypath input.
897
+ *
898
+ * This uses the FirstRound state generated by `generate_musig2_nonces()`.
899
+ * Each FirstRound can only be used once (nonce reuse is a security risk).
900
+ *
901
+ * For non-MuSig2 inputs, returns an error (use `sign_wallet_input` instead).
902
+ *
903
+ * # Arguments
904
+ * - `input_index`: The index of the input to sign (0-based)
905
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
906
+ *
907
+ * # Returns
908
+ * - `Ok(())` if signing was successful
909
+ * - `Err(WasmUtxoError)` if signing fails, no FirstRound exists, or not a MuSig2 input
910
+ * @param {number} input_index
911
+ * @param {WasmBIP32} xpriv
912
+ */
913
+ sign_musig2_input(input_index, xpriv) {
914
+ try {
915
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
916
+ _assertClass(xpriv, WasmBIP32);
917
+ wasm.bitgopsbt_sign_musig2_input(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
918
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
919
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
920
+ if (r1) {
921
+ throw takeObject(r0);
922
+ }
923
+ } finally {
924
+ wasm.__wbindgen_add_to_stack_pointer(16);
925
+ }
926
+ }
927
+ /**
928
+ * Sign a single non-MuSig2 wallet input using save/restore pattern.
929
+ *
930
+ * For MuSig2 inputs, returns an error (use `sign_musig2_input` instead).
931
+ * For ECDSA inputs, this uses a save/restore pattern: clones the PSBT,
932
+ * signs all inputs on the clone, then copies only the target input's
933
+ * signatures back.
934
+ *
935
+ * **Important:** This is NOT faster than `sign_all_wallet_inputs()` for ECDSA inputs.
936
+ * The underlying library signs all inputs regardless. This method just ensures
937
+ * that only the specified input gets signatures added to the PSBT.
938
+ * Use `sign_all_wallet_inputs()` when signing multiple inputs with the same key.
939
+ *
940
+ * # Arguments
941
+ * - `input_index`: The index of the input to sign (0-based)
942
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
943
+ *
944
+ * # Returns
945
+ * - `Ok(())` if the input was signed
946
+ * - `Err(WasmUtxoError)` if signing fails or input is MuSig2
947
+ * @param {number} input_index
948
+ * @param {WasmBIP32} xpriv
949
+ */
950
+ sign_wallet_input(input_index, xpriv) {
951
+ try {
952
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
953
+ _assertClass(xpriv, WasmBIP32);
954
+ wasm.bitgopsbt_sign_single_input_with_xpriv(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
955
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
956
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
957
+ if (r1) {
958
+ throw takeObject(r0);
959
+ }
960
+ } finally {
961
+ wasm.__wbindgen_add_to_stack_pointer(16);
962
+ }
963
+ }
876
964
  /**
877
965
  * Sign a single input with a raw private key
878
966
  *
@@ -1001,6 +1089,41 @@ export class BitGoPsbt {
1001
1089
  wasm.__wbindgen_add_to_stack_pointer(16);
1002
1090
  }
1003
1091
  }
1092
+ /**
1093
+ * Sign all non-MuSig2 inputs with an extended private key (xpriv) in a single pass.
1094
+ *
1095
+ * This is more efficient than calling `sign_with_xpriv` for each input individually.
1096
+ * The underlying miniscript library's `sign` method signs all matching inputs at once.
1097
+ *
1098
+ * **Note:** MuSig2 inputs are skipped by this method because they require FirstRound
1099
+ * state from nonce generation. After calling this method, sign MuSig2 inputs
1100
+ * individually using `sign_with_xpriv`.
1101
+ *
1102
+ * # Arguments
1103
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
1104
+ *
1105
+ * # Returns
1106
+ * - `Ok(JsValue)` with an array of input indices that were signed
1107
+ * - `Err(WasmUtxoError)` if signing fails
1108
+ * @param {WasmBIP32} xpriv
1109
+ * @returns {any}
1110
+ */
1111
+ sign_all_with_xpriv(xpriv) {
1112
+ try {
1113
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1114
+ _assertClass(xpriv, WasmBIP32);
1115
+ wasm.bitgopsbt_sign_all_wallet_inputs(retptr, this.__wbg_ptr, xpriv.__wbg_ptr);
1116
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1117
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1118
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1119
+ if (r2) {
1120
+ throw takeObject(r1);
1121
+ }
1122
+ return takeObject(r0);
1123
+ } finally {
1124
+ wasm.__wbindgen_add_to_stack_pointer(16);
1125
+ }
1126
+ }
1004
1127
  /**
1005
1128
  * Add a PayGo attestation to a PSBT output
1006
1129
  *
@@ -1110,6 +1233,75 @@ export class BitGoPsbt {
1110
1233
  wasm.__wbindgen_add_to_stack_pointer(16);
1111
1234
  }
1112
1235
  }
1236
+ /**
1237
+ * Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
1238
+ *
1239
+ * This is more efficient than calling `sign_musig2_input()` for each input because
1240
+ * it reuses the SighashCache across all inputs, avoiding redundant computation of
1241
+ * sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs.
1242
+ *
1243
+ * Each MuSig2 input requires a FirstRound from `generate_musig2_nonces()`.
1244
+ * FirstRounds that have already been consumed (signed) are skipped.
1245
+ *
1246
+ * # Arguments
1247
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
1248
+ *
1249
+ * # Returns
1250
+ * - `Ok(JsValue)` with an array of input indices that were signed
1251
+ * - `Err(WasmUtxoError)` if signing fails
1252
+ * @param {WasmBIP32} xpriv
1253
+ * @returns {any}
1254
+ */
1255
+ sign_all_musig2_inputs(xpriv) {
1256
+ try {
1257
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1258
+ _assertClass(xpriv, WasmBIP32);
1259
+ wasm.bitgopsbt_sign_all_musig2_inputs(retptr, this.__wbg_ptr, xpriv.__wbg_ptr);
1260
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1261
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1262
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1263
+ if (r2) {
1264
+ throw takeObject(r1);
1265
+ }
1266
+ return takeObject(r0);
1267
+ } finally {
1268
+ wasm.__wbindgen_add_to_stack_pointer(16);
1269
+ }
1270
+ }
1271
+ /**
1272
+ * Sign all non-MuSig2 wallet inputs in a single efficient pass.
1273
+ *
1274
+ * This signs all ECDSA (P2SH, P2SH-P2WSH, P2WSH) and Taproot script path (P2TR)
1275
+ * inputs that match the provided xpriv. MuSig2 keypath inputs are skipped.
1276
+ *
1277
+ * This is the most efficient way to sign wallet inputs. After calling this,
1278
+ * sign any MuSig2 inputs using `sign_all_musig2_inputs()` or `sign_musig2_input()`.
1279
+ *
1280
+ * # Arguments
1281
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
1282
+ *
1283
+ * # Returns
1284
+ * - `Ok(JsValue)` with an array of input indices that were signed
1285
+ * - `Err(WasmUtxoError)` if signing fails
1286
+ * @param {WasmBIP32} xpriv
1287
+ * @returns {any}
1288
+ */
1289
+ sign_all_wallet_inputs(xpriv) {
1290
+ try {
1291
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1292
+ _assertClass(xpriv, WasmBIP32);
1293
+ wasm.bitgopsbt_sign_all_wallet_inputs(retptr, this.__wbg_ptr, xpriv.__wbg_ptr);
1294
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1295
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1296
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1297
+ if (r2) {
1298
+ throw takeObject(r1);
1299
+ }
1300
+ return takeObject(r0);
1301
+ } finally {
1302
+ wasm.__wbindgen_add_to_stack_pointer(16);
1303
+ }
1304
+ }
1113
1305
  /**
1114
1306
  * Add an output to the PSBT by address
1115
1307
  *
@@ -1299,6 +1491,72 @@ export class BitGoPsbt {
1299
1491
  wasm.__wbindgen_add_to_stack_pointer(16);
1300
1492
  }
1301
1493
  }
1494
+ /**
1495
+ * Sign a single input with an extended private key, using save/restore for ECDSA inputs.
1496
+ *
1497
+ * For MuSig2 inputs, this returns an error (use sign_with_xpriv which handles FirstRound).
1498
+ * For ECDSA inputs, this clones the PSBT, signs all, then copies only the target
1499
+ * input's signatures back.
1500
+ *
1501
+ * **Important:** This is NOT faster than `sign_all_with_xpriv` for ECDSA inputs.
1502
+ * The underlying miniscript library signs all inputs regardless. This method
1503
+ * just prevents signatures from being added to other inputs.
1504
+ *
1505
+ * # Arguments
1506
+ * - `input_index`: The index of the input to sign (0-based)
1507
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
1508
+ *
1509
+ * # Returns
1510
+ * - `Ok(())` if the input was signed
1511
+ * - `Err(WasmUtxoError)` if signing fails
1512
+ * @param {number} input_index
1513
+ * @param {WasmBIP32} xpriv
1514
+ */
1515
+ sign_single_input_with_xpriv(input_index, xpriv) {
1516
+ try {
1517
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1518
+ _assertClass(xpriv, WasmBIP32);
1519
+ wasm.bitgopsbt_sign_single_input_with_xpriv(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
1520
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1521
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1522
+ if (r1) {
1523
+ throw takeObject(r0);
1524
+ }
1525
+ } finally {
1526
+ wasm.__wbindgen_add_to_stack_pointer(16);
1527
+ }
1528
+ }
1529
+ /**
1530
+ * Sign all replay protection inputs with a raw private key.
1531
+ *
1532
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
1533
+ * that match the provided public key and signs them.
1534
+ *
1535
+ * # Arguments
1536
+ * - `ecpair`: The ECPair containing the private key
1537
+ *
1538
+ * # Returns
1539
+ * - `Ok(JsValue)` with an array of input indices that were signed
1540
+ * - `Err(WasmUtxoError)` if signing fails
1541
+ * @param {WasmECPair} ecpair
1542
+ * @returns {any}
1543
+ */
1544
+ sign_replay_protection_inputs(ecpair) {
1545
+ try {
1546
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1547
+ _assertClass(ecpair, WasmECPair);
1548
+ wasm.bitgopsbt_sign_all_replay_protection_inputs(retptr, this.__wbg_ptr, ecpair.__wbg_ptr);
1549
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1550
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1551
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1552
+ if (r2) {
1553
+ throw takeObject(r1);
1554
+ }
1555
+ return takeObject(r0);
1556
+ } finally {
1557
+ wasm.__wbindgen_add_to_stack_pointer(16);
1558
+ }
1559
+ }
1302
1560
  /**
1303
1561
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
1304
1562
  *
@@ -1325,6 +1583,71 @@ export class BitGoPsbt {
1325
1583
  wasm.__wbindgen_add_to_stack_pointer(16);
1326
1584
  }
1327
1585
  }
1586
+ /**
1587
+ * Sign a single input with a raw private key, using save/restore for regular inputs.
1588
+ *
1589
+ * For replay protection inputs (P2SH-P2PK), this uses direct signing which is
1590
+ * already single-input. For regular inputs, this clones the PSBT, signs all,
1591
+ * then copies only the target input's signatures back.
1592
+ *
1593
+ * **Important:** This is NOT faster than signing all inputs for regular (non-RP) inputs.
1594
+ * The underlying miniscript library signs all inputs regardless.
1595
+ *
1596
+ * # Arguments
1597
+ * - `input_index`: The index of the input to sign (0-based)
1598
+ * - `ecpair`: The ECPair containing the private key
1599
+ *
1600
+ * # Returns
1601
+ * - `Ok(())` if the input was signed
1602
+ * - `Err(WasmUtxoError)` if signing fails
1603
+ * @param {number} input_index
1604
+ * @param {WasmECPair} ecpair
1605
+ */
1606
+ sign_single_input_with_privkey(input_index, ecpair) {
1607
+ try {
1608
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1609
+ _assertClass(ecpair, WasmECPair);
1610
+ wasm.bitgopsbt_sign_single_input_with_privkey(retptr, this.__wbg_ptr, input_index, ecpair.__wbg_ptr);
1611
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1612
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1613
+ if (r1) {
1614
+ throw takeObject(r0);
1615
+ }
1616
+ } finally {
1617
+ wasm.__wbindgen_add_to_stack_pointer(16);
1618
+ }
1619
+ }
1620
+ /**
1621
+ * Sign all replay protection inputs with a raw private key.
1622
+ *
1623
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
1624
+ * that match the provided public key and signs them.
1625
+ *
1626
+ * # Arguments
1627
+ * - `ecpair`: The ECPair containing the private key
1628
+ *
1629
+ * # Returns
1630
+ * - `Ok(JsValue)` with an array of input indices that were signed
1631
+ * - `Err(WasmUtxoError)` if signing fails
1632
+ * @param {WasmECPair} ecpair
1633
+ * @returns {any}
1634
+ */
1635
+ sign_all_replay_protection_inputs(ecpair) {
1636
+ try {
1637
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1638
+ _assertClass(ecpair, WasmECPair);
1639
+ wasm.bitgopsbt_sign_all_replay_protection_inputs(retptr, this.__wbg_ptr, ecpair.__wbg_ptr);
1640
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1641
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1642
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1643
+ if (r2) {
1644
+ throw takeObject(r1);
1645
+ }
1646
+ return takeObject(r0);
1647
+ } finally {
1648
+ wasm.__wbindgen_add_to_stack_pointer(16);
1649
+ }
1650
+ }
1328
1651
  /**
1329
1652
  * Parse transaction with wallet keys to identify wallet inputs/outputs
1330
1653
  * @param {WasmRootWalletKeys} wallet_keys
@@ -1579,6 +1902,37 @@ export class FixedScriptWalletNamespace {
1579
1902
  wasm.__wbindgen_add_to_stack_pointer(16);
1580
1903
  }
1581
1904
  }
1905
+ /**
1906
+ * Create an OP_RETURN output script with optional data
1907
+ *
1908
+ * # Arguments
1909
+ * * `data` - Optional data bytes to include in the OP_RETURN script
1910
+ *
1911
+ * # Returns
1912
+ * The OP_RETURN script as bytes
1913
+ * @param {Uint8Array | null} [data]
1914
+ * @returns {Uint8Array}
1915
+ */
1916
+ static create_op_return_script(data) {
1917
+ try {
1918
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1919
+ var ptr0 = isLikeNone(data) ? 0 : passArray8ToWasm0(data, wasm.__wbindgen_export);
1920
+ var len0 = WASM_VECTOR_LEN;
1921
+ wasm.fixedscriptwalletnamespace_create_op_return_script(retptr, ptr0, len0);
1922
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1923
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1924
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1925
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1926
+ if (r3) {
1927
+ throw takeObject(r2);
1928
+ }
1929
+ var v2 = getArrayU8FromWasm0(r0, r1).slice();
1930
+ wasm.__wbindgen_export4(r0, r1 * 1, 1);
1931
+ return v2;
1932
+ } finally {
1933
+ wasm.__wbindgen_add_to_stack_pointer(16);
1934
+ }
1935
+ }
1582
1936
  /**
1583
1937
  * @param {WasmRootWalletKeys} keys
1584
1938
  * @param {number} chain
Binary file