@bitgo/wasm-utxo 4.37.2 → 4.39.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.
@@ -20,6 +20,8 @@ export declare class Psbt extends PsbtBase<WasmPsbt> implements IPsbt {
20
20
  addOutput(script: Uint8Array, value: bigint): number;
21
21
  updateInputWithDescriptor(inputIndex: number, descriptor: WrapDescriptor): void;
22
22
  updateOutputWithDescriptor(outputIndex: number, descriptor: WrapDescriptor): void;
23
+ /** Add a 32-byte SHA256 preimage for Miniscript descriptor finalization. */
24
+ addSha256Preimage(inputIndex: number, preimage: Uint8Array): void;
23
25
  signWithXprv(xprv: string): SignPsbtResult;
24
26
  signWithPrv(prv: Uint8Array): SignPsbtResult;
25
27
  signAll(key: WasmBIP32): SignPsbtResult;
@@ -33,5 +35,7 @@ export declare class Psbt extends PsbtBase<WasmPsbt> implements IPsbt {
33
35
  verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
34
36
  getUnsignedTx(): Uint8Array;
35
37
  finalize(): void;
38
+ /** Finalize one Miniscript input without requiring all inputs to be complete. */
39
+ finalizeInput(inputIndex: number): void;
36
40
  extractTransaction(): Transaction;
37
41
  }
@@ -47,6 +47,10 @@ class Psbt extends psbtBase_js_1.PsbtBase {
47
47
  updateOutputWithDescriptor(outputIndex, descriptor) {
48
48
  this._wasm.update_output_with_descriptor(outputIndex, descriptor);
49
49
  }
50
+ /** Add a 32-byte SHA256 preimage for Miniscript descriptor finalization. */
51
+ addSha256Preimage(inputIndex, preimage) {
52
+ this._wasm.add_sha256_preimage(inputIndex, preimage);
53
+ }
50
54
  // -- Signing --
51
55
  signWithXprv(xprv) {
52
56
  return this._wasm.sign_with_xprv(xprv);
@@ -81,6 +85,10 @@ class Psbt extends psbtBase_js_1.PsbtBase {
81
85
  finalize() {
82
86
  this._wasm.finalize_mut();
83
87
  }
88
+ /** Finalize one Miniscript input without requiring all inputs to be complete. */
89
+ finalizeInput(inputIndex) {
90
+ this._wasm.finalize_input(inputIndex);
91
+ }
84
92
  extractTransaction() {
85
93
  return transaction_js_1.Transaction.fromWasm(this._wasm.extract_transaction());
86
94
  }
@@ -17,6 +17,16 @@ export type FromInputOptions = {
17
17
  */
18
18
  utxolibCompat?: boolean;
19
19
  };
20
+ /**
21
+ * Options for output dimension calculation
22
+ */
23
+ export type FromOutputOptions = {
24
+ /**
25
+ * Set when `address` may be a ZIP-316 Unified Address whose Orchard receiver should be sized
26
+ * as a shielded output. Forwarded to `toOutputScriptWithCoin`'s `canBeShieldedOutput`.
27
+ */
28
+ isShielded?: boolean;
29
+ };
20
30
  /**
21
31
  * Dimensions class for estimating transaction virtual size.
22
32
  *
@@ -52,9 +62,12 @@ export declare class Dimensions {
52
62
  */
53
63
  static fromOutput(script: Uint8Array): Dimensions;
54
64
  /**
55
- * Create dimensions for a single output from an address
65
+ * Create dimensions for a single output from an address.
66
+ *
67
+ * Pass `{ isShielded: true }` when `address` may be a ZIP-316 Unified Address whose Orchard
68
+ * receiver should be sized as a shielded output
56
69
  */
57
- static fromOutput(address: string, network: CoinName): Dimensions;
70
+ static fromOutput(address: string, network: CoinName, options?: FromOutputOptions): Dimensions;
58
71
  /**
59
72
  * Create dimensions for a single output from script length only
60
73
  */
@@ -45,12 +45,12 @@ class Dimensions {
45
45
  }
46
46
  return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_input(params.chain, params.signPath?.signer, params.signPath?.cosigner, compat));
47
47
  }
48
- static fromOutput(params, network) {
48
+ static fromOutput(params, network, options) {
49
49
  if (typeof params === "string") {
50
50
  if (network === undefined) {
51
51
  throw new Error("network is required when passing an address string");
52
52
  }
53
- const script = (0, address_js_1.toOutputScriptWithCoin)(params, network);
53
+ const script = (0, address_js_1.toOutputScriptWithCoin)(params, network, options?.isShielded);
54
54
  return new Dimensions(wasm_utxo_js_1.WasmDimensions.from_output_script_length(script.length));
55
55
  }
56
56
  if (typeof params === "object" && "scriptType" in params) {
@@ -146,6 +146,27 @@ export declare class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt {
146
146
  ovk?: Uint8Array;
147
147
  unifiedAddress?: string;
148
148
  }): void;
149
+ /**
150
+ * Add one or more shielded outputs (Constructor role) as a single orchard PCZT — the
151
+ * multi-recipient counterpart to {@link addShieldedOutput}. Every recipient must be passed in
152
+ * one call: only one call to `addShieldedOutput`/`addShieldedOutputs` is supported per PSBT (see
153
+ * {@link addShieldedOutput}).
154
+ *
155
+ * @param outputs - one entry per recipient; `memo` defaults per-entry to the ZIP-302 "no memo"
156
+ * encoding, exactly as {@link addShieldedOutput}'s does
157
+ * @param anchor - 32-byte Ironwood note-commitment-tree root, shared by every output
158
+ * @returns the action index assigned to each output, in the same order as `outputs` — the
159
+ * orchard builder pads/reorders actions, so a client-managed-`ovk` caller must use these
160
+ * indices (not the position in `outputs`) when later calling
161
+ * `setIronwoodOutCiphertext`/`setIronwoodOutCiphertextForUser` for a specific recipient.
162
+ */
163
+ addShieldedOutputs(outputs: Array<{
164
+ recipient: Uint8Array;
165
+ amount: bigint;
166
+ memo?: Uint8Array;
167
+ ovk?: Uint8Array;
168
+ unifiedAddress?: string;
169
+ }>, anchor: Uint8Array): number[];
149
170
  /**
150
171
  * Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
151
172
  * `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
@@ -143,6 +143,29 @@ class ZcashIronwoodBitGoPsbt extends ZcashBitGoPsbt_js_1.ZcashBitGoPsbt {
143
143
  const memo = options.memo ?? zip302NoMemo();
144
144
  this.wasm.add_ironwood_output(recipient, amount, options.ovk, options.anchor, memo, options.unifiedAddress);
145
145
  }
146
+ /**
147
+ * Add one or more shielded outputs (Constructor role) as a single orchard PCZT — the
148
+ * multi-recipient counterpart to {@link addShieldedOutput}. Every recipient must be passed in
149
+ * one call: only one call to `addShieldedOutput`/`addShieldedOutputs` is supported per PSBT (see
150
+ * {@link addShieldedOutput}).
151
+ *
152
+ * @param outputs - one entry per recipient; `memo` defaults per-entry to the ZIP-302 "no memo"
153
+ * encoding, exactly as {@link addShieldedOutput}'s does
154
+ * @param anchor - 32-byte Ironwood note-commitment-tree root, shared by every output
155
+ * @returns the action index assigned to each output, in the same order as `outputs` — the
156
+ * orchard builder pads/reorders actions, so a client-managed-`ovk` caller must use these
157
+ * indices (not the position in `outputs`) when later calling
158
+ * `setIronwoodOutCiphertext`/`setIronwoodOutCiphertextForUser` for a specific recipient.
159
+ */
160
+ addShieldedOutputs(outputs, anchor) {
161
+ return Array.from(this.wasm.add_ironwood_outputs(outputs.map((o) => ({
162
+ recipient: o.recipient,
163
+ amount: o.amount,
164
+ memo: o.memo ?? zip302NoMemo(),
165
+ ovk: o.ovk,
166
+ unifiedAddress: o.unifiedAddress,
167
+ })), anchor));
168
+ }
146
169
  /**
147
170
  * Client-managed `ovk`: re-encrypt the shielded output's `out_ciphertext` under **this wallet's**
148
171
  * `ovk`, derived as the ECDH agreement of `rootWalletKeys.bitgoKey()` and `userKey`. Both are root
@@ -161,6 +161,21 @@ export class BitGoPsbt {
161
161
  * [`MEMO_SIZE`]: crate::zcash::ironwood_build::MEMO_SIZE
162
162
  */
163
163
  add_ironwood_output(recipient: Uint8Array, amount: bigint, ovk: Uint8Array | null | undefined, anchor: Uint8Array, memo: Uint8Array, unified_address?: string | null): void;
164
+ /**
165
+ * Constructor: add one or more shielded Ironwood outputs as a single orchard PCZT stored in
166
+ * the PSBT — the multi-recipient counterpart to [`Self::add_ironwood_output`].
167
+ *
168
+ * `outputs` is an array of `{ recipient: Uint8Array, amount: bigint, memo: Uint8Array,
169
+ * ovk?: Uint8Array, unifiedAddress?: string }`, one entry per recipient — see
170
+ * [`Self::add_ironwood_output`] for the meaning of each field. `anchor` is shared by every
171
+ * output.
172
+ *
173
+ * Returns the action index assigned to each output, in the same order as `outputs` — the
174
+ * orchard builder pads/reorders actions, so a client-managed-`ovk` caller must use these
175
+ * indices (not the position in `outputs`) when later calling `set_ironwood_out_ciphertext`
176
+ * for a specific recipient.
177
+ */
178
+ add_ironwood_outputs(outputs: any, anchor: Uint8Array): Uint32Array;
164
179
  /**
165
180
  * Ingest a transparent-input signature (`sig`: DER ECDSA with the trailing SIGHASH_ALL byte)
166
181
  * after verifying it against `ironwood_v6_transparent_sighash(index)`.
@@ -1556,6 +1571,13 @@ export class WrapPsbt {
1556
1571
  * The index of the newly added output
1557
1572
  */
1558
1573
  add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
1574
+ /**
1575
+ * Add a 32-byte SHA256 preimage to an input's standard BIP174 metadata.
1576
+ *
1577
+ * Descriptor finalization uses this metadata to satisfy `sha256(H)`
1578
+ * Miniscript fragments when `H == sha256(preimage)`.
1579
+ */
1580
+ add_sha256_preimage(input_index: number, preimage: Uint8Array): void;
1559
1581
  clone(): WrapPsbt;
1560
1582
  delete_input_kv(index: number, key: any): void;
1561
1583
  delete_kv(key: any): void;
@@ -1582,6 +1604,10 @@ export class WrapPsbt {
1582
1604
  * * `expiry_height` - Transaction expiry height (default: 0)
1583
1605
  */
1584
1606
  extract_zcash_transaction(version_group_id?: number | null, expiry_height?: number | null): WasmZcashTransaction;
1607
+ /**
1608
+ * Finalize one Miniscript input, preserving any other incomplete inputs.
1609
+ */
1610
+ finalize_input(input_index: number): void;
1585
1611
  finalize_mut(): void;
1586
1612
  /**
1587
1613
  * Finalize all Zcash transparent inputs using ZIP-243 sighash verification.
@@ -521,6 +521,43 @@ class BitGoPsbt {
521
521
  wasm.__wbindgen_add_to_stack_pointer(16);
522
522
  }
523
523
  }
524
+ /**
525
+ * Constructor: add one or more shielded Ironwood outputs as a single orchard PCZT stored in
526
+ * the PSBT — the multi-recipient counterpart to [`Self::add_ironwood_output`].
527
+ *
528
+ * `outputs` is an array of `{ recipient: Uint8Array, amount: bigint, memo: Uint8Array,
529
+ * ovk?: Uint8Array, unifiedAddress?: string }`, one entry per recipient — see
530
+ * [`Self::add_ironwood_output`] for the meaning of each field. `anchor` is shared by every
531
+ * output.
532
+ *
533
+ * Returns the action index assigned to each output, in the same order as `outputs` — the
534
+ * orchard builder pads/reorders actions, so a client-managed-`ovk` caller must use these
535
+ * indices (not the position in `outputs`) when later calling `set_ironwood_out_ciphertext`
536
+ * for a specific recipient.
537
+ * @param {any} outputs
538
+ * @param {Uint8Array} anchor
539
+ * @returns {Uint32Array}
540
+ */
541
+ add_ironwood_outputs(outputs, anchor) {
542
+ try {
543
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
544
+ const ptr0 = passArray8ToWasm0(anchor, wasm.__wbindgen_export);
545
+ const len0 = WASM_VECTOR_LEN;
546
+ wasm.bitgopsbt_add_ironwood_outputs(retptr, this.__wbg_ptr, addHeapObject(outputs), ptr0, len0);
547
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
548
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
549
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
550
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
551
+ if (r3) {
552
+ throw takeObject(r2);
553
+ }
554
+ var v2 = getArrayU32FromWasm0(r0, r1).slice();
555
+ wasm.__wbindgen_export4(r0, r1 * 4, 4);
556
+ return v2;
557
+ } finally {
558
+ wasm.__wbindgen_add_to_stack_pointer(16);
559
+ }
560
+ }
524
561
  /**
525
562
  * Ingest a transparent-input signature (`sig`: DER ECDSA with the trailing SIGHASH_ALL byte)
526
563
  * after verifying it against `ironwood_v6_transparent_sighash(index)`.
@@ -5743,6 +5780,29 @@ class WrapPsbt {
5743
5780
  wasm.__wbindgen_add_to_stack_pointer(16);
5744
5781
  }
5745
5782
  }
5783
+ /**
5784
+ * Add a 32-byte SHA256 preimage to an input's standard BIP174 metadata.
5785
+ *
5786
+ * Descriptor finalization uses this metadata to satisfy `sha256(H)`
5787
+ * Miniscript fragments when `H == sha256(preimage)`.
5788
+ * @param {number} input_index
5789
+ * @param {Uint8Array} preimage
5790
+ */
5791
+ add_sha256_preimage(input_index, preimage) {
5792
+ try {
5793
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5794
+ const ptr0 = passArray8ToWasm0(preimage, wasm.__wbindgen_export);
5795
+ const len0 = WASM_VECTOR_LEN;
5796
+ wasm.wrappsbt_add_sha256_preimage(retptr, this.__wbg_ptr, input_index, ptr0, len0);
5797
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5798
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5799
+ if (r1) {
5800
+ throw takeObject(r0);
5801
+ }
5802
+ } finally {
5803
+ wasm.__wbindgen_add_to_stack_pointer(16);
5804
+ }
5805
+ }
5746
5806
  /**
5747
5807
  * @returns {WrapPsbt}
5748
5808
  */
@@ -5874,6 +5934,23 @@ class WrapPsbt {
5874
5934
  wasm.__wbindgen_add_to_stack_pointer(16);
5875
5935
  }
5876
5936
  }
5937
+ /**
5938
+ * Finalize one Miniscript input, preserving any other incomplete inputs.
5939
+ * @param {number} input_index
5940
+ */
5941
+ finalize_input(input_index) {
5942
+ try {
5943
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5944
+ wasm.wrappsbt_finalize_input(retptr, this.__wbg_ptr, input_index);
5945
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5946
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5947
+ if (r1) {
5948
+ throw takeObject(r0);
5949
+ }
5950
+ } finally {
5951
+ wasm.__wbindgen_add_to_stack_pointer(16);
5952
+ }
5953
+ }
5877
5954
  finalize_mut() {
5878
5955
  try {
5879
5956
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
@@ -7174,6 +7251,10 @@ function __wbg_get_imports() {
7174
7251
  getDataViewMemory0().setInt32(arg0 + 4 * 1, len1, true);
7175
7252
  getDataViewMemory0().setInt32(arg0 + 4 * 0, ptr1, true);
7176
7253
  },
7254
+ __wbg___wbindgen_is_bigint_31b12575b56f32fc: function(arg0) {
7255
+ const ret = typeof(getObject(arg0)) === 'bigint';
7256
+ return ret;
7257
+ },
7177
7258
  __wbg___wbindgen_is_function_0095a73b8b156f76: function(arg0) {
7178
7259
  const ret = typeof(getObject(arg0)) === 'function';
7179
7260
  return ret;
Binary file