@bitgo/wasm-utxo 1.6.0 → 1.8.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 (63) hide show
  1. package/dist/cjs/js/bip32.d.ts +140 -0
  2. package/dist/cjs/js/bip32.js +177 -0
  3. package/dist/cjs/js/ecpair.d.ts +96 -0
  4. package/dist/cjs/js/ecpair.js +134 -0
  5. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +242 -0
  6. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +274 -0
  7. package/dist/cjs/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
  8. package/dist/cjs/js/fixedScriptWallet/ReplayProtection.js +89 -0
  9. package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
  10. package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.js +108 -0
  11. package/dist/cjs/js/fixedScriptWallet/address.d.ts +20 -0
  12. package/dist/cjs/js/fixedScriptWallet/address.js +29 -0
  13. package/dist/cjs/js/fixedScriptWallet/index.d.ts +4 -0
  14. package/dist/cjs/js/fixedScriptWallet/index.js +12 -0
  15. package/dist/cjs/js/index.d.ts +5 -1
  16. package/dist/cjs/js/index.js +11 -2
  17. package/dist/cjs/js/utxolibCompat.d.ts +0 -18
  18. package/dist/cjs/js/wasm/wasm_utxo.d.ts +333 -15
  19. package/dist/cjs/js/wasm/wasm_utxo.js +1311 -201
  20. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  21. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +64 -15
  22. package/dist/cjs/tsconfig.cjs.tsbuildinfo +1 -1
  23. package/dist/esm/js/bip32.d.ts +140 -0
  24. package/dist/esm/js/bip32.js +173 -0
  25. package/dist/esm/js/ecpair.d.ts +96 -0
  26. package/dist/esm/js/ecpair.js +130 -0
  27. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +242 -0
  28. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +270 -0
  29. package/dist/esm/js/fixedScriptWallet/ReplayProtection.d.ts +58 -0
  30. package/dist/esm/js/fixedScriptWallet/ReplayProtection.js +85 -0
  31. package/dist/esm/js/fixedScriptWallet/RootWalletKeys.d.ts +66 -0
  32. package/dist/esm/js/fixedScriptWallet/RootWalletKeys.js +104 -0
  33. package/dist/esm/js/fixedScriptWallet/address.d.ts +20 -0
  34. package/dist/esm/js/fixedScriptWallet/address.js +25 -0
  35. package/dist/esm/js/fixedScriptWallet/index.d.ts +4 -0
  36. package/dist/esm/js/fixedScriptWallet/index.js +4 -0
  37. package/dist/esm/js/index.d.ts +5 -1
  38. package/dist/esm/js/index.js +8 -1
  39. package/dist/esm/js/utxolibCompat.d.ts +0 -18
  40. package/dist/esm/js/wasm/wasm_utxo.d.ts +333 -15
  41. package/dist/esm/js/wasm/wasm_utxo_bg.js +1301 -199
  42. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  43. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +64 -15
  44. package/dist/esm/test/bip32.js +242 -0
  45. package/dist/esm/test/ecpair.d.ts +1 -0
  46. package/dist/esm/test/ecpair.js +137 -0
  47. package/dist/esm/test/fixedScript/fixtureUtil.d.ts +12 -2
  48. package/dist/esm/test/fixedScript/fixtureUtil.js +28 -7
  49. package/dist/esm/test/fixedScript/musig2Nonces.d.ts +1 -0
  50. package/dist/esm/test/fixedScript/musig2Nonces.js +77 -0
  51. package/dist/esm/test/fixedScript/parseTransactionWithWalletKeys.js +7 -7
  52. package/dist/esm/test/fixedScript/signAndVerifySignature.d.ts +1 -0
  53. package/dist/esm/test/fixedScript/signAndVerifySignature.js +268 -0
  54. package/dist/esm/test/fixedScript/walletKeys.util.d.ts +12 -0
  55. package/dist/esm/test/fixedScript/walletKeys.util.js +17 -0
  56. package/dist/esm/tsconfig.tsbuildinfo +1 -1
  57. package/package.json +1 -1
  58. package/dist/cjs/js/fixedScriptWallet.d.ts +0 -146
  59. package/dist/cjs/js/fixedScriptWallet.js +0 -138
  60. package/dist/esm/js/fixedScriptWallet.d.ts +0 -146
  61. package/dist/esm/js/fixedScriptWallet.js +0 -132
  62. package/dist/esm/test/fixedScript/verifySignature.js +0 -141
  63. /package/dist/esm/test/{fixedScript/verifySignature.d.ts → bip32.d.ts} +0 -0
@@ -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,18 +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
136
  function passArray8ToWasm0(arg, malloc) {
137
137
  const ptr = malloc(arg.length * 1, 1) >>> 0;
138
138
  getUint8ArrayMemory0().set(arg, ptr / 1);
@@ -140,12 +140,30 @@ function passArray8ToWasm0(arg, malloc) {
140
140
  return ptr;
141
141
  }
142
142
 
143
+ function passArrayJsValueToWasm0(array, malloc) {
144
+ const ptr = malloc(array.length * 4, 4) >>> 0;
145
+ const mem = getDataViewMemory0();
146
+ for (let i = 0; i < array.length; i++) {
147
+ mem.setUint32(ptr + 4 * i, addHeapObject(array[i]), true);
148
+ }
149
+ WASM_VECTOR_LEN = array.length;
150
+ return ptr;
151
+ }
152
+
143
153
  function _assertClass(instance, klass) {
144
154
  if (!(instance instanceof klass)) {
145
155
  throw new Error(`expected instance of ${klass.name}`);
146
156
  }
147
157
  }
148
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
+
149
167
  const AddressNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
150
168
  ? { register: () => {}, unregister: () => {} }
151
169
  : new FinalizationRegistry(ptr => wasm.__wbg_addressnamespace_free(ptr >>> 0, 1));
@@ -302,37 +320,71 @@ class BitGoPsbt {
302
320
  }
303
321
  }
304
322
  /**
305
- * Verify if a valid signature exists for a given xpub at the specified input index
323
+ * Sign a single input with an extended private key (xpriv)
306
324
  *
307
- * This method derives the public key from the xpub using the derivation path found in the
308
- * PSBT input, then verifies the signature. It supports both ECDSA signatures (for legacy/SegWit
309
- * inputs) and Schnorr signatures (for Taproot script path inputs).
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)
310
332
  *
311
333
  * # Arguments
312
- * - `input_index`: The index of the input to check
313
- * - `xpub_str`: The extended public key as a base58-encoded string
334
+ * - `input_index`: The index of the input to sign (0-based)
335
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
314
336
  *
315
337
  * # Returns
316
- * - `Ok(true)` if a valid signature exists for the derived public key
317
- * - `Ok(false)` if no signature exists for the derived public key
318
- * - `Err(WasmUtxoError)` if the input index is out of bounds, xpub is invalid, derivation fails, or verification fails
338
+ * - `Ok(())` if signing was successful
339
+ * - `Err(WasmUtxoError)` if signing fails
319
340
  * @param {number} input_index
320
- * @param {string} xpub_str
321
- * @returns {boolean}
341
+ * @param {WasmBIP32} xpriv
322
342
  */
323
- verify_signature(input_index, xpub_str) {
343
+ sign_with_xpriv(input_index, xpriv) {
324
344
  try {
325
345
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
326
- const ptr0 = passStringToWasm0(xpub_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
327
- const len0 = WASM_VECTOR_LEN;
328
- wasm.bitgopsbt_verify_signature(retptr, this.__wbg_ptr, input_index, ptr0, len0);
346
+ _assertClass(xpriv, WasmBIP32);
347
+ wasm.bitgopsbt_sign_with_xpriv(retptr, this.__wbg_ptr, input_index, xpriv.__wbg_ptr);
329
348
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
330
349
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
331
- var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
332
- if (r2) {
333
- throw takeObject(r1);
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);
334
387
  }
335
- return r0 !== 0;
336
388
  } finally {
337
389
  wasm.__wbindgen_add_to_stack_pointer(16);
338
390
  }
@@ -379,300 +431,1300 @@ class BitGoPsbt {
379
431
  finalize_all_inputs() {
380
432
  try {
381
433
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
382
- wasm.bitgopsbt_finalize_all_inputs(retptr, this.__wbg_ptr);
434
+ wasm.bitgopsbt_finalize_all_inputs(retptr, this.__wbg_ptr);
435
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
436
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
437
+ if (r1) {
438
+ throw takeObject(r0);
439
+ }
440
+ } finally {
441
+ wasm.__wbindgen_add_to_stack_pointer(16);
442
+ }
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
+ }
521
+ /**
522
+ * Verify if a valid signature exists for a given ECPair key at the specified input index
523
+ *
524
+ * This method verifies the signature directly with the provided ECPair's public key. It supports:
525
+ * - ECDSA signatures (for legacy/SegWit inputs)
526
+ * - Schnorr signatures (for Taproot script path inputs)
527
+ *
528
+ * Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
529
+ * Use `verify_signature_with_xpub` for MuSig2 inputs.
530
+ *
531
+ * # Arguments
532
+ * - `input_index`: The index of the input to check
533
+ * - `ecpair`: The ECPair key (uses the public key for verification)
534
+ *
535
+ * # Returns
536
+ * - `Ok(true)` if a valid signature exists for the public key
537
+ * - `Ok(false)` if no signature exists for the public key
538
+ * - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
539
+ * @param {number} input_index
540
+ * @param {WasmECPair} ecpair
541
+ * @returns {boolean}
542
+ */
543
+ verify_signature_with_pub(input_index, ecpair) {
544
+ try {
545
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
546
+ _assertClass(ecpair, WasmECPair);
547
+ wasm.bitgopsbt_verify_signature_with_pub(retptr, this.__wbg_ptr, input_index, ecpair.__wbg_ptr);
548
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
549
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
550
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
551
+ if (r2) {
552
+ throw takeObject(r1);
553
+ }
554
+ return r0 !== 0;
555
+ } finally {
556
+ wasm.__wbindgen_add_to_stack_pointer(16);
557
+ }
558
+ }
559
+ /**
560
+ * Verify if a valid signature exists for a given xpub at the specified input index
561
+ *
562
+ * This method derives the public key from the xpub using the derivation path found in the
563
+ * PSBT input, then verifies the signature. It supports:
564
+ * - ECDSA signatures (for legacy/SegWit inputs)
565
+ * - Schnorr signatures (for Taproot script path inputs)
566
+ * - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
567
+ *
568
+ * # Arguments
569
+ * - `input_index`: The index of the input to check
570
+ * - `xpub`: The extended public key as a WasmBIP32 instance
571
+ *
572
+ * # Returns
573
+ * - `Ok(true)` if a valid signature exists for the derived public key
574
+ * - `Ok(false)` if no signature exists for the derived public key
575
+ * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
576
+ * @param {number} input_index
577
+ * @param {WasmBIP32} xpub
578
+ * @returns {boolean}
579
+ */
580
+ verify_signature_with_xpub(input_index, xpub) {
581
+ try {
582
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
583
+ _assertClass(xpub, WasmBIP32);
584
+ wasm.bitgopsbt_verify_signature_with_xpub(retptr, this.__wbg_ptr, input_index, xpub.__wbg_ptr);
585
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
586
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
587
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
588
+ if (r2) {
589
+ throw takeObject(r1);
590
+ }
591
+ return r0 !== 0;
592
+ } finally {
593
+ wasm.__wbindgen_add_to_stack_pointer(16);
594
+ }
595
+ }
596
+ /**
597
+ * Parse outputs with wallet keys to identify which outputs belong to a wallet
598
+ *
599
+ * Note: This method does NOT validate wallet inputs. It only parses outputs.
600
+ * @param {WasmRootWalletKeys} wallet_keys
601
+ * @returns {any}
602
+ */
603
+ parse_outputs_with_wallet_keys(wallet_keys) {
604
+ try {
605
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
606
+ _assertClass(wallet_keys, WasmRootWalletKeys);
607
+ wasm.bitgopsbt_parse_outputs_with_wallet_keys(retptr, this.__wbg_ptr, wallet_keys.__wbg_ptr);
608
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
609
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
610
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
611
+ if (r2) {
612
+ throw takeObject(r1);
613
+ }
614
+ return takeObject(r0);
615
+ } finally {
616
+ wasm.__wbindgen_add_to_stack_pointer(16);
617
+ }
618
+ }
619
+ /**
620
+ * Parse transaction with wallet keys to identify wallet inputs/outputs
621
+ * @param {WasmRootWalletKeys} wallet_keys
622
+ * @param {WasmReplayProtection} replay_protection
623
+ * @returns {any}
624
+ */
625
+ parse_transaction_with_wallet_keys(wallet_keys, replay_protection) {
626
+ try {
627
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
628
+ _assertClass(wallet_keys, WasmRootWalletKeys);
629
+ _assertClass(replay_protection, WasmReplayProtection);
630
+ wasm.bitgopsbt_parse_transaction_with_wallet_keys(retptr, this.__wbg_ptr, wallet_keys.__wbg_ptr, replay_protection.__wbg_ptr);
631
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
632
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
633
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
634
+ if (r2) {
635
+ throw takeObject(r1);
636
+ }
637
+ return takeObject(r0);
638
+ } finally {
639
+ wasm.__wbindgen_add_to_stack_pointer(16);
640
+ }
641
+ }
642
+ /**
643
+ * Verify if a replay protection input has a valid signature
644
+ *
645
+ * This method checks if a given input is a replay protection input and cryptographically verifies
646
+ * the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
647
+ * so this method verifies signatures without deriving from xpub.
648
+ *
649
+ * # Arguments
650
+ * - `input_index`: The index of the input to check
651
+ * - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
652
+ * Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
653
+ *
654
+ * # Returns
655
+ * - `Ok(true)` if the input is a replay protection input and has a valid signature
656
+ * - `Ok(false)` if the input is a replay protection input but has no valid signature
657
+ * - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
658
+ * @param {number} input_index
659
+ * @param {WasmReplayProtection} replay_protection
660
+ * @returns {boolean}
661
+ */
662
+ verify_replay_protection_signature(input_index, replay_protection) {
663
+ try {
664
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
665
+ _assertClass(replay_protection, WasmReplayProtection);
666
+ wasm.bitgopsbt_verify_replay_protection_signature(retptr, this.__wbg_ptr, input_index, replay_protection.__wbg_ptr);
667
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
668
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
669
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
670
+ if (r2) {
671
+ throw takeObject(r1);
672
+ }
673
+ return r0 !== 0;
674
+ } finally {
675
+ wasm.__wbindgen_add_to_stack_pointer(16);
676
+ }
677
+ }
678
+ /**
679
+ * Get the network of the PSBT
680
+ * @returns {string}
681
+ */
682
+ network() {
683
+ let deferred1_0;
684
+ let deferred1_1;
685
+ try {
686
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
687
+ wasm.bitgopsbt_network(retptr, this.__wbg_ptr);
688
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
689
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
690
+ deferred1_0 = r0;
691
+ deferred1_1 = r1;
692
+ return getStringFromWasm0(r0, r1);
693
+ } finally {
694
+ wasm.__wbindgen_add_to_stack_pointer(16);
695
+ wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
696
+ }
697
+ }
698
+ /**
699
+ * Serialize the PSBT to bytes
700
+ *
701
+ * # Returns
702
+ * The serialized PSBT as a byte array
703
+ * @returns {Uint8Array}
704
+ */
705
+ serialize() {
706
+ try {
707
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
708
+ wasm.bitgopsbt_serialize(retptr, this.__wbg_ptr);
709
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
710
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
711
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
712
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
713
+ if (r3) {
714
+ throw takeObject(r2);
715
+ }
716
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
717
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
718
+ return v1;
719
+ } finally {
720
+ wasm.__wbindgen_add_to_stack_pointer(16);
721
+ }
722
+ }
723
+ }
724
+ if (Symbol.dispose) BitGoPsbt.prototype[Symbol.dispose] = BitGoPsbt.prototype.free;
725
+
726
+ exports.BitGoPsbt = BitGoPsbt;
727
+
728
+ const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
729
+ ? { register: () => {}, unregister: () => {} }
730
+ : new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
731
+
732
+ class FixedScriptWalletNamespace {
733
+
734
+ __destroy_into_raw() {
735
+ const ptr = this.__wbg_ptr;
736
+ this.__wbg_ptr = 0;
737
+ FixedScriptWalletNamespaceFinalization.unregister(this);
738
+ return ptr;
739
+ }
740
+
741
+ free() {
742
+ const ptr = this.__destroy_into_raw();
743
+ wasm.__wbg_fixedscriptwalletnamespace_free(ptr, 0);
744
+ }
745
+ /**
746
+ * @param {WasmRootWalletKeys} keys
747
+ * @param {number} chain
748
+ * @param {number} index
749
+ * @param {any} network
750
+ * @returns {Uint8Array}
751
+ */
752
+ static output_script(keys, chain, index, network) {
753
+ try {
754
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
755
+ _assertClass(keys, WasmRootWalletKeys);
756
+ wasm.fixedscriptwalletnamespace_output_script(retptr, keys.__wbg_ptr, chain, index, addHeapObject(network));
757
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
758
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
759
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
760
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
761
+ if (r3) {
762
+ throw takeObject(r2);
763
+ }
764
+ var v1 = getArrayU8FromWasm0(r0, r1).slice();
765
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
766
+ return v1;
767
+ } finally {
768
+ wasm.__wbindgen_add_to_stack_pointer(16);
769
+ }
770
+ }
771
+ /**
772
+ * @param {WasmRootWalletKeys} keys
773
+ * @param {number} chain
774
+ * @param {number} index
775
+ * @param {any} network
776
+ * @param {string | null} [address_format]
777
+ * @returns {string}
778
+ */
779
+ static address(keys, chain, index, network, address_format) {
780
+ let deferred3_0;
781
+ let deferred3_1;
782
+ try {
783
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
784
+ _assertClass(keys, WasmRootWalletKeys);
785
+ var ptr0 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
786
+ var len0 = WASM_VECTOR_LEN;
787
+ wasm.fixedscriptwalletnamespace_address(retptr, keys.__wbg_ptr, chain, index, addHeapObject(network), ptr0, len0);
788
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
789
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
790
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
791
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
792
+ var ptr2 = r0;
793
+ var len2 = r1;
794
+ if (r3) {
795
+ ptr2 = 0; len2 = 0;
796
+ throw takeObject(r2);
797
+ }
798
+ deferred3_0 = ptr2;
799
+ deferred3_1 = len2;
800
+ return getStringFromWasm0(ptr2, len2);
801
+ } finally {
802
+ wasm.__wbindgen_add_to_stack_pointer(16);
803
+ wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
804
+ }
805
+ }
806
+ }
807
+ if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
808
+
809
+ exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
810
+
811
+ const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
812
+ ? { register: () => {}, unregister: () => {} }
813
+ : new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
814
+
815
+ class UtxolibCompatNamespace {
816
+
817
+ __destroy_into_raw() {
818
+ const ptr = this.__wbg_ptr;
819
+ this.__wbg_ptr = 0;
820
+ UtxolibCompatNamespaceFinalization.unregister(this);
821
+ return ptr;
822
+ }
823
+
824
+ free() {
825
+ const ptr = this.__destroy_into_raw();
826
+ wasm.__wbg_utxolibcompatnamespace_free(ptr, 0);
827
+ }
828
+ /**
829
+ * Convert address string to output script
830
+ *
831
+ * # Arguments
832
+ * * `address` - The address string
833
+ * * `network` - The UtxolibNetwork object from JavaScript
834
+ * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
835
+ * @param {string} address
836
+ * @param {any} network
837
+ * @param {string | null} [format]
838
+ * @returns {Uint8Array}
839
+ */
840
+ static to_output_script(address, network, format) {
841
+ try {
842
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
843
+ const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
844
+ const len0 = WASM_VECTOR_LEN;
845
+ var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
846
+ var len1 = WASM_VECTOR_LEN;
847
+ wasm.utxolibcompatnamespace_to_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
848
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
849
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
850
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
851
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
852
+ if (r3) {
853
+ throw takeObject(r2);
854
+ }
855
+ var v3 = getArrayU8FromWasm0(r0, r1).slice();
856
+ wasm.__wbindgen_export_3(r0, r1 * 1, 1);
857
+ return v3;
858
+ } finally {
859
+ wasm.__wbindgen_add_to_stack_pointer(16);
860
+ }
861
+ }
862
+ /**
863
+ * Convert output script to address string
864
+ *
865
+ * # Arguments
866
+ * * `script` - The output script as a byte array
867
+ * * `network` - The UtxolibNetwork object from JavaScript
868
+ * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
869
+ * @param {Uint8Array} script
870
+ * @param {any} network
871
+ * @param {string | null} [format]
872
+ * @returns {string}
873
+ */
874
+ static from_output_script(script, network, format) {
875
+ let deferred4_0;
876
+ let deferred4_1;
877
+ try {
878
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
879
+ const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
880
+ const len0 = WASM_VECTOR_LEN;
881
+ var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
882
+ var len1 = WASM_VECTOR_LEN;
883
+ wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
884
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
885
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
886
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
887
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
888
+ var ptr3 = r0;
889
+ var len3 = r1;
890
+ if (r3) {
891
+ ptr3 = 0; len3 = 0;
892
+ throw takeObject(r2);
893
+ }
894
+ deferred4_0 = ptr3;
895
+ deferred4_1 = len3;
896
+ return getStringFromWasm0(ptr3, len3);
897
+ } finally {
898
+ wasm.__wbindgen_add_to_stack_pointer(16);
899
+ wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
900
+ }
901
+ }
902
+ }
903
+ if (Symbol.dispose) UtxolibCompatNamespace.prototype[Symbol.dispose] = UtxolibCompatNamespace.prototype.free;
904
+
905
+ exports.UtxolibCompatNamespace = UtxolibCompatNamespace;
906
+
907
+ const WasmBIP32Finalization = (typeof FinalizationRegistry === 'undefined')
908
+ ? { register: () => {}, unregister: () => {} }
909
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmbip32_free(ptr >>> 0, 1));
910
+ /**
911
+ * WASM wrapper for BIP32 extended keys (Xpub/Xpriv)
912
+ * Implements the BIP32Interface TypeScript interface
913
+ */
914
+ class WasmBIP32 {
915
+
916
+ static __wrap(ptr) {
917
+ ptr = ptr >>> 0;
918
+ const obj = Object.create(WasmBIP32.prototype);
919
+ obj.__wbg_ptr = ptr;
920
+ WasmBIP32Finalization.register(obj, obj.__wbg_ptr, obj);
921
+ return obj;
922
+ }
923
+
924
+ __destroy_into_raw() {
925
+ const ptr = this.__wbg_ptr;
926
+ this.__wbg_ptr = 0;
927
+ WasmBIP32Finalization.unregister(this);
928
+ return ptr;
929
+ }
930
+
931
+ free() {
932
+ const ptr = this.__destroy_into_raw();
933
+ wasm.__wbg_wasmbip32_free(ptr, 0);
934
+ }
935
+ /**
936
+ * Get the chain code as a Uint8Array
937
+ * @returns {Uint8Array}
938
+ */
939
+ get chain_code() {
940
+ const ret = wasm.wasmbip32_chain_code(this.__wbg_ptr);
941
+ return takeObject(ret);
942
+ }
943
+ /**
944
+ * Get the identifier as a Uint8Array
945
+ * @returns {Uint8Array}
946
+ */
947
+ get identifier() {
948
+ const ret = wasm.wasmbip32_identifier(this.__wbg_ptr);
949
+ return takeObject(ret);
950
+ }
951
+ /**
952
+ * Get the public key as a Uint8Array
953
+ * @returns {Uint8Array}
954
+ */
955
+ get public_key() {
956
+ const ret = wasm.wasmbip32_public_key(this.__wbg_ptr);
957
+ return takeObject(ret);
958
+ }
959
+ /**
960
+ * Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
961
+ * @param {string} path
962
+ * @returns {WasmBIP32}
963
+ */
964
+ derive_path(path) {
965
+ try {
966
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
967
+ const ptr0 = passStringToWasm0(path, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
968
+ const len0 = WASM_VECTOR_LEN;
969
+ wasm.wasmbip32_derive_path(retptr, this.__wbg_ptr, ptr0, len0);
970
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
971
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
972
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
973
+ if (r2) {
974
+ throw takeObject(r1);
975
+ }
976
+ return WasmBIP32.__wrap(r0);
977
+ } finally {
978
+ wasm.__wbindgen_add_to_stack_pointer(16);
979
+ }
980
+ }
981
+ /**
982
+ * Get the fingerprint as a Uint8Array
983
+ * @returns {Uint8Array}
984
+ */
985
+ get fingerprint() {
986
+ const ret = wasm.wasmbip32_fingerprint(this.__wbg_ptr);
987
+ return takeObject(ret);
988
+ }
989
+ /**
990
+ * Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
991
+ * @param {string} base58_str
992
+ * @returns {WasmBIP32}
993
+ */
994
+ static from_base58(base58_str) {
995
+ try {
996
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
997
+ const ptr0 = passStringToWasm0(base58_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
998
+ const len0 = WASM_VECTOR_LEN;
999
+ wasm.wasmbip32_from_base58(retptr, ptr0, len0);
1000
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1001
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1002
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1003
+ if (r2) {
1004
+ throw takeObject(r1);
1005
+ }
1006
+ return WasmBIP32.__wrap(r0);
1007
+ } finally {
1008
+ wasm.__wbindgen_add_to_stack_pointer(16);
1009
+ }
1010
+ }
1011
+ /**
1012
+ * Check if this is a neutered (public) key
1013
+ * @returns {boolean}
1014
+ */
1015
+ is_neutered() {
1016
+ const ret = wasm.wasmbip32_is_neutered(this.__wbg_ptr);
1017
+ return ret !== 0;
1018
+ }
1019
+ /**
1020
+ * Get the private key as a Uint8Array (if available)
1021
+ * @returns {Uint8Array | undefined}
1022
+ */
1023
+ get private_key() {
1024
+ const ret = wasm.wasmbip32_private_key(this.__wbg_ptr);
1025
+ return takeObject(ret);
1026
+ }
1027
+ /**
1028
+ * Derive a hardened child key (only works for private keys)
1029
+ * @param {number} index
1030
+ * @returns {WasmBIP32}
1031
+ */
1032
+ derive_hardened(index) {
1033
+ try {
1034
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1035
+ wasm.wasmbip32_derive_hardened(retptr, this.__wbg_ptr, index);
1036
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1037
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1038
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1039
+ if (r2) {
1040
+ throw takeObject(r1);
1041
+ }
1042
+ return WasmBIP32.__wrap(r0);
1043
+ } finally {
1044
+ wasm.__wbindgen_add_to_stack_pointer(16);
1045
+ }
1046
+ }
1047
+ /**
1048
+ * Get the parent fingerprint
1049
+ * @returns {number}
1050
+ */
1051
+ get parent_fingerprint() {
1052
+ const ret = wasm.wasmbip32_parent_fingerprint(this.__wbg_ptr);
1053
+ return ret >>> 0;
1054
+ }
1055
+ /**
1056
+ * Create a BIP32 key from a BIP32Interface JavaScript object properties
1057
+ * Expects an object with: network.bip32.public, depth, parentFingerprint,
1058
+ * index, chainCode, and publicKey properties
1059
+ * @param {any} bip32_key
1060
+ * @returns {WasmBIP32}
1061
+ */
1062
+ static from_bip32_interface(bip32_key) {
1063
+ try {
1064
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1065
+ wasm.wasmbip32_from_bip32_interface(retptr, addBorrowedObject(bip32_key));
1066
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1067
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1068
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1069
+ if (r2) {
1070
+ throw takeObject(r1);
1071
+ }
1072
+ return WasmBIP32.__wrap(r0);
1073
+ } finally {
1074
+ wasm.__wbindgen_add_to_stack_pointer(16);
1075
+ heap[stack_pointer++] = undefined;
1076
+ }
1077
+ }
1078
+ /**
1079
+ * Create a BIP32 key from BIP32 properties
1080
+ * Extracts properties from a JavaScript object and constructs an xpub
1081
+ * @param {any} bip32_key
1082
+ * @returns {WasmBIP32}
1083
+ */
1084
+ static from_bip32_properties(bip32_key) {
1085
+ try {
1086
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1087
+ wasm.wasmbip32_from_bip32_interface(retptr, addBorrowedObject(bip32_key));
1088
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1089
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1090
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1091
+ if (r2) {
1092
+ throw takeObject(r1);
1093
+ }
1094
+ return WasmBIP32.__wrap(r0);
1095
+ } finally {
1096
+ wasm.__wbindgen_add_to_stack_pointer(16);
1097
+ heap[stack_pointer++] = undefined;
1098
+ }
1099
+ }
1100
+ /**
1101
+ * Get the depth
1102
+ * @returns {number}
1103
+ */
1104
+ get depth() {
1105
+ const ret = wasm.wasmbip32_depth(this.__wbg_ptr);
1106
+ return ret;
1107
+ }
1108
+ /**
1109
+ * Get the child index
1110
+ * @returns {number}
1111
+ */
1112
+ get index() {
1113
+ const ret = wasm.wasmbip32_index(this.__wbg_ptr);
1114
+ return ret >>> 0;
1115
+ }
1116
+ /**
1117
+ * Derive a normal (non-hardened) child key
1118
+ * @param {number} index
1119
+ * @returns {WasmBIP32}
1120
+ */
1121
+ derive(index) {
1122
+ try {
1123
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1124
+ wasm.wasmbip32_derive(retptr, this.__wbg_ptr, index);
1125
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1126
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1127
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1128
+ if (r2) {
1129
+ throw takeObject(r1);
1130
+ }
1131
+ return WasmBIP32.__wrap(r0);
1132
+ } finally {
1133
+ wasm.__wbindgen_add_to_stack_pointer(16);
1134
+ }
1135
+ }
1136
+ /**
1137
+ * Get the WIF encoding of the private key
1138
+ * @returns {string}
1139
+ */
1140
+ to_wif() {
1141
+ let deferred2_0;
1142
+ let deferred2_1;
1143
+ try {
1144
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1145
+ wasm.wasmbip32_to_wif(retptr, this.__wbg_ptr);
1146
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1147
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1148
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1149
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1150
+ var ptr1 = r0;
1151
+ var len1 = r1;
1152
+ if (r3) {
1153
+ ptr1 = 0; len1 = 0;
1154
+ throw takeObject(r2);
1155
+ }
1156
+ deferred2_0 = ptr1;
1157
+ deferred2_1 = len1;
1158
+ return getStringFromWasm0(ptr1, len1);
1159
+ } finally {
1160
+ wasm.__wbindgen_add_to_stack_pointer(16);
1161
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
1162
+ }
1163
+ }
1164
+ /**
1165
+ * Get the neutered (public) version of this key
1166
+ * @returns {WasmBIP32}
1167
+ */
1168
+ neutered() {
1169
+ const ret = wasm.wasmbip32_neutered(this.__wbg_ptr);
1170
+ return WasmBIP32.__wrap(ret);
1171
+ }
1172
+ /**
1173
+ * Create a BIP32 master key from a seed
1174
+ * @param {Uint8Array} seed
1175
+ * @param {string | null} [network]
1176
+ * @returns {WasmBIP32}
1177
+ */
1178
+ static from_seed(seed, network) {
1179
+ try {
1180
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1181
+ const ptr0 = passArray8ToWasm0(seed, wasm.__wbindgen_export_1);
1182
+ const len0 = WASM_VECTOR_LEN;
1183
+ var ptr1 = isLikeNone(network) ? 0 : passStringToWasm0(network, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1184
+ var len1 = WASM_VECTOR_LEN;
1185
+ wasm.wasmbip32_from_seed(retptr, ptr0, len0, ptr1, len1);
1186
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1187
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1188
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1189
+ if (r2) {
1190
+ throw takeObject(r1);
1191
+ }
1192
+ return WasmBIP32.__wrap(r0);
1193
+ } finally {
1194
+ wasm.__wbindgen_add_to_stack_pointer(16);
1195
+ }
1196
+ }
1197
+ /**
1198
+ * Create a BIP32 key from an xprv string (base58-encoded)
1199
+ * @param {string} xprv_str
1200
+ * @returns {WasmBIP32}
1201
+ */
1202
+ static from_xprv(xprv_str) {
1203
+ try {
1204
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1205
+ const ptr0 = passStringToWasm0(xprv_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1206
+ const len0 = WASM_VECTOR_LEN;
1207
+ wasm.wasmbip32_from_xprv(retptr, ptr0, len0);
1208
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1209
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1210
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1211
+ if (r2) {
1212
+ throw takeObject(r1);
1213
+ }
1214
+ return WasmBIP32.__wrap(r0);
1215
+ } finally {
1216
+ wasm.__wbindgen_add_to_stack_pointer(16);
1217
+ }
1218
+ }
1219
+ /**
1220
+ * Create a BIP32 key from an xpub string (base58-encoded)
1221
+ * @param {string} xpub_str
1222
+ * @returns {WasmBIP32}
1223
+ */
1224
+ static from_xpub(xpub_str) {
1225
+ try {
1226
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1227
+ const ptr0 = passStringToWasm0(xpub_str, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1228
+ const len0 = WASM_VECTOR_LEN;
1229
+ wasm.wasmbip32_from_xpub(retptr, ptr0, len0);
1230
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1231
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1232
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1233
+ if (r2) {
1234
+ throw takeObject(r1);
1235
+ }
1236
+ return WasmBIP32.__wrap(r0);
1237
+ } finally {
1238
+ wasm.__wbindgen_add_to_stack_pointer(16);
1239
+ }
1240
+ }
1241
+ /**
1242
+ * Serialize to base58 string
1243
+ * @returns {string}
1244
+ */
1245
+ to_base58() {
1246
+ let deferred1_0;
1247
+ let deferred1_1;
1248
+ try {
1249
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1250
+ wasm.wasmbip32_to_base58(retptr, this.__wbg_ptr);
1251
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1252
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1253
+ deferred1_0 = r0;
1254
+ deferred1_1 = r1;
1255
+ return getStringFromWasm0(r0, r1);
1256
+ } finally {
1257
+ wasm.__wbindgen_add_to_stack_pointer(16);
1258
+ wasm.__wbindgen_export_3(deferred1_0, deferred1_1, 1);
1259
+ }
1260
+ }
1261
+ }
1262
+ if (Symbol.dispose) WasmBIP32.prototype[Symbol.dispose] = WasmBIP32.prototype.free;
1263
+
1264
+ exports.WasmBIP32 = WasmBIP32;
1265
+
1266
+ const WasmECPairFinalization = (typeof FinalizationRegistry === 'undefined')
1267
+ ? { register: () => {}, unregister: () => {} }
1268
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmecpair_free(ptr >>> 0, 1));
1269
+ /**
1270
+ * WASM wrapper for elliptic curve key pairs (always uses compressed keys)
1271
+ */
1272
+ class WasmECPair {
1273
+
1274
+ static __wrap(ptr) {
1275
+ ptr = ptr >>> 0;
1276
+ const obj = Object.create(WasmECPair.prototype);
1277
+ obj.__wbg_ptr = ptr;
1278
+ WasmECPairFinalization.register(obj, obj.__wbg_ptr, obj);
1279
+ return obj;
1280
+ }
1281
+
1282
+ __destroy_into_raw() {
1283
+ const ptr = this.__wbg_ptr;
1284
+ this.__wbg_ptr = 0;
1285
+ WasmECPairFinalization.unregister(this);
1286
+ return ptr;
1287
+ }
1288
+
1289
+ free() {
1290
+ const ptr = this.__destroy_into_raw();
1291
+ wasm.__wbg_wasmecpair_free(ptr, 0);
1292
+ }
1293
+ /**
1294
+ * Get the compressed public key as a Uint8Array (always 33 bytes)
1295
+ * @returns {Uint8Array}
1296
+ */
1297
+ get public_key() {
1298
+ const ret = wasm.wasmecpair_public_key(this.__wbg_ptr);
1299
+ return takeObject(ret);
1300
+ }
1301
+ /**
1302
+ * Get the private key as a Uint8Array (if available)
1303
+ * @returns {Uint8Array | undefined}
1304
+ */
1305
+ get private_key() {
1306
+ const ret = wasm.wasmecpair_private_key(this.__wbg_ptr);
1307
+ return takeObject(ret);
1308
+ }
1309
+ /**
1310
+ * Convert to mainnet WIF string
1311
+ * @returns {string}
1312
+ */
1313
+ to_wif_mainnet() {
1314
+ let deferred2_0;
1315
+ let deferred2_1;
1316
+ try {
1317
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1318
+ wasm.wasmecpair_to_wif_mainnet(retptr, this.__wbg_ptr);
1319
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1320
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1321
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1322
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1323
+ var ptr1 = r0;
1324
+ var len1 = r1;
1325
+ if (r3) {
1326
+ ptr1 = 0; len1 = 0;
1327
+ throw takeObject(r2);
1328
+ }
1329
+ deferred2_0 = ptr1;
1330
+ deferred2_1 = len1;
1331
+ return getStringFromWasm0(ptr1, len1);
1332
+ } finally {
1333
+ wasm.__wbindgen_add_to_stack_pointer(16);
1334
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
1335
+ }
1336
+ }
1337
+ /**
1338
+ * Convert to testnet WIF string
1339
+ * @returns {string}
1340
+ */
1341
+ to_wif_testnet() {
1342
+ let deferred2_0;
1343
+ let deferred2_1;
1344
+ try {
1345
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1346
+ wasm.wasmecpair_to_wif_testnet(retptr, this.__wbg_ptr);
1347
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1348
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1349
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1350
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1351
+ var ptr1 = r0;
1352
+ var len1 = r1;
1353
+ if (r3) {
1354
+ ptr1 = 0; len1 = 0;
1355
+ throw takeObject(r2);
1356
+ }
1357
+ deferred2_0 = ptr1;
1358
+ deferred2_1 = len1;
1359
+ return getStringFromWasm0(ptr1, len1);
1360
+ } finally {
1361
+ wasm.__wbindgen_add_to_stack_pointer(16);
1362
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
1363
+ }
1364
+ }
1365
+ /**
1366
+ * Create an ECPair from a public key (always uses compressed keys)
1367
+ * @param {Uint8Array} public_key
1368
+ * @returns {WasmECPair}
1369
+ */
1370
+ static from_public_key(public_key) {
1371
+ try {
1372
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1373
+ const ptr0 = passArray8ToWasm0(public_key, wasm.__wbindgen_export_1);
1374
+ const len0 = WASM_VECTOR_LEN;
1375
+ wasm.wasmecpair_from_public_key(retptr, ptr0, len0);
383
1376
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
384
1377
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
385
- if (r1) {
386
- throw takeObject(r0);
1378
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1379
+ if (r2) {
1380
+ throw takeObject(r1);
387
1381
  }
1382
+ return WasmECPair.__wrap(r0);
388
1383
  } finally {
389
1384
  wasm.__wbindgen_add_to_stack_pointer(16);
390
1385
  }
391
1386
  }
392
1387
  /**
393
- * Parse outputs with wallet keys to identify which outputs belong to a wallet
394
- *
395
- * Note: This method does NOT validate wallet inputs. It only parses outputs.
396
- * @param {any} wallet_keys
397
- * @returns {any}
1388
+ * Create an ECPair from a private key (always uses compressed keys)
1389
+ * @param {Uint8Array} private_key
1390
+ * @returns {WasmECPair}
398
1391
  */
399
- parse_outputs_with_wallet_keys(wallet_keys) {
1392
+ static from_private_key(private_key) {
400
1393
  try {
401
1394
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
402
- wasm.bitgopsbt_parse_outputs_with_wallet_keys(retptr, this.__wbg_ptr, addHeapObject(wallet_keys));
1395
+ const ptr0 = passArray8ToWasm0(private_key, wasm.__wbindgen_export_1);
1396
+ const len0 = WASM_VECTOR_LEN;
1397
+ wasm.wasmecpair_from_private_key(retptr, ptr0, len0);
403
1398
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
404
1399
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
405
1400
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
406
1401
  if (r2) {
407
1402
  throw takeObject(r1);
408
1403
  }
409
- return takeObject(r0);
1404
+ return WasmECPair.__wrap(r0);
410
1405
  } finally {
411
1406
  wasm.__wbindgen_add_to_stack_pointer(16);
412
1407
  }
413
1408
  }
414
1409
  /**
415
- * Parse transaction with wallet keys to identify wallet inputs/outputs
416
- * @param {any} wallet_keys
417
- * @param {any} replay_protection
418
- * @returns {any}
1410
+ * Create an ECPair from a mainnet WIF string
1411
+ * @param {string} wif_string
1412
+ * @returns {WasmECPair}
419
1413
  */
420
- parse_transaction_with_wallet_keys(wallet_keys, replay_protection) {
1414
+ static from_wif_mainnet(wif_string) {
421
1415
  try {
422
1416
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
423
- wasm.bitgopsbt_parse_transaction_with_wallet_keys(retptr, this.__wbg_ptr, addHeapObject(wallet_keys), addHeapObject(replay_protection));
1417
+ const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1418
+ const len0 = WASM_VECTOR_LEN;
1419
+ wasm.wasmecpair_from_wif_mainnet(retptr, ptr0, len0);
424
1420
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
425
1421
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
426
1422
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
427
1423
  if (r2) {
428
1424
  throw takeObject(r1);
429
1425
  }
430
- return takeObject(r0);
1426
+ return WasmECPair.__wrap(r0);
431
1427
  } finally {
432
1428
  wasm.__wbindgen_add_to_stack_pointer(16);
433
1429
  }
434
1430
  }
435
1431
  /**
436
- * Verify if a replay protection input has a valid signature
437
- *
438
- * This method checks if a given input is a replay protection input and cryptographically verifies
439
- * the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
440
- * so this method verifies signatures without deriving from xpub.
441
- *
442
- * # Arguments
443
- * - `input_index`: The index of the input to check
444
- * - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
445
- * Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
446
- *
447
- * # Returns
448
- * - `Ok(true)` if the input is a replay protection input and has a valid signature
449
- * - `Ok(false)` if the input is a replay protection input but has no valid signature
450
- * - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
451
- * @param {number} input_index
452
- * @param {any} replay_protection
453
- * @returns {boolean}
1432
+ * Create an ECPair from a testnet WIF string
1433
+ * @param {string} wif_string
1434
+ * @returns {WasmECPair}
454
1435
  */
455
- verify_replay_protection_signature(input_index, replay_protection) {
1436
+ static from_wif_testnet(wif_string) {
456
1437
  try {
457
1438
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
458
- wasm.bitgopsbt_verify_replay_protection_signature(retptr, this.__wbg_ptr, input_index, addHeapObject(replay_protection));
1439
+ const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1440
+ const len0 = WASM_VECTOR_LEN;
1441
+ wasm.wasmecpair_from_wif_testnet(retptr, ptr0, len0);
459
1442
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
460
1443
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
461
1444
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
462
1445
  if (r2) {
463
1446
  throw takeObject(r1);
464
1447
  }
465
- return r0 !== 0;
1448
+ return WasmECPair.__wrap(r0);
466
1449
  } finally {
467
1450
  wasm.__wbindgen_add_to_stack_pointer(16);
468
1451
  }
469
1452
  }
470
1453
  /**
471
- * Serialize the PSBT to bytes
472
- *
473
- * # Returns
474
- * The serialized PSBT as a byte array
475
- * @returns {Uint8Array}
1454
+ * Convert to WIF string (mainnet)
1455
+ * @returns {string}
476
1456
  */
477
- serialize() {
1457
+ to_wif() {
1458
+ let deferred2_0;
1459
+ let deferred2_1;
478
1460
  try {
479
1461
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
480
- wasm.bitgopsbt_serialize(retptr, this.__wbg_ptr);
1462
+ wasm.wasmecpair_to_wif(retptr, this.__wbg_ptr);
481
1463
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
482
1464
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
483
1465
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
484
1466
  var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
1467
+ var ptr1 = r0;
1468
+ var len1 = r1;
485
1469
  if (r3) {
1470
+ ptr1 = 0; len1 = 0;
486
1471
  throw takeObject(r2);
487
1472
  }
488
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
489
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
490
- return v1;
1473
+ deferred2_0 = ptr1;
1474
+ deferred2_1 = len1;
1475
+ return getStringFromWasm0(ptr1, len1);
1476
+ } finally {
1477
+ wasm.__wbindgen_add_to_stack_pointer(16);
1478
+ wasm.__wbindgen_export_3(deferred2_0, deferred2_1, 1);
1479
+ }
1480
+ }
1481
+ /**
1482
+ * Create an ECPair from a WIF string (auto-detects network)
1483
+ * @param {string} wif_string
1484
+ * @returns {WasmECPair}
1485
+ */
1486
+ static from_wif(wif_string) {
1487
+ try {
1488
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1489
+ const ptr0 = passStringToWasm0(wif_string, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1490
+ const len0 = WASM_VECTOR_LEN;
1491
+ wasm.wasmecpair_from_wif(retptr, ptr0, len0);
1492
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1493
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1494
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1495
+ if (r2) {
1496
+ throw takeObject(r1);
1497
+ }
1498
+ return WasmECPair.__wrap(r0);
491
1499
  } finally {
492
1500
  wasm.__wbindgen_add_to_stack_pointer(16);
493
1501
  }
494
1502
  }
495
1503
  }
496
- if (Symbol.dispose) BitGoPsbt.prototype[Symbol.dispose] = BitGoPsbt.prototype.free;
1504
+ if (Symbol.dispose) WasmECPair.prototype[Symbol.dispose] = WasmECPair.prototype.free;
497
1505
 
498
- exports.BitGoPsbt = BitGoPsbt;
1506
+ exports.WasmECPair = WasmECPair;
499
1507
 
500
- const FixedScriptWalletNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
1508
+ const WasmReplayProtectionFinalization = (typeof FinalizationRegistry === 'undefined')
501
1509
  ? { register: () => {}, unregister: () => {} }
502
- : new FinalizationRegistry(ptr => wasm.__wbg_fixedscriptwalletnamespace_free(ptr >>> 0, 1));
1510
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmreplayprotection_free(ptr >>> 0, 1));
1511
+ /**
1512
+ * WASM wrapper for ReplayProtection
1513
+ */
1514
+ class WasmReplayProtection {
503
1515
 
504
- class FixedScriptWalletNamespace {
1516
+ static __wrap(ptr) {
1517
+ ptr = ptr >>> 0;
1518
+ const obj = Object.create(WasmReplayProtection.prototype);
1519
+ obj.__wbg_ptr = ptr;
1520
+ WasmReplayProtectionFinalization.register(obj, obj.__wbg_ptr, obj);
1521
+ return obj;
1522
+ }
505
1523
 
506
1524
  __destroy_into_raw() {
507
1525
  const ptr = this.__wbg_ptr;
508
1526
  this.__wbg_ptr = 0;
509
- FixedScriptWalletNamespaceFinalization.unregister(this);
1527
+ WasmReplayProtectionFinalization.unregister(this);
510
1528
  return ptr;
511
1529
  }
512
1530
 
513
1531
  free() {
514
1532
  const ptr = this.__destroy_into_raw();
515
- wasm.__wbg_fixedscriptwalletnamespace_free(ptr, 0);
1533
+ wasm.__wbg_wasmreplayprotection_free(ptr, 0);
516
1534
  }
517
1535
  /**
518
- * @param {any} keys
519
- * @param {number} chain
520
- * @param {number} index
521
- * @param {any} network
522
- * @returns {Uint8Array}
1536
+ * Create from addresses (requires network for decoding)
1537
+ * @param {any[]} addresses
1538
+ * @param {string} network
1539
+ * @returns {WasmReplayProtection}
523
1540
  */
524
- static output_script(keys, chain, index, network) {
1541
+ static from_addresses(addresses, network) {
525
1542
  try {
526
1543
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
527
- wasm.fixedscriptwalletnamespace_output_script(retptr, addHeapObject(keys), chain, index, addHeapObject(network));
1544
+ const ptr0 = passArrayJsValueToWasm0(addresses, wasm.__wbindgen_export_1);
1545
+ const len0 = WASM_VECTOR_LEN;
1546
+ const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1547
+ const len1 = WASM_VECTOR_LEN;
1548
+ wasm.wasmreplayprotection_from_addresses(retptr, ptr0, len0, ptr1, len1);
528
1549
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
529
1550
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
530
1551
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
531
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
532
- if (r3) {
533
- throw takeObject(r2);
1552
+ if (r2) {
1553
+ throw takeObject(r1);
534
1554
  }
535
- var v1 = getArrayU8FromWasm0(r0, r1).slice();
536
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
537
- return v1;
1555
+ return WasmReplayProtection.__wrap(r0);
538
1556
  } finally {
539
1557
  wasm.__wbindgen_add_to_stack_pointer(16);
540
1558
  }
541
1559
  }
542
1560
  /**
543
- * @param {any} keys
544
- * @param {number} chain
545
- * @param {number} index
546
- * @param {any} network
547
- * @param {string | null} [address_format]
548
- * @returns {string}
1561
+ * Create from public keys (derives P2SH-P2PK output scripts)
1562
+ * @param {Uint8Array[]} public_keys
1563
+ * @returns {WasmReplayProtection}
549
1564
  */
550
- static address(keys, chain, index, network, address_format) {
551
- let deferred3_0;
552
- let deferred3_1;
1565
+ static from_public_keys(public_keys) {
553
1566
  try {
554
1567
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
555
- var ptr0 = isLikeNone(address_format) ? 0 : passStringToWasm0(address_format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
556
- var len0 = WASM_VECTOR_LEN;
557
- wasm.fixedscriptwalletnamespace_address(retptr, addHeapObject(keys), chain, index, addHeapObject(network), ptr0, len0);
1568
+ const ptr0 = passArrayJsValueToWasm0(public_keys, wasm.__wbindgen_export_1);
1569
+ const len0 = WASM_VECTOR_LEN;
1570
+ wasm.wasmreplayprotection_from_public_keys(retptr, ptr0, len0);
558
1571
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
559
1572
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
560
1573
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
561
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
562
- var ptr2 = r0;
563
- var len2 = r1;
564
- if (r3) {
565
- ptr2 = 0; len2 = 0;
566
- throw takeObject(r2);
1574
+ if (r2) {
1575
+ throw takeObject(r1);
567
1576
  }
568
- deferred3_0 = ptr2;
569
- deferred3_1 = len2;
570
- return getStringFromWasm0(ptr2, len2);
1577
+ return WasmReplayProtection.__wrap(r0);
571
1578
  } finally {
572
1579
  wasm.__wbindgen_add_to_stack_pointer(16);
573
- wasm.__wbindgen_export_3(deferred3_0, deferred3_1, 1);
574
1580
  }
575
1581
  }
1582
+ /**
1583
+ * Create from output scripts directly
1584
+ * @param {Uint8Array[]} output_scripts
1585
+ * @returns {WasmReplayProtection}
1586
+ */
1587
+ static from_output_scripts(output_scripts) {
1588
+ const ptr0 = passArrayJsValueToWasm0(output_scripts, wasm.__wbindgen_export_1);
1589
+ const len0 = WASM_VECTOR_LEN;
1590
+ const ret = wasm.wasmreplayprotection_from_output_scripts(ptr0, len0);
1591
+ return WasmReplayProtection.__wrap(ret);
1592
+ }
576
1593
  }
577
- if (Symbol.dispose) FixedScriptWalletNamespace.prototype[Symbol.dispose] = FixedScriptWalletNamespace.prototype.free;
1594
+ if (Symbol.dispose) WasmReplayProtection.prototype[Symbol.dispose] = WasmReplayProtection.prototype.free;
578
1595
 
579
- exports.FixedScriptWalletNamespace = FixedScriptWalletNamespace;
1596
+ exports.WasmReplayProtection = WasmReplayProtection;
580
1597
 
581
- const UtxolibCompatNamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
1598
+ const WasmRootWalletKeysFinalization = (typeof FinalizationRegistry === 'undefined')
582
1599
  ? { register: () => {}, unregister: () => {} }
583
- : new FinalizationRegistry(ptr => wasm.__wbg_utxolibcompatnamespace_free(ptr >>> 0, 1));
1600
+ : new FinalizationRegistry(ptr => wasm.__wbg_wasmrootwalletkeys_free(ptr >>> 0, 1));
1601
+ /**
1602
+ * WASM wrapper for RootWalletKeys
1603
+ * Represents a set of three extended public keys with their derivation prefixes
1604
+ */
1605
+ class WasmRootWalletKeys {
584
1606
 
585
- class UtxolibCompatNamespace {
1607
+ static __wrap(ptr) {
1608
+ ptr = ptr >>> 0;
1609
+ const obj = Object.create(WasmRootWalletKeys.prototype);
1610
+ obj.__wbg_ptr = ptr;
1611
+ WasmRootWalletKeysFinalization.register(obj, obj.__wbg_ptr, obj);
1612
+ return obj;
1613
+ }
586
1614
 
587
1615
  __destroy_into_raw() {
588
1616
  const ptr = this.__wbg_ptr;
589
1617
  this.__wbg_ptr = 0;
590
- UtxolibCompatNamespaceFinalization.unregister(this);
1618
+ WasmRootWalletKeysFinalization.unregister(this);
591
1619
  return ptr;
592
1620
  }
593
1621
 
594
1622
  free() {
595
1623
  const ptr = this.__destroy_into_raw();
596
- wasm.__wbg_utxolibcompatnamespace_free(ptr, 0);
1624
+ wasm.__wbg_wasmrootwalletkeys_free(ptr, 0);
597
1625
  }
598
1626
  /**
599
- * Convert address string to output script
1627
+ * Get the backup key (second xpub)
1628
+ * @returns {WasmBIP32}
1629
+ */
1630
+ backup_key() {
1631
+ const ret = wasm.wasmrootwalletkeys_backup_key(this.__wbg_ptr);
1632
+ return WasmBIP32.__wrap(ret);
1633
+ }
1634
+ /**
1635
+ * Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
600
1636
  *
601
1637
  * # Arguments
602
- * * `address` - The address string
603
- * * `network` - The UtxolibNetwork object from JavaScript
604
- * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
605
- * @param {string} address
606
- * @param {any} network
607
- * @param {string | null} [format]
608
- * @returns {Uint8Array}
1638
+ * - `user`: User key (first xpub)
1639
+ * - `backup`: Backup key (second xpub)
1640
+ * - `bitgo`: BitGo key (third xpub)
1641
+ * - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
1642
+ * - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
1643
+ * - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
1644
+ * @param {WasmBIP32} user
1645
+ * @param {WasmBIP32} backup
1646
+ * @param {WasmBIP32} bitgo
1647
+ * @param {string} user_derivation
1648
+ * @param {string} backup_derivation
1649
+ * @param {string} bitgo_derivation
1650
+ * @returns {WasmRootWalletKeys}
609
1651
  */
610
- static to_output_script(address, network, format) {
1652
+ static with_derivation_prefixes(user, backup, bitgo, user_derivation, backup_derivation, bitgo_derivation) {
611
1653
  try {
612
1654
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
613
- const ptr0 = passStringToWasm0(address, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1655
+ _assertClass(user, WasmBIP32);
1656
+ _assertClass(backup, WasmBIP32);
1657
+ _assertClass(bitgo, WasmBIP32);
1658
+ const ptr0 = passStringToWasm0(user_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
614
1659
  const len0 = WASM_VECTOR_LEN;
615
- var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
616
- var len1 = WASM_VECTOR_LEN;
617
- wasm.utxolibcompatnamespace_to_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
1660
+ const ptr1 = passStringToWasm0(backup_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1661
+ const len1 = WASM_VECTOR_LEN;
1662
+ const ptr2 = passStringToWasm0(bitgo_derivation, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
1663
+ const len2 = WASM_VECTOR_LEN;
1664
+ wasm.wasmrootwalletkeys_with_derivation_prefixes(retptr, user.__wbg_ptr, backup.__wbg_ptr, bitgo.__wbg_ptr, ptr0, len0, ptr1, len1, ptr2, len2);
618
1665
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
619
1666
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
620
1667
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
621
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
622
- if (r3) {
623
- throw takeObject(r2);
1668
+ if (r2) {
1669
+ throw takeObject(r1);
624
1670
  }
625
- var v3 = getArrayU8FromWasm0(r0, r1).slice();
626
- wasm.__wbindgen_export_3(r0, r1 * 1, 1);
627
- return v3;
1671
+ return WasmRootWalletKeys.__wrap(r0);
628
1672
  } finally {
629
1673
  wasm.__wbindgen_add_to_stack_pointer(16);
630
1674
  }
631
1675
  }
632
1676
  /**
633
- * Convert output script to address string
1677
+ * Create a RootWalletKeys from three BIP32 keys
1678
+ * Uses default derivation prefix of m/0/0 for all three keys
634
1679
  *
635
1680
  * # Arguments
636
- * * `script` - The output script as a byte array
637
- * * `network` - The UtxolibNetwork object from JavaScript
638
- * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
639
- * @param {Uint8Array} script
640
- * @param {any} network
641
- * @param {string | null} [format]
642
- * @returns {string}
1681
+ * - `user`: User key (first xpub)
1682
+ * - `backup`: Backup key (second xpub)
1683
+ * - `bitgo`: BitGo key (third xpub)
1684
+ * @param {WasmBIP32} user
1685
+ * @param {WasmBIP32} backup
1686
+ * @param {WasmBIP32} bitgo
643
1687
  */
644
- static from_output_script(script, network, format) {
645
- let deferred4_0;
646
- let deferred4_1;
1688
+ constructor(user, backup, bitgo) {
647
1689
  try {
648
1690
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
649
- const ptr0 = passArray8ToWasm0(script, wasm.__wbindgen_export_1);
650
- const len0 = WASM_VECTOR_LEN;
651
- var ptr1 = isLikeNone(format) ? 0 : passStringToWasm0(format, wasm.__wbindgen_export_1, wasm.__wbindgen_export_2);
652
- var len1 = WASM_VECTOR_LEN;
653
- wasm.utxolibcompatnamespace_from_output_script(retptr, ptr0, len0, addHeapObject(network), ptr1, len1);
1691
+ _assertClass(user, WasmBIP32);
1692
+ _assertClass(backup, WasmBIP32);
1693
+ _assertClass(bitgo, WasmBIP32);
1694
+ wasm.wasmrootwalletkeys_new(retptr, user.__wbg_ptr, backup.__wbg_ptr, bitgo.__wbg_ptr);
654
1695
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
655
1696
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
656
1697
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
657
- var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
658
- var ptr3 = r0;
659
- var len3 = r1;
660
- if (r3) {
661
- ptr3 = 0; len3 = 0;
662
- throw takeObject(r2);
1698
+ if (r2) {
1699
+ throw takeObject(r1);
663
1700
  }
664
- deferred4_0 = ptr3;
665
- deferred4_1 = len3;
666
- return getStringFromWasm0(ptr3, len3);
1701
+ this.__wbg_ptr = r0 >>> 0;
1702
+ WasmRootWalletKeysFinalization.register(this, this.__wbg_ptr, this);
1703
+ return this;
667
1704
  } finally {
668
1705
  wasm.__wbindgen_add_to_stack_pointer(16);
669
- wasm.__wbindgen_export_3(deferred4_0, deferred4_1, 1);
670
1706
  }
671
1707
  }
1708
+ /**
1709
+ * Get the user key (first xpub)
1710
+ * @returns {WasmBIP32}
1711
+ */
1712
+ user_key() {
1713
+ const ret = wasm.wasmrootwalletkeys_user_key(this.__wbg_ptr);
1714
+ return WasmBIP32.__wrap(ret);
1715
+ }
1716
+ /**
1717
+ * Get the bitgo key (third xpub)
1718
+ * @returns {WasmBIP32}
1719
+ */
1720
+ bitgo_key() {
1721
+ const ret = wasm.wasmrootwalletkeys_bitgo_key(this.__wbg_ptr);
1722
+ return WasmBIP32.__wrap(ret);
1723
+ }
672
1724
  }
673
- if (Symbol.dispose) UtxolibCompatNamespace.prototype[Symbol.dispose] = UtxolibCompatNamespace.prototype.free;
1725
+ if (Symbol.dispose) WasmRootWalletKeys.prototype[Symbol.dispose] = WasmRootWalletKeys.prototype.free;
674
1726
 
675
- exports.UtxolibCompatNamespace = UtxolibCompatNamespace;
1727
+ exports.WasmRootWalletKeys = WasmRootWalletKeys;
676
1728
 
677
1729
  const WrapDescriptorFinalization = (typeof FinalizationRegistry === 'undefined')
678
1730
  ? { register: () => {}, unregister: () => {} }
@@ -1296,45 +2348,33 @@ exports.__wbg_call_13410aac570ffff7 = function() { return handleError(function (
1296
2348
  return addHeapObject(ret);
1297
2349
  }, arguments) };
1298
2350
 
1299
- exports.__wbg_from_88bc52ce20ba6318 = function(arg0) {
1300
- const ret = Array.from(getObject(arg0));
2351
+ exports.__wbg_call_a5400b25a865cfd8 = function() { return handleError(function (arg0, arg1, arg2) {
2352
+ const ret = getObject(arg0).call(getObject(arg1), getObject(arg2));
1301
2353
  return addHeapObject(ret);
1302
- };
2354
+ }, arguments) };
1303
2355
 
1304
- exports.__wbg_get_0da715ceaecea5c8 = function(arg0, arg1) {
1305
- const ret = getObject(arg0)[arg1 >>> 0];
2356
+ exports.__wbg_crypto_574e78ad8b13b65f = function(arg0) {
2357
+ const ret = getObject(arg0).crypto;
1306
2358
  return addHeapObject(ret);
1307
2359
  };
1308
2360
 
2361
+ exports.__wbg_getRandomValues_b8f5dbd5f3995a9e = function() { return handleError(function (arg0, arg1) {
2362
+ getObject(arg0).getRandomValues(getObject(arg1));
2363
+ }, arguments) };
2364
+
1309
2365
  exports.__wbg_get_458e874b43b18b25 = function() { return handleError(function (arg0, arg1) {
1310
2366
  const ret = Reflect.get(getObject(arg0), getObject(arg1));
1311
2367
  return addHeapObject(ret);
1312
2368
  }, arguments) };
1313
2369
 
1314
- exports.__wbg_instanceof_Uint8Array_9a8378d955933db7 = function(arg0) {
1315
- let result;
1316
- try {
1317
- result = getObject(arg0) instanceof Uint8Array;
1318
- } catch (_) {
1319
- result = false;
1320
- }
1321
- const ret = result;
1322
- return ret;
1323
- };
1324
-
1325
- exports.__wbg_isArray_030cce220591fb41 = function(arg0) {
1326
- const ret = Array.isArray(getObject(arg0));
1327
- return ret;
1328
- };
1329
-
1330
- exports.__wbg_length_186546c51cd61acd = function(arg0) {
2370
+ exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
1331
2371
  const ret = getObject(arg0).length;
1332
2372
  return ret;
1333
2373
  };
1334
2374
 
1335
- exports.__wbg_length_6bb7e81f9d7713e4 = function(arg0) {
1336
- const ret = getObject(arg0).length;
1337
- return ret;
2375
+ exports.__wbg_msCrypto_a61aeb35a24c1329 = function(arg0) {
2376
+ const ret = getObject(arg0).msCrypto;
2377
+ return addHeapObject(ret);
1338
2378
  };
1339
2379
 
1340
2380
  exports.__wbg_new_19c25a3f2fa63a02 = function() {
@@ -1362,6 +2402,26 @@ exports.__wbg_newfromslice_074c56947bd43469 = function(arg0, arg1) {
1362
2402
  return addHeapObject(ret);
1363
2403
  };
1364
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
+
1365
2425
  exports.__wbg_prototypesetcall_3d4a26c1ed734349 = function(arg0, arg1, arg2) {
1366
2426
  Uint8Array.prototype.set.call(getArrayU8FromWasm0(arg0, arg1), getObject(arg2));
1367
2427
  };
@@ -1371,11 +2431,50 @@ exports.__wbg_push_330b2eb93e4e1212 = function(arg0, arg1) {
1371
2431
  return ret;
1372
2432
  };
1373
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
+
1374
2443
  exports.__wbg_set_453345bcda80b89a = function() { return handleError(function (arg0, arg1, arg2) {
1375
2444
  const ret = Reflect.set(getObject(arg0), getObject(arg1), getObject(arg2));
1376
2445
  return ret;
1377
2446
  }, arguments) };
1378
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
+
1379
2478
  exports.__wbg_wbindgenisfunction_8cee7dce3725ae74 = function(arg0) {
1380
2479
  const ret = typeof(getObject(arg0)) === 'function';
1381
2480
  return ret;
@@ -1392,6 +2491,11 @@ exports.__wbg_wbindgenisobject_307a53c6bd97fbf8 = function(arg0) {
1392
2491
  return ret;
1393
2492
  };
1394
2493
 
2494
+ exports.__wbg_wbindgenisstring_d4fa939789f003b0 = function(arg0) {
2495
+ const ret = typeof(getObject(arg0)) === 'string';
2496
+ return ret;
2497
+ };
2498
+
1395
2499
  exports.__wbg_wbindgenisundefined_c4b71d073b92f3c5 = function(arg0) {
1396
2500
  const ret = getObject(arg0) === undefined;
1397
2501
  return ret;
@@ -1429,6 +2533,12 @@ exports.__wbindgen_cast_4625c577ab2ec9ee = function(arg0) {
1429
2533
  return addHeapObject(ret);
1430
2534
  };
1431
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
+
1432
2542
  exports.__wbindgen_cast_d6cd19b81560fd6e = function(arg0) {
1433
2543
  // Cast intrinsic for `F64 -> Externref`.
1434
2544
  const ret = arg0;