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