@bitgo/wasm-utxo 1.21.0 → 1.23.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.
@@ -4,6 +4,7 @@ export { ReplayProtection, type ReplayProtectionArg } from "./ReplayProtection.j
4
4
  export { outputScript, address } from "./address.js";
5
5
  export { Dimensions } from "./Dimensions.js";
6
6
  export { type OutputScriptType, type InputScriptType, type ScriptType } from "./scriptType.js";
7
+ export { ChainCode, chainCodes, type Scope } from "./chains.js";
7
8
  export { BitGoPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, } from "./BitGoPsbt.js";
8
9
  export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
9
10
  import type { ScriptType } from "./scriptType.js";
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
3
+ exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.chainCodes = exports.ChainCode = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
4
4
  exports.supportsScriptType = supportsScriptType;
5
5
  const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
6
6
  var RootWalletKeys_js_1 = require("./RootWalletKeys.js");
@@ -12,6 +12,9 @@ Object.defineProperty(exports, "outputScript", { enumerable: true, get: function
12
12
  Object.defineProperty(exports, "address", { enumerable: true, get: function () { return address_js_1.address; } });
13
13
  var Dimensions_js_1 = require("./Dimensions.js");
14
14
  Object.defineProperty(exports, "Dimensions", { enumerable: true, get: function () { return Dimensions_js_1.Dimensions; } });
15
+ var chains_js_1 = require("./chains.js");
16
+ Object.defineProperty(exports, "ChainCode", { enumerable: true, get: function () { return chains_js_1.ChainCode; } });
17
+ Object.defineProperty(exports, "chainCodes", { enumerable: true, get: function () { return chains_js_1.chainCodes; } });
15
18
  // Bitcoin-like PSBT (for all non-Zcash networks)
16
19
  var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
17
20
  Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
@@ -1,5 +1,6 @@
1
1
  export * as address from "./address.js";
2
2
  export * as ast from "./ast/index.js";
3
+ export * as bip322 from "./bip322/index.js";
3
4
  export * as utxolibCompat from "./utxolibCompat.js";
4
5
  export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
5
6
  export * as bip32 from "./bip32.js";
@@ -33,7 +33,7 @@ var __importStar = (this && this.__importStar) || (function () {
33
33
  };
34
34
  })();
35
35
  Object.defineProperty(exports, "__esModule", { value: true });
36
- exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.ast = exports.address = void 0;
36
+ exports.ZcashTransaction = exports.Transaction = exports.DashTransaction = exports.Psbt = exports.Miniscript = exports.Descriptor = exports.Dimensions = exports.BIP32 = exports.ECPair = exports.ecpair = exports.bip32 = exports.fixedScriptWallet = exports.utxolibCompat = exports.bip322 = exports.ast = exports.address = void 0;
37
37
  const wasm = __importStar(require("./wasm/wasm_utxo.js"));
38
38
  // we need to access the wasm module here, otherwise webpack gets all weird
39
39
  // and forgets to include it in the bundle
@@ -42,6 +42,7 @@ void wasm;
42
42
  // and to make imports more explicit (e.g., `import { address } from '@bitgo/wasm-utxo'`)
43
43
  exports.address = __importStar(require("./address.js"));
44
44
  exports.ast = __importStar(require("./ast/index.js"));
45
+ exports.bip322 = __importStar(require("./bip322/index.js"));
45
46
  exports.utxolibCompat = __importStar(require("./utxolibCompat.js"));
46
47
  exports.fixedScriptWallet = __importStar(require("./fixedScriptWallet/index.js"));
47
48
  exports.bip32 = __importStar(require("./bip32.js"));
@@ -9,6 +9,106 @@ export class AddressNamespace {
9
9
  static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
10
10
  }
11
11
 
12
+ export class Bip322Namespace {
13
+ private constructor();
14
+ free(): void;
15
+ [Symbol.dispose](): void;
16
+ /**
17
+ * Add a BIP-0322 message input to an existing BitGoPsbt
18
+ *
19
+ * If this is the first input, also adds the OP_RETURN output.
20
+ * The PSBT must have version 0 per BIP-0322 specification.
21
+ *
22
+ * # Arguments
23
+ * * `psbt` - The BitGoPsbt to add the input to
24
+ * * `message` - The message to sign
25
+ * * `chain` - The wallet chain (e.g., 10 for external, 20 for internal)
26
+ * * `index` - The address index
27
+ * * `wallet_keys` - The wallet's root keys
28
+ * * `signer` - Optional signer key name for taproot (e.g., "user", "backup", "bitgo")
29
+ * * `cosigner` - Optional cosigner key name for taproot
30
+ * * `tag` - Optional custom tag for message hashing
31
+ *
32
+ * # Returns
33
+ * The index of the added input
34
+ */
35
+ static add_bip322_input(psbt: BitGoPsbt, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, signer?: string | null, cosigner?: string | null, tag?: string | null): number;
36
+ /**
37
+ * Verify a single input of a BIP-0322 transaction proof
38
+ *
39
+ * # Arguments
40
+ * * `tx` - The signed transaction
41
+ * * `input_index` - The index of the input to verify
42
+ * * `message` - The message that was signed
43
+ * * `chain` - The wallet chain
44
+ * * `index` - The address index
45
+ * * `wallet_keys` - The wallet's root keys
46
+ * * `network` - Network name
47
+ * * `tag` - Optional custom tag for message hashing
48
+ *
49
+ * # Throws
50
+ * Throws an error if verification fails
51
+ */
52
+ static verify_bip322_tx_input(tx: WasmTransaction, input_index: number, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, network: string, tag?: string | null): void;
53
+ /**
54
+ * Verify a single input of a BIP-0322 PSBT proof
55
+ *
56
+ * # Arguments
57
+ * * `psbt` - The signed BitGoPsbt
58
+ * * `input_index` - The index of the input to verify
59
+ * * `message` - The message that was signed
60
+ * * `chain` - The wallet chain
61
+ * * `index` - The address index
62
+ * * `wallet_keys` - The wallet's root keys
63
+ * * `tag` - Optional custom tag for message hashing
64
+ *
65
+ * # Returns
66
+ * An array of signer names ("user", "backup", "bitgo") that have valid signatures
67
+ *
68
+ * # Throws
69
+ * Throws an error if verification fails or no valid signatures found
70
+ */
71
+ static verify_bip322_psbt_input(psbt: BitGoPsbt, input_index: number, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, tag?: string | null): string[];
72
+ /**
73
+ * Verify a single input of a BIP-0322 transaction proof using pubkeys directly
74
+ *
75
+ * # Arguments
76
+ * * `tx` - The signed transaction
77
+ * * `input_index` - The index of the input to verify
78
+ * * `message` - The message that was signed
79
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
80
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
81
+ * * `is_script_path` - For taproot types, whether script path was used
82
+ * * `tag` - Optional custom tag for message hashing
83
+ *
84
+ * # Returns
85
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
86
+ *
87
+ * # Throws
88
+ * Throws an error if verification fails
89
+ */
90
+ static verify_bip322_tx_input_with_pubkeys(tx: WasmTransaction, input_index: number, message: string, pubkeys: string[], script_type: string, is_script_path?: boolean | null, tag?: string | null): Uint32Array;
91
+ /**
92
+ * Verify a single input of a BIP-0322 PSBT proof using pubkeys directly
93
+ *
94
+ * # Arguments
95
+ * * `psbt` - The signed BitGoPsbt
96
+ * * `input_index` - The index of the input to verify
97
+ * * `message` - The message that was signed
98
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
99
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
100
+ * * `is_script_path` - For taproot types, whether script path was used
101
+ * * `tag` - Optional custom tag for message hashing
102
+ *
103
+ * # Returns
104
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
105
+ *
106
+ * # Throws
107
+ * Throws an error if verification fails or no valid signatures found
108
+ */
109
+ static verify_bip322_psbt_input_with_pubkeys(psbt: BitGoPsbt, input_index: number, message: string, pubkeys: string[], script_type: string, is_script_path?: boolean | null, tag?: string | null): Uint32Array;
110
+ }
111
+
12
112
  export class BitGoPsbt {
13
113
  private constructor();
14
114
  free(): void;
@@ -379,6 +479,15 @@ export class FixedScriptWalletNamespace {
379
479
  free(): void;
380
480
  [Symbol.dispose](): void;
381
481
  static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
482
+ /**
483
+ * Get all chain code metadata for building TypeScript lookup tables
484
+ *
485
+ * Returns an array of [chainCode, scriptType, scope] tuples where:
486
+ * - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
487
+ * - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
488
+ * - scope: string ("external" or "internal")
489
+ */
490
+ static chain_code_table(): any;
382
491
  /**
383
492
  * Check if a network supports a given fixed-script wallet script type
384
493
  *
@@ -553,6 +662,28 @@ export class WasmDimensions {
553
662
  * Whether any inputs are segwit (affects overhead calculation)
554
663
  */
555
664
  has_segwit(): boolean;
665
+ /**
666
+ * Get input virtual size (min or max)
667
+ *
668
+ * # Arguments
669
+ * * `size` - "min" or "max", defaults to "max"
670
+ */
671
+ get_input_vsize(size?: string | null): number;
672
+ /**
673
+ * Get input weight only (min or max)
674
+ *
675
+ * # Arguments
676
+ * * `size` - "min" or "max", defaults to "max"
677
+ */
678
+ get_input_weight(size?: string | null): number;
679
+ /**
680
+ * Get output virtual size
681
+ */
682
+ get_output_vsize(): number;
683
+ /**
684
+ * Get output weight
685
+ */
686
+ get_output_weight(): number;
556
687
  /**
557
688
  * Create dimensions for a single output from script bytes
558
689
  */
@@ -573,6 +704,10 @@ export class WasmDimensions {
573
704
  * Create empty dimensions (zero weight)
574
705
  */
575
706
  static empty(): WasmDimensions;
707
+ /**
708
+ * Multiply dimensions by a scalar
709
+ */
710
+ times(n: number): WasmDimensions;
576
711
  /**
577
712
  * Create dimensions from a BitGoPsbt
578
713
  *
@@ -29,6 +29,21 @@ function dropObject(idx) {
29
29
  heap_next = idx;
30
30
  }
31
31
 
32
+ function getArrayJsValueFromWasm0(ptr, len) {
33
+ ptr = ptr >>> 0;
34
+ const mem = getDataViewMemory0();
35
+ const result = [];
36
+ for (let i = ptr; i < ptr + 4 * len; i += 4) {
37
+ result.push(takeObject(mem.getUint32(i, true)));
38
+ }
39
+ return result;
40
+ }
41
+
42
+ function getArrayU32FromWasm0(ptr, len) {
43
+ ptr = ptr >>> 0;
44
+ return getUint32ArrayMemory0().subarray(ptr / 4, ptr / 4 + len);
45
+ }
46
+
32
47
  function getArrayU8FromWasm0(ptr, len) {
33
48
  ptr = ptr >>> 0;
34
49
  return getUint8ArrayMemory0().subarray(ptr / 1, ptr / 1 + len);
@@ -47,6 +62,14 @@ function getStringFromWasm0(ptr, len) {
47
62
  return decodeText(ptr, len);
48
63
  }
49
64
 
65
+ let cachedUint32ArrayMemory0 = null;
66
+ function getUint32ArrayMemory0() {
67
+ if (cachedUint32ArrayMemory0 === null || cachedUint32ArrayMemory0.byteLength === 0) {
68
+ cachedUint32ArrayMemory0 = new Uint32Array(wasm.memory.buffer);
69
+ }
70
+ return cachedUint32ArrayMemory0;
71
+ }
72
+
50
73
  let cachedUint8ArrayMemory0 = null;
51
74
  function getUint8ArrayMemory0() {
52
75
  if (cachedUint8ArrayMemory0 === null || cachedUint8ArrayMemory0.byteLength === 0) {
@@ -161,6 +184,10 @@ const AddressNamespaceFinalization = (typeof FinalizationRegistry === 'undefined
161
184
  ? { register: () => {}, unregister: () => {} }
162
185
  : new FinalizationRegistry(ptr => wasm.__wbg_addressnamespace_free(ptr >>> 0, 1));
163
186
 
187
+ const Bip322NamespaceFinalization = (typeof FinalizationRegistry === 'undefined')
188
+ ? { register: () => {}, unregister: () => {} }
189
+ : new FinalizationRegistry(ptr => wasm.__wbg_bip322namespace_free(ptr >>> 0, 1));
190
+
164
191
  const BitGoPsbtFinalization = (typeof FinalizationRegistry === 'undefined')
165
192
  ? { register: () => {}, unregister: () => {} }
166
193
  : new FinalizationRegistry(ptr => wasm.__wbg_bitgopsbt_free(ptr >>> 0, 1));
@@ -295,6 +322,278 @@ class AddressNamespace {
295
322
  if (Symbol.dispose) AddressNamespace.prototype[Symbol.dispose] = AddressNamespace.prototype.free;
296
323
  exports.AddressNamespace = AddressNamespace;
297
324
 
325
+ /**
326
+ * Namespace for BIP-0322 functions
327
+ */
328
+ class Bip322Namespace {
329
+ __destroy_into_raw() {
330
+ const ptr = this.__wbg_ptr;
331
+ this.__wbg_ptr = 0;
332
+ Bip322NamespaceFinalization.unregister(this);
333
+ return ptr;
334
+ }
335
+ free() {
336
+ const ptr = this.__destroy_into_raw();
337
+ wasm.__wbg_bip322namespace_free(ptr, 0);
338
+ }
339
+ /**
340
+ * Add a BIP-0322 message input to an existing BitGoPsbt
341
+ *
342
+ * If this is the first input, also adds the OP_RETURN output.
343
+ * The PSBT must have version 0 per BIP-0322 specification.
344
+ *
345
+ * # Arguments
346
+ * * `psbt` - The BitGoPsbt to add the input to
347
+ * * `message` - The message to sign
348
+ * * `chain` - The wallet chain (e.g., 10 for external, 20 for internal)
349
+ * * `index` - The address index
350
+ * * `wallet_keys` - The wallet's root keys
351
+ * * `signer` - Optional signer key name for taproot (e.g., "user", "backup", "bitgo")
352
+ * * `cosigner` - Optional cosigner key name for taproot
353
+ * * `tag` - Optional custom tag for message hashing
354
+ *
355
+ * # Returns
356
+ * The index of the added input
357
+ * @param {BitGoPsbt} psbt
358
+ * @param {string} message
359
+ * @param {number} chain
360
+ * @param {number} index
361
+ * @param {WasmRootWalletKeys} wallet_keys
362
+ * @param {string | null} [signer]
363
+ * @param {string | null} [cosigner]
364
+ * @param {string | null} [tag]
365
+ * @returns {number}
366
+ */
367
+ static add_bip322_input(psbt, message, chain, index, wallet_keys, signer, cosigner, tag) {
368
+ try {
369
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
370
+ _assertClass(psbt, BitGoPsbt);
371
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export, wasm.__wbindgen_export2);
372
+ const len0 = WASM_VECTOR_LEN;
373
+ _assertClass(wallet_keys, WasmRootWalletKeys);
374
+ var ptr1 = isLikeNone(signer) ? 0 : passStringToWasm0(signer, wasm.__wbindgen_export, wasm.__wbindgen_export2);
375
+ var len1 = WASM_VECTOR_LEN;
376
+ var ptr2 = isLikeNone(cosigner) ? 0 : passStringToWasm0(cosigner, wasm.__wbindgen_export, wasm.__wbindgen_export2);
377
+ var len2 = WASM_VECTOR_LEN;
378
+ var ptr3 = isLikeNone(tag) ? 0 : passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
379
+ var len3 = WASM_VECTOR_LEN;
380
+ wasm.bip322namespace_add_bip322_input(retptr, psbt.__wbg_ptr, ptr0, len0, chain, index, wallet_keys.__wbg_ptr, ptr1, len1, ptr2, len2, ptr3, len3);
381
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
382
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
383
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
384
+ if (r2) {
385
+ throw takeObject(r1);
386
+ }
387
+ return r0 >>> 0;
388
+ } finally {
389
+ wasm.__wbindgen_add_to_stack_pointer(16);
390
+ }
391
+ }
392
+ /**
393
+ * Verify a single input of a BIP-0322 transaction proof
394
+ *
395
+ * # Arguments
396
+ * * `tx` - The signed transaction
397
+ * * `input_index` - The index of the input to verify
398
+ * * `message` - The message that was signed
399
+ * * `chain` - The wallet chain
400
+ * * `index` - The address index
401
+ * * `wallet_keys` - The wallet's root keys
402
+ * * `network` - Network name
403
+ * * `tag` - Optional custom tag for message hashing
404
+ *
405
+ * # Throws
406
+ * Throws an error if verification fails
407
+ * @param {WasmTransaction} tx
408
+ * @param {number} input_index
409
+ * @param {string} message
410
+ * @param {number} chain
411
+ * @param {number} index
412
+ * @param {WasmRootWalletKeys} wallet_keys
413
+ * @param {string} network
414
+ * @param {string | null} [tag]
415
+ */
416
+ static verify_bip322_tx_input(tx, input_index, message, chain, index, wallet_keys, network, tag) {
417
+ try {
418
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
419
+ _assertClass(tx, WasmTransaction);
420
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export, wasm.__wbindgen_export2);
421
+ const len0 = WASM_VECTOR_LEN;
422
+ _assertClass(wallet_keys, WasmRootWalletKeys);
423
+ const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
424
+ const len1 = WASM_VECTOR_LEN;
425
+ var ptr2 = isLikeNone(tag) ? 0 : passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
426
+ var len2 = WASM_VECTOR_LEN;
427
+ wasm.bip322namespace_verify_bip322_tx_input(retptr, tx.__wbg_ptr, input_index, ptr0, len0, chain, index, wallet_keys.__wbg_ptr, ptr1, len1, ptr2, len2);
428
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
429
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
430
+ if (r1) {
431
+ throw takeObject(r0);
432
+ }
433
+ } finally {
434
+ wasm.__wbindgen_add_to_stack_pointer(16);
435
+ }
436
+ }
437
+ /**
438
+ * Verify a single input of a BIP-0322 PSBT proof
439
+ *
440
+ * # Arguments
441
+ * * `psbt` - The signed BitGoPsbt
442
+ * * `input_index` - The index of the input to verify
443
+ * * `message` - The message that was signed
444
+ * * `chain` - The wallet chain
445
+ * * `index` - The address index
446
+ * * `wallet_keys` - The wallet's root keys
447
+ * * `tag` - Optional custom tag for message hashing
448
+ *
449
+ * # Returns
450
+ * An array of signer names ("user", "backup", "bitgo") that have valid signatures
451
+ *
452
+ * # Throws
453
+ * Throws an error if verification fails or no valid signatures found
454
+ * @param {BitGoPsbt} psbt
455
+ * @param {number} input_index
456
+ * @param {string} message
457
+ * @param {number} chain
458
+ * @param {number} index
459
+ * @param {WasmRootWalletKeys} wallet_keys
460
+ * @param {string | null} [tag]
461
+ * @returns {string[]}
462
+ */
463
+ static verify_bip322_psbt_input(psbt, input_index, message, chain, index, wallet_keys, tag) {
464
+ try {
465
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
466
+ _assertClass(psbt, BitGoPsbt);
467
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export, wasm.__wbindgen_export2);
468
+ const len0 = WASM_VECTOR_LEN;
469
+ _assertClass(wallet_keys, WasmRootWalletKeys);
470
+ var ptr1 = isLikeNone(tag) ? 0 : passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
471
+ var len1 = WASM_VECTOR_LEN;
472
+ wasm.bip322namespace_verify_bip322_psbt_input(retptr, psbt.__wbg_ptr, input_index, ptr0, len0, chain, index, wallet_keys.__wbg_ptr, ptr1, len1);
473
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
474
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
475
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
476
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
477
+ if (r3) {
478
+ throw takeObject(r2);
479
+ }
480
+ var v3 = getArrayJsValueFromWasm0(r0, r1).slice();
481
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
482
+ return v3;
483
+ } finally {
484
+ wasm.__wbindgen_add_to_stack_pointer(16);
485
+ }
486
+ }
487
+ /**
488
+ * Verify a single input of a BIP-0322 transaction proof using pubkeys directly
489
+ *
490
+ * # Arguments
491
+ * * `tx` - The signed transaction
492
+ * * `input_index` - The index of the input to verify
493
+ * * `message` - The message that was signed
494
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
495
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
496
+ * * `is_script_path` - For taproot types, whether script path was used
497
+ * * `tag` - Optional custom tag for message hashing
498
+ *
499
+ * # Returns
500
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
501
+ *
502
+ * # Throws
503
+ * Throws an error if verification fails
504
+ * @param {WasmTransaction} tx
505
+ * @param {number} input_index
506
+ * @param {string} message
507
+ * @param {string[]} pubkeys
508
+ * @param {string} script_type
509
+ * @param {boolean | null} [is_script_path]
510
+ * @param {string | null} [tag]
511
+ * @returns {Uint32Array}
512
+ */
513
+ static verify_bip322_tx_input_with_pubkeys(tx, input_index, message, pubkeys, script_type, is_script_path, tag) {
514
+ try {
515
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
516
+ _assertClass(tx, WasmTransaction);
517
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export, wasm.__wbindgen_export2);
518
+ const len0 = WASM_VECTOR_LEN;
519
+ const ptr1 = passArrayJsValueToWasm0(pubkeys, wasm.__wbindgen_export);
520
+ const len1 = WASM_VECTOR_LEN;
521
+ const ptr2 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
522
+ const len2 = WASM_VECTOR_LEN;
523
+ var ptr3 = isLikeNone(tag) ? 0 : passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
524
+ var len3 = WASM_VECTOR_LEN;
525
+ wasm.bip322namespace_verify_bip322_tx_input_with_pubkeys(retptr, tx.__wbg_ptr, input_index, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(is_script_path) ? 0xFFFFFF : is_script_path ? 1 : 0, ptr3, len3);
526
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
527
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
528
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
529
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
530
+ if (r3) {
531
+ throw takeObject(r2);
532
+ }
533
+ var v5 = getArrayU32FromWasm0(r0, r1).slice();
534
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
535
+ return v5;
536
+ } finally {
537
+ wasm.__wbindgen_add_to_stack_pointer(16);
538
+ }
539
+ }
540
+ /**
541
+ * Verify a single input of a BIP-0322 PSBT proof using pubkeys directly
542
+ *
543
+ * # Arguments
544
+ * * `psbt` - The signed BitGoPsbt
545
+ * * `input_index` - The index of the input to verify
546
+ * * `message` - The message that was signed
547
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
548
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
549
+ * * `is_script_path` - For taproot types, whether script path was used
550
+ * * `tag` - Optional custom tag for message hashing
551
+ *
552
+ * # Returns
553
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
554
+ *
555
+ * # Throws
556
+ * Throws an error if verification fails or no valid signatures found
557
+ * @param {BitGoPsbt} psbt
558
+ * @param {number} input_index
559
+ * @param {string} message
560
+ * @param {string[]} pubkeys
561
+ * @param {string} script_type
562
+ * @param {boolean | null} [is_script_path]
563
+ * @param {string | null} [tag]
564
+ * @returns {Uint32Array}
565
+ */
566
+ static verify_bip322_psbt_input_with_pubkeys(psbt, input_index, message, pubkeys, script_type, is_script_path, tag) {
567
+ try {
568
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
569
+ _assertClass(psbt, BitGoPsbt);
570
+ const ptr0 = passStringToWasm0(message, wasm.__wbindgen_export, wasm.__wbindgen_export2);
571
+ const len0 = WASM_VECTOR_LEN;
572
+ const ptr1 = passArrayJsValueToWasm0(pubkeys, wasm.__wbindgen_export);
573
+ const len1 = WASM_VECTOR_LEN;
574
+ const ptr2 = passStringToWasm0(script_type, wasm.__wbindgen_export, wasm.__wbindgen_export2);
575
+ const len2 = WASM_VECTOR_LEN;
576
+ var ptr3 = isLikeNone(tag) ? 0 : passStringToWasm0(tag, wasm.__wbindgen_export, wasm.__wbindgen_export2);
577
+ var len3 = WASM_VECTOR_LEN;
578
+ wasm.bip322namespace_verify_bip322_psbt_input_with_pubkeys(retptr, psbt.__wbg_ptr, input_index, ptr0, len0, ptr1, len1, ptr2, len2, isLikeNone(is_script_path) ? 0xFFFFFF : is_script_path ? 1 : 0, ptr3, len3);
579
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
580
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
581
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
582
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
583
+ if (r3) {
584
+ throw takeObject(r2);
585
+ }
586
+ var v5 = getArrayU32FromWasm0(r0, r1).slice();
587
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
588
+ return v5;
589
+ } finally {
590
+ wasm.__wbindgen_add_to_stack_pointer(16);
591
+ }
592
+ }
593
+ }
594
+ if (Symbol.dispose) Bip322Namespace.prototype[Symbol.dispose] = Bip322Namespace.prototype.free;
595
+ exports.Bip322Namespace = Bip322Namespace;
596
+
298
597
  class BitGoPsbt {
299
598
  static __wrap(ptr) {
300
599
  ptr = ptr >>> 0;
@@ -1220,6 +1519,19 @@ class FixedScriptWalletNamespace {
1220
1519
  wasm.__wbindgen_add_to_stack_pointer(16);
1221
1520
  }
1222
1521
  }
1522
+ /**
1523
+ * Get all chain code metadata for building TypeScript lookup tables
1524
+ *
1525
+ * Returns an array of [chainCode, scriptType, scope] tuples where:
1526
+ * - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
1527
+ * - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
1528
+ * - scope: string ("external" or "internal")
1529
+ * @returns {any}
1530
+ */
1531
+ static chain_code_table() {
1532
+ const ret = wasm.fixedscriptwalletnamespace_chain_code_table();
1533
+ return takeObject(ret);
1534
+ }
1223
1535
  /**
1224
1536
  * Check if a network supports a given fixed-script wallet script type
1225
1537
  *
@@ -1883,6 +2195,50 @@ class WasmDimensions {
1883
2195
  const ret = wasm.wasmdimensions_has_segwit(this.__wbg_ptr);
1884
2196
  return ret !== 0;
1885
2197
  }
2198
+ /**
2199
+ * Get input virtual size (min or max)
2200
+ *
2201
+ * # Arguments
2202
+ * * `size` - "min" or "max", defaults to "max"
2203
+ * @param {string | null} [size]
2204
+ * @returns {number}
2205
+ */
2206
+ get_input_vsize(size) {
2207
+ var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2208
+ var len0 = WASM_VECTOR_LEN;
2209
+ const ret = wasm.wasmdimensions_get_input_vsize(this.__wbg_ptr, ptr0, len0);
2210
+ return ret >>> 0;
2211
+ }
2212
+ /**
2213
+ * Get input weight only (min or max)
2214
+ *
2215
+ * # Arguments
2216
+ * * `size` - "min" or "max", defaults to "max"
2217
+ * @param {string | null} [size]
2218
+ * @returns {number}
2219
+ */
2220
+ get_input_weight(size) {
2221
+ var ptr0 = isLikeNone(size) ? 0 : passStringToWasm0(size, wasm.__wbindgen_export, wasm.__wbindgen_export2);
2222
+ var len0 = WASM_VECTOR_LEN;
2223
+ const ret = wasm.wasmdimensions_get_input_weight(this.__wbg_ptr, ptr0, len0);
2224
+ return ret >>> 0;
2225
+ }
2226
+ /**
2227
+ * Get output virtual size
2228
+ * @returns {number}
2229
+ */
2230
+ get_output_vsize() {
2231
+ const ret = wasm.wasmdimensions_get_output_vsize(this.__wbg_ptr);
2232
+ return ret >>> 0;
2233
+ }
2234
+ /**
2235
+ * Get output weight
2236
+ * @returns {number}
2237
+ */
2238
+ get_output_weight() {
2239
+ const ret = wasm.wasmdimensions_get_output_weight(this.__wbg_ptr);
2240
+ return ret >>> 0;
2241
+ }
1886
2242
  /**
1887
2243
  * Create dimensions for a single output from script bytes
1888
2244
  * @param {Uint8Array} script
@@ -1938,6 +2294,15 @@ class WasmDimensions {
1938
2294
  const ret = wasm.wasmdimensions_empty();
1939
2295
  return WasmDimensions.__wrap(ret);
1940
2296
  }
2297
+ /**
2298
+ * Multiply dimensions by a scalar
2299
+ * @param {number} n
2300
+ * @returns {WasmDimensions}
2301
+ */
2302
+ times(n) {
2303
+ const ret = wasm.wasmdimensions_times(this.__wbg_ptr, n);
2304
+ return WasmDimensions.__wrap(ret);
2305
+ }
1941
2306
  /**
1942
2307
  * Create dimensions from a BitGoPsbt
1943
2308
  *
Binary file