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