@bitgo/wasm-utxo 4.4.0 → 4.6.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.
@@ -8,7 +8,7 @@ import { type ECPairArg } from "../ecpair.js";
8
8
  import type { UtxolibName } from "../utxolibCompat.js";
9
9
  import type { CoinName } from "../coinName.js";
10
10
  import type { InputScriptType } from "./scriptType.js";
11
- import { type ITransaction } from "../transaction.js";
11
+ import { Transaction, DashTransaction, type ITransaction } from "../transaction.js";
12
12
  export type { InputScriptType };
13
13
  export type NetworkName = UtxolibName | CoinName;
14
14
  export type ScriptId = {
@@ -151,12 +151,17 @@ export declare class BitGoPsbt extends PsbtBase<WasmBitGoPsbt> implements IPsbtW
151
151
  * with proper wallet metadata (bip32Derivation, scripts, witnessUtxo).
152
152
  * Only supports p2sh, p2shP2wsh, and p2wsh inputs (not taproot).
153
153
  *
154
- * @param txBytes - The serialized half-signed legacy transaction
154
+ * Supports both Bitcoin-like coins (BTC, LTC, DOGE) and Dash (DASH).
155
+ * Zcash is NOT supported; use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead.
156
+ *
157
+ * @param txBytesOrTx - Transaction bytes or decoded transaction instance (Bitcoin-like or Dash)
155
158
  * @param network - Network name
156
159
  * @param walletKeys - The wallet's root keys
157
160
  * @param unspents - Chain, index, and value for each input
161
+ * @param _options - Reserved for future use and signature compatibility with subclasses
162
+ * @throws Error if transaction is Zcash (use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead)
158
163
  */
159
- static fromHalfSignedLegacyTransaction(txBytes: Uint8Array, network: NetworkName, walletKeys: WalletKeysArg, unspents: HydrationUnspent[]): BitGoPsbt;
164
+ static fromHalfSignedLegacyTransaction(txBytesOrTx: Uint8Array | Transaction | DashTransaction, network: NetworkName, walletKeys: WalletKeysArg, unspents: HydrationUnspent[], _options?: unknown): BitGoPsbt;
160
165
  /**
161
166
  * Add an input to the PSBT
162
167
  *
@@ -8,6 +8,7 @@ const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
8
8
  const ReplayProtection_js_1 = require("./ReplayProtection.js");
9
9
  const bip32_js_1 = require("../bip32.js");
10
10
  const ecpair_js_1 = require("../ecpair.js");
11
+ const coinName_js_1 = require("../coinName.js");
11
12
  const transaction_js_1 = require("../transaction.js");
12
13
  class BitGoPsbt extends psbtBase_js_1.PsbtBase {
13
14
  constructor(wasm) {
@@ -64,14 +65,32 @@ class BitGoPsbt extends psbtBase_js_1.PsbtBase {
64
65
  * with proper wallet metadata (bip32Derivation, scripts, witnessUtxo).
65
66
  * Only supports p2sh, p2shP2wsh, and p2wsh inputs (not taproot).
66
67
  *
67
- * @param txBytes - The serialized half-signed legacy transaction
68
+ * Supports both Bitcoin-like coins (BTC, LTC, DOGE) and Dash (DASH).
69
+ * Zcash is NOT supported; use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead.
70
+ *
71
+ * @param txBytesOrTx - Transaction bytes or decoded transaction instance (Bitcoin-like or Dash)
68
72
  * @param network - Network name
69
73
  * @param walletKeys - The wallet's root keys
70
74
  * @param unspents - Chain, index, and value for each input
75
+ * @param _options - Reserved for future use and signature compatibility with subclasses
76
+ * @throws Error if transaction is Zcash (use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction instead)
71
77
  */
72
- static fromHalfSignedLegacyTransaction(txBytes, network, walletKeys, unspents) {
78
+ static fromHalfSignedLegacyTransaction(txBytesOrTx, network, walletKeys, unspents,
79
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
80
+ _options) {
73
81
  const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
74
- const wasm = wasm_utxo_js_1.BitGoPsbt.from_half_signed_legacy_transaction(txBytes, network, keys.wasm, unspents);
82
+ // Parse bytes to Transaction if needed
83
+ const tx = txBytesOrTx instanceof Uint8Array
84
+ ? transaction_js_1.Transaction.fromBytes(txBytesOrTx, (0, coinName_js_1.toCoinName)(network))
85
+ : txBytesOrTx;
86
+ // Validate that this is not a Zcash transaction
87
+ if (tx instanceof transaction_js_1.ZcashTransaction) {
88
+ throw new Error("Use ZcashBitGoPsbt.fromHalfSignedLegacyTransaction() for Zcash transactions");
89
+ }
90
+ // Pass WASM transaction directly to avoid serialization round-trip
91
+ const wasm = tx instanceof transaction_js_1.DashTransaction
92
+ ? wasm_utxo_js_1.BitGoPsbt.from_half_signed_legacy_transaction_dash(tx.wasm, network, keys.wasm, unspents)
93
+ : wasm_utxo_js_1.BitGoPsbt.from_half_signed_legacy_transaction(tx.wasm, network, keys.wasm, unspents);
75
94
  return new BitGoPsbt(wasm);
76
95
  }
77
96
  addInputAtIndex(index, txidOrOptions, voutOrScript, value, script, sequence) {
@@ -1,6 +1,6 @@
1
1
  import { type WalletKeysArg } from "./RootWalletKeys.js";
2
- import { BitGoPsbt, type CreateEmptyOptions } from "./BitGoPsbt.js";
3
- import { ZcashTransaction } from "../transaction.js";
2
+ import { BitGoPsbt, type CreateEmptyOptions, type HydrationUnspent } from "./BitGoPsbt.js";
3
+ import { ZcashTransaction, type ITransaction } from "../transaction.js";
4
4
  /** Zcash network names */
5
5
  export type ZcashNetworkName = "zcash" | "zcashTest" | "zec" | "tzec";
6
6
  /** Options for creating an empty Zcash PSBT (preferred method using block height) */
@@ -101,6 +101,51 @@ export declare class ZcashBitGoPsbt extends BitGoPsbt {
101
101
  * @returns A ZcashBitGoPsbt instance
102
102
  */
103
103
  static fromBytes(bytes: Uint8Array, network: ZcashNetworkName): ZcashBitGoPsbt;
104
+ /**
105
+ * Reconstruct a Zcash PSBT from a half-signed legacy transaction
106
+ *
107
+ * This is the inverse of `getHalfSignedLegacyFormat()` for Zcash. It decodes the Zcash wire
108
+ * format (which includes version_group_id, expiry_height, and sapling fields), extracts
109
+ * partial signatures, and reconstructs a proper Zcash PSBT with consensus metadata.
110
+ *
111
+ * Supports two modes for determining consensus_branch_id:
112
+ * - **Recommended**: Pass `blockHeight` to auto-determine consensus_branch_id via network upgrade activation heights
113
+ * - **Advanced**: Pass `consensusBranchId` directly if you already know it (e.g., 0xC2D6D0B4 for NU5)
114
+ *
115
+ * @param txBytesOrTx - Either serialized Zcash transaction bytes or a decoded ZcashTransaction instance
116
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
117
+ * @param walletKeys - The wallet's root keys
118
+ * @param unspents - Chain, index, and value for each input
119
+ * @param options - Either `{ blockHeight: number }` or `{ consensusBranchId: number }`
120
+ * @returns A ZcashBitGoPsbt instance
121
+ *
122
+ * @example
123
+ * ```typescript
124
+ * // Round-trip with block height (recommended)
125
+ * const legacyBytes = psbt.getHalfSignedLegacyFormat();
126
+ * const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
127
+ * legacyBytes,
128
+ * "zec",
129
+ * walletKeys,
130
+ * unspents,
131
+ * { blockHeight: 1687105 } // NU5 activation height
132
+ * );
133
+ *
134
+ * // Or with explicit consensus branch ID
135
+ * const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
136
+ * legacyBytes,
137
+ * "zec",
138
+ * walletKeys,
139
+ * unspents,
140
+ * { consensusBranchId: 0xC2D6D0B4 } // NU5 branch ID
141
+ * );
142
+ * ```
143
+ */
144
+ static fromHalfSignedLegacyTransaction(txBytesOrTx: Uint8Array | ITransaction, network: ZcashNetworkName, walletKeys: WalletKeysArg, unspents: HydrationUnspent[], options: {
145
+ blockHeight: number;
146
+ } | {
147
+ consensusBranchId: number;
148
+ }): ZcashBitGoPsbt;
104
149
  /**
105
150
  * Get the Zcash version group ID
106
151
  * @returns The version group ID (e.g., 0x892F2085 for Sapling)
@@ -96,6 +96,60 @@ class ZcashBitGoPsbt extends BitGoPsbt_js_1.BitGoPsbt {
96
96
  const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
97
97
  return new ZcashBitGoPsbt(wasm);
98
98
  }
99
+ /**
100
+ * Reconstruct a Zcash PSBT from a half-signed legacy transaction
101
+ *
102
+ * This is the inverse of `getHalfSignedLegacyFormat()` for Zcash. It decodes the Zcash wire
103
+ * format (which includes version_group_id, expiry_height, and sapling fields), extracts
104
+ * partial signatures, and reconstructs a proper Zcash PSBT with consensus metadata.
105
+ *
106
+ * Supports two modes for determining consensus_branch_id:
107
+ * - **Recommended**: Pass `blockHeight` to auto-determine consensus_branch_id via network upgrade activation heights
108
+ * - **Advanced**: Pass `consensusBranchId` directly if you already know it (e.g., 0xC2D6D0B4 for NU5)
109
+ *
110
+ * @param txBytesOrTx - Either serialized Zcash transaction bytes or a decoded ZcashTransaction instance
111
+ * @param network - Zcash network name ("zcash", "zcashTest", "zec", "tzec")
112
+ * @param walletKeys - The wallet's root keys
113
+ * @param unspents - Chain, index, and value for each input
114
+ * @param options - Either `{ blockHeight: number }` or `{ consensusBranchId: number }`
115
+ * @returns A ZcashBitGoPsbt instance
116
+ *
117
+ * @example
118
+ * ```typescript
119
+ * // Round-trip with block height (recommended)
120
+ * const legacyBytes = psbt.getHalfSignedLegacyFormat();
121
+ * const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
122
+ * legacyBytes,
123
+ * "zec",
124
+ * walletKeys,
125
+ * unspents,
126
+ * { blockHeight: 1687105 } // NU5 activation height
127
+ * );
128
+ *
129
+ * // Or with explicit consensus branch ID
130
+ * const reconstructed = ZcashBitGoPsbt.fromHalfSignedLegacyTransaction(
131
+ * legacyBytes,
132
+ * "zec",
133
+ * walletKeys,
134
+ * unspents,
135
+ * { consensusBranchId: 0xC2D6D0B4 } // NU5 branch ID
136
+ * );
137
+ * ```
138
+ */
139
+ static fromHalfSignedLegacyTransaction(txBytesOrTx, network, walletKeys, unspents, options) {
140
+ const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
141
+ const tx = txBytesOrTx instanceof Uint8Array
142
+ ? transaction_js_1.ZcashTransaction.fromBytes(txBytesOrTx)
143
+ : txBytesOrTx;
144
+ if ("blockHeight" in options) {
145
+ const wasm = wasm_utxo_js_1.BitGoPsbt.from_half_signed_legacy_transaction_zcash_with_block_height(tx.wasm, network, keys.wasm, unspents, options.blockHeight);
146
+ return new ZcashBitGoPsbt(wasm);
147
+ }
148
+ else {
149
+ const wasm = wasm_utxo_js_1.BitGoPsbt.from_half_signed_legacy_transaction_zcash_with_branch_id(tx.wasm, network, keys.wasm, unspents, options.consensusBranchId);
150
+ return new ZcashBitGoPsbt(wasm);
151
+ }
152
+ }
99
153
  // --- Zcash-specific getters ---
100
154
  /**
101
155
  * Get the Zcash version group ID
@@ -12,10 +12,13 @@ export interface IPsbt extends ITransactionCommon<PsbtInputData, PsbtOutputData>
12
12
  removeOutput(index: number): void;
13
13
  setKV(key: PsbtKvKey, value: Uint8Array): void;
14
14
  getKV(key: PsbtKvKey): Uint8Array | undefined;
15
+ deleteKV(key: PsbtKvKey): void;
15
16
  setInputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
16
17
  getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
18
+ deleteInputKV(index: number, key: PsbtKvKey): void;
17
19
  setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
18
20
  getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
21
+ deleteOutputKV(index: number, key: PsbtKvKey): void;
19
22
  }
20
23
  /** Extended PSBT with address resolution (no coin parameter needed) */
21
24
  export interface IPsbtWithAddress extends IPsbt {
@@ -15,10 +15,13 @@ interface WasmPsbtBase {
15
15
  remove_output(index: number): void;
16
16
  set_kv(key: unknown, value: Uint8Array): void;
17
17
  get_kv(key: unknown): Uint8Array | null | undefined;
18
+ delete_kv(key: unknown): void;
18
19
  set_input_kv(index: number, key: unknown, value: Uint8Array): void;
19
20
  get_input_kv(index: number, key: unknown): Uint8Array | null | undefined;
21
+ delete_input_kv(index: number, key: unknown): void;
20
22
  set_output_kv(index: number, key: unknown, value: Uint8Array): void;
21
23
  get_output_kv(index: number, key: unknown): Uint8Array | null | undefined;
24
+ delete_output_kv(index: number, key: unknown): void;
22
25
  }
23
26
  export declare abstract class PsbtBase<W extends WasmPsbtBase> {
24
27
  protected _wasm: W;
@@ -40,5 +43,8 @@ export declare abstract class PsbtBase<W extends WasmPsbtBase> {
40
43
  getInputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
41
44
  setOutputKV(index: number, key: PsbtKvKey, value: Uint8Array): void;
42
45
  getOutputKV(index: number, key: PsbtKvKey): Uint8Array | undefined;
46
+ deleteKV(key: PsbtKvKey): void;
47
+ deleteInputKV(index: number, key: PsbtKvKey): void;
48
+ deleteOutputKV(index: number, key: PsbtKvKey): void;
43
49
  }
44
50
  export {};
@@ -58,5 +58,14 @@ class PsbtBase {
58
58
  getOutputKV(index, key) {
59
59
  return this._wasm.get_output_kv(index, key) ?? undefined;
60
60
  }
61
+ deleteKV(key) {
62
+ this._wasm.delete_kv(key);
63
+ }
64
+ deleteInputKV(index, key) {
65
+ this._wasm.delete_input_kv(index, key);
66
+ }
67
+ deleteOutputKV(index, key) {
68
+ this._wasm.delete_output_kv(index, key);
69
+ }
61
70
  }
62
71
  exports.PsbtBase = PsbtBase;
@@ -24,11 +24,19 @@ export interface ITransaction extends ITransactionCommon<TxInputData, TxOutputDa
24
24
  */
25
25
  export declare class Transaction extends TransactionBase<WasmTransaction> {
26
26
  private constructor();
27
+ /**
28
+ * Check if a coin is supported by this transaction class.
29
+ * Bitcoin-like transactions support all coins except Zcash and Dash.
30
+ */
31
+ static supportsCoin(coin: CoinName): boolean;
27
32
  /**
28
33
  * Create an empty transaction (version 1, locktime 0)
29
34
  */
30
35
  static create(): Transaction;
31
36
  static fromBytes(bytes: Uint8Array): Transaction;
37
+ static fromBytes(bytes: Uint8Array, coin: "zec" | "tzec"): ZcashTransaction;
38
+ static fromBytes(bytes: Uint8Array, coin: "dash" | "tdash"): DashTransaction;
39
+ static fromBytes(bytes: Uint8Array, coin: CoinName): Transaction | ZcashTransaction | DashTransaction;
32
40
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
33
41
  static fromWasm(wasm: WasmTransaction): Transaction;
34
42
  /**
@@ -60,6 +68,11 @@ export declare class Transaction extends TransactionBase<WasmTransaction> {
60
68
  */
61
69
  export declare class ZcashTransaction extends TransactionBase<WasmZcashTransaction> {
62
70
  private constructor();
71
+ /**
72
+ * Check if a coin is supported by this transaction class.
73
+ * Zcash transactions support Zcash mainnet and testnet.
74
+ */
75
+ static supportsCoin(coin: CoinName): boolean;
63
76
  static fromBytes(bytes: Uint8Array): ZcashTransaction;
64
77
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
65
78
  static fromWasm(wasm: WasmZcashTransaction): ZcashTransaction;
@@ -73,6 +86,11 @@ export declare class ZcashTransaction extends TransactionBase<WasmZcashTransacti
73
86
  */
74
87
  export declare class DashTransaction extends TransactionBase<WasmDashTransaction> {
75
88
  private constructor();
89
+ /**
90
+ * Check if a coin is supported by this transaction class.
91
+ * Dash transactions support Dash mainnet and testnet.
92
+ */
93
+ static supportsCoin(coin: CoinName): boolean;
76
94
  static fromBytes(bytes: Uint8Array): DashTransaction;
77
95
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
78
96
  static fromWasm(wasm: WasmDashTransaction): DashTransaction;
@@ -12,13 +12,26 @@ class Transaction extends transactionBase_js_1.TransactionBase {
12
12
  constructor(wasm) {
13
13
  super(wasm);
14
14
  }
15
+ /**
16
+ * Check if a coin is supported by this transaction class.
17
+ * Bitcoin-like transactions support all coins except Zcash and Dash.
18
+ */
19
+ static supportsCoin(coin) {
20
+ return !ZcashTransaction.supportsCoin(coin) && !DashTransaction.supportsCoin(coin);
21
+ }
15
22
  /**
16
23
  * Create an empty transaction (version 1, locktime 0)
17
24
  */
18
25
  static create() {
19
26
  return new Transaction(wasm_utxo_js_1.WasmTransaction.create());
20
27
  }
21
- static fromBytes(bytes) {
28
+ static fromBytes(bytes, coin) {
29
+ if (coin !== undefined) {
30
+ if (ZcashTransaction.supportsCoin(coin))
31
+ return ZcashTransaction.fromBytes(bytes);
32
+ if (DashTransaction.supportsCoin(coin))
33
+ return DashTransaction.fromBytes(bytes);
34
+ }
22
35
  return new Transaction(wasm_utxo_js_1.WasmTransaction.from_bytes(bytes));
23
36
  }
24
37
  /** @internal Create from WASM instance directly (avoids re-parsing bytes) */
@@ -69,6 +82,13 @@ class ZcashTransaction extends transactionBase_js_1.TransactionBase {
69
82
  constructor(wasm) {
70
83
  super(wasm);
71
84
  }
85
+ /**
86
+ * Check if a coin is supported by this transaction class.
87
+ * Zcash transactions support Zcash mainnet and testnet.
88
+ */
89
+ static supportsCoin(coin) {
90
+ return coin === "zec" || coin === "tzec";
91
+ }
72
92
  static fromBytes(bytes) {
73
93
  return new ZcashTransaction(wasm_utxo_js_1.WasmZcashTransaction.from_bytes(bytes));
74
94
  }
@@ -91,6 +111,13 @@ class DashTransaction extends transactionBase_js_1.TransactionBase {
91
111
  constructor(wasm) {
92
112
  super(wasm);
93
113
  }
114
+ /**
115
+ * Check if a coin is supported by this transaction class.
116
+ * Dash transactions support Dash mainnet and testnet.
117
+ */
118
+ static supportsCoin(coin) {
119
+ return coin === "dash" || coin === "tdash";
120
+ }
94
121
  static fromBytes(bytes) {
95
122
  return new DashTransaction(wasm_utxo_js_1.WasmDashTransaction.from_bytes(bytes));
96
123
  }
@@ -221,6 +221,9 @@ export class BitGoPsbt {
221
221
  * Returns error if block height is before Overwinter activation
222
222
  */
223
223
  static create_empty_zcash_at_height(network: string, wallet_keys: WasmRootWalletKeys, block_height: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
224
+ delete_input_kv(index: number, key: any): void;
225
+ delete_kv(key: any): void;
226
+ delete_output_kv(index: number, key: any): void;
224
227
  /**
225
228
  * Get the Zcash expiry height (returns None for non-Zcash PSBTs)
226
229
  */
@@ -298,12 +301,45 @@ export class BitGoPsbt {
298
301
  * Convert a half-signed legacy transaction to a psbt-lite.
299
302
  *
300
303
  * # Arguments
301
- * * `tx_bytes` - The serialized half-signed legacy transaction
304
+ * * `tx` - The decoded half-signed legacy transaction
302
305
  * * `network` - Network name (utxolib or coin name)
303
306
  * * `wallet_keys` - The wallet's root keys
304
307
  * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
305
308
  */
306
- static from_half_signed_legacy_transaction(tx_bytes: Uint8Array, network: string, wallet_keys: WasmRootWalletKeys, unspents: any): BitGoPsbt;
309
+ static from_half_signed_legacy_transaction(tx: WasmTransaction, network: string, wallet_keys: WasmRootWalletKeys, unspents: any): BitGoPsbt;
310
+ /**
311
+ * Convert a half-signed legacy Dash transaction to a psbt-lite.
312
+ *
313
+ * # Arguments
314
+ * * `tx` - The decoded Dash transaction
315
+ * * `network` - Network name ("dash" or "tdash")
316
+ * * `wallet_keys` - The wallet's root keys
317
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
318
+ */
319
+ static from_half_signed_legacy_transaction_dash(tx: WasmDashTransaction, network: string, wallet_keys: WasmRootWalletKeys, unspents: any): BitGoPsbt;
320
+ /**
321
+ * Convert a half-signed legacy Zcash transaction to a psbt-lite (with block height).
322
+ * Thin wrapper: resolves block_height → consensus_branch_id and delegates to the explicit variant.
323
+ *
324
+ * # Arguments
325
+ * * `tx` - The decoded Zcash transaction
326
+ * * `network` - Network name ("zec" or "tzec")
327
+ * * `wallet_keys` - The wallet's root keys
328
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
329
+ * * `block_height` - Block height to determine consensus branch ID
330
+ */
331
+ static from_half_signed_legacy_transaction_zcash_with_block_height(tx: WasmZcashTransaction, network: string, wallet_keys: WasmRootWalletKeys, unspents: any, block_height: number): BitGoPsbt;
332
+ /**
333
+ * Convert a half-signed legacy Zcash transaction to a psbt-lite (with consensus branch ID).
334
+ *
335
+ * # Arguments
336
+ * * `tx` - The decoded Zcash transaction
337
+ * * `network` - Network name ("zec" or "tzec")
338
+ * * `wallet_keys` - The wallet's root keys
339
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
340
+ * * `consensus_branch_id` - Zcash consensus branch ID
341
+ */
342
+ static from_half_signed_legacy_transaction_zcash_with_branch_id(tx: WasmZcashTransaction, network: string, wallet_keys: WasmRootWalletKeys, unspents: any, consensus_branch_id: number): BitGoPsbt;
307
343
  /**
308
344
  * Generate and store MuSig2 nonces for all MuSig2 inputs
309
345
  *
@@ -1363,6 +1399,9 @@ export class WrapPsbt {
1363
1399
  */
1364
1400
  add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
1365
1401
  clone(): WrapPsbt;
1402
+ delete_input_kv(index: number, key: any): void;
1403
+ delete_kv(key: any): void;
1404
+ delete_output_kv(index: number, key: any): void;
1366
1405
  static deserialize(psbt: Uint8Array): WrapPsbt;
1367
1406
  /**
1368
1407
  * Extract the final transaction from a finalized PSBT
@@ -920,6 +920,56 @@ class BitGoPsbt {
920
920
  wasm.__wbindgen_add_to_stack_pointer(16);
921
921
  }
922
922
  }
923
+ /**
924
+ * @param {number} index
925
+ * @param {any} key
926
+ */
927
+ delete_input_kv(index, key) {
928
+ try {
929
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
930
+ wasm.bitgopsbt_delete_input_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
931
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
932
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
933
+ if (r1) {
934
+ throw takeObject(r0);
935
+ }
936
+ } finally {
937
+ wasm.__wbindgen_add_to_stack_pointer(16);
938
+ }
939
+ }
940
+ /**
941
+ * @param {any} key
942
+ */
943
+ delete_kv(key) {
944
+ try {
945
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
946
+ wasm.bitgopsbt_delete_kv(retptr, this.__wbg_ptr, addHeapObject(key));
947
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
948
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
949
+ if (r1) {
950
+ throw takeObject(r0);
951
+ }
952
+ } finally {
953
+ wasm.__wbindgen_add_to_stack_pointer(16);
954
+ }
955
+ }
956
+ /**
957
+ * @param {number} index
958
+ * @param {any} key
959
+ */
960
+ delete_output_kv(index, key) {
961
+ try {
962
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
963
+ wasm.bitgopsbt_delete_output_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
964
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
965
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
966
+ if (r1) {
967
+ throw takeObject(r0);
968
+ }
969
+ } finally {
970
+ wasm.__wbindgen_add_to_stack_pointer(16);
971
+ }
972
+ }
923
973
  /**
924
974
  * Get the Zcash expiry height (returns None for non-Zcash PSBTs)
925
975
  * @returns {number | undefined}
@@ -1112,25 +1162,128 @@ class BitGoPsbt {
1112
1162
  * Convert a half-signed legacy transaction to a psbt-lite.
1113
1163
  *
1114
1164
  * # Arguments
1115
- * * `tx_bytes` - The serialized half-signed legacy transaction
1165
+ * * `tx` - The decoded half-signed legacy transaction
1116
1166
  * * `network` - Network name (utxolib or coin name)
1117
1167
  * * `wallet_keys` - The wallet's root keys
1118
1168
  * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
1119
- * @param {Uint8Array} tx_bytes
1169
+ * @param {WasmTransaction} tx
1120
1170
  * @param {string} network
1121
1171
  * @param {WasmRootWalletKeys} wallet_keys
1122
1172
  * @param {any} unspents
1123
1173
  * @returns {BitGoPsbt}
1124
1174
  */
1125
- static from_half_signed_legacy_transaction(tx_bytes, network, wallet_keys, unspents) {
1175
+ static from_half_signed_legacy_transaction(tx, network, wallet_keys, unspents) {
1126
1176
  try {
1127
1177
  const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1128
- const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_export);
1178
+ _assertClass(tx, WasmTransaction);
1179
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1129
1180
  const len0 = WASM_VECTOR_LEN;
1130
- const ptr1 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1131
- const len1 = WASM_VECTOR_LEN;
1132
1181
  _assertClass(wallet_keys, WasmRootWalletKeys);
1133
- wasm.bitgopsbt_from_half_signed_legacy_transaction(retptr, ptr0, len0, ptr1, len1, wallet_keys.__wbg_ptr, addHeapObject(unspents));
1182
+ wasm.bitgopsbt_from_half_signed_legacy_transaction(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents));
1183
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1184
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1185
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1186
+ if (r2) {
1187
+ throw takeObject(r1);
1188
+ }
1189
+ return BitGoPsbt.__wrap(r0);
1190
+ } finally {
1191
+ wasm.__wbindgen_add_to_stack_pointer(16);
1192
+ }
1193
+ }
1194
+ /**
1195
+ * Convert a half-signed legacy Dash transaction to a psbt-lite.
1196
+ *
1197
+ * # Arguments
1198
+ * * `tx` - The decoded Dash transaction
1199
+ * * `network` - Network name ("dash" or "tdash")
1200
+ * * `wallet_keys` - The wallet's root keys
1201
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
1202
+ * @param {WasmDashTransaction} tx
1203
+ * @param {string} network
1204
+ * @param {WasmRootWalletKeys} wallet_keys
1205
+ * @param {any} unspents
1206
+ * @returns {BitGoPsbt}
1207
+ */
1208
+ static from_half_signed_legacy_transaction_dash(tx, network, wallet_keys, unspents) {
1209
+ try {
1210
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1211
+ _assertClass(tx, WasmDashTransaction);
1212
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1213
+ const len0 = WASM_VECTOR_LEN;
1214
+ _assertClass(wallet_keys, WasmRootWalletKeys);
1215
+ wasm.bitgopsbt_from_half_signed_legacy_transaction_dash(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents));
1216
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1217
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1218
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1219
+ if (r2) {
1220
+ throw takeObject(r1);
1221
+ }
1222
+ return BitGoPsbt.__wrap(r0);
1223
+ } finally {
1224
+ wasm.__wbindgen_add_to_stack_pointer(16);
1225
+ }
1226
+ }
1227
+ /**
1228
+ * Convert a half-signed legacy Zcash transaction to a psbt-lite (with block height).
1229
+ * Thin wrapper: resolves block_height → consensus_branch_id and delegates to the explicit variant.
1230
+ *
1231
+ * # Arguments
1232
+ * * `tx` - The decoded Zcash transaction
1233
+ * * `network` - Network name ("zec" or "tzec")
1234
+ * * `wallet_keys` - The wallet's root keys
1235
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
1236
+ * * `block_height` - Block height to determine consensus branch ID
1237
+ * @param {WasmZcashTransaction} tx
1238
+ * @param {string} network
1239
+ * @param {WasmRootWalletKeys} wallet_keys
1240
+ * @param {any} unspents
1241
+ * @param {number} block_height
1242
+ * @returns {BitGoPsbt}
1243
+ */
1244
+ static from_half_signed_legacy_transaction_zcash_with_block_height(tx, network, wallet_keys, unspents, block_height) {
1245
+ try {
1246
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1247
+ _assertClass(tx, WasmZcashTransaction);
1248
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1249
+ const len0 = WASM_VECTOR_LEN;
1250
+ _assertClass(wallet_keys, WasmRootWalletKeys);
1251
+ wasm.bitgopsbt_from_half_signed_legacy_transaction_zcash_with_block_height(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents), block_height);
1252
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1253
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1254
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
1255
+ if (r2) {
1256
+ throw takeObject(r1);
1257
+ }
1258
+ return BitGoPsbt.__wrap(r0);
1259
+ } finally {
1260
+ wasm.__wbindgen_add_to_stack_pointer(16);
1261
+ }
1262
+ }
1263
+ /**
1264
+ * Convert a half-signed legacy Zcash transaction to a psbt-lite (with consensus branch ID).
1265
+ *
1266
+ * # Arguments
1267
+ * * `tx` - The decoded Zcash transaction
1268
+ * * `network` - Network name ("zec" or "tzec")
1269
+ * * `wallet_keys` - The wallet's root keys
1270
+ * * `unspents` - Array of `{ chain: number, index: number, value: bigint }` for each input
1271
+ * * `consensus_branch_id` - Zcash consensus branch ID
1272
+ * @param {WasmZcashTransaction} tx
1273
+ * @param {string} network
1274
+ * @param {WasmRootWalletKeys} wallet_keys
1275
+ * @param {any} unspents
1276
+ * @param {number} consensus_branch_id
1277
+ * @returns {BitGoPsbt}
1278
+ */
1279
+ static from_half_signed_legacy_transaction_zcash_with_branch_id(tx, network, wallet_keys, unspents, consensus_branch_id) {
1280
+ try {
1281
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
1282
+ _assertClass(tx, WasmZcashTransaction);
1283
+ const ptr0 = passStringToWasm0(network, wasm.__wbindgen_export, wasm.__wbindgen_export2);
1284
+ const len0 = WASM_VECTOR_LEN;
1285
+ _assertClass(wallet_keys, WasmRootWalletKeys);
1286
+ wasm.bitgopsbt_from_half_signed_legacy_transaction_zcash_with_branch_id(retptr, tx.__wbg_ptr, ptr0, len0, wallet_keys.__wbg_ptr, addHeapObject(unspents), consensus_branch_id);
1134
1287
  var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
1135
1288
  var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
1136
1289
  var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
@@ -5049,6 +5202,56 @@ class WrapPsbt {
5049
5202
  const ret = wasm.wrappsbt_clone(this.__wbg_ptr);
5050
5203
  return WrapPsbt.__wrap(ret);
5051
5204
  }
5205
+ /**
5206
+ * @param {number} index
5207
+ * @param {any} key
5208
+ */
5209
+ delete_input_kv(index, key) {
5210
+ try {
5211
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5212
+ wasm.wrappsbt_delete_input_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
5213
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5214
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5215
+ if (r1) {
5216
+ throw takeObject(r0);
5217
+ }
5218
+ } finally {
5219
+ wasm.__wbindgen_add_to_stack_pointer(16);
5220
+ }
5221
+ }
5222
+ /**
5223
+ * @param {any} key
5224
+ */
5225
+ delete_kv(key) {
5226
+ try {
5227
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5228
+ wasm.wrappsbt_delete_kv(retptr, this.__wbg_ptr, addHeapObject(key));
5229
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5230
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5231
+ if (r1) {
5232
+ throw takeObject(r0);
5233
+ }
5234
+ } finally {
5235
+ wasm.__wbindgen_add_to_stack_pointer(16);
5236
+ }
5237
+ }
5238
+ /**
5239
+ * @param {number} index
5240
+ * @param {any} key
5241
+ */
5242
+ delete_output_kv(index, key) {
5243
+ try {
5244
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
5245
+ wasm.wrappsbt_delete_output_kv(retptr, this.__wbg_ptr, index, addHeapObject(key));
5246
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
5247
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
5248
+ if (r1) {
5249
+ throw takeObject(r0);
5250
+ }
5251
+ } finally {
5252
+ wasm.__wbindgen_add_to_stack_pointer(16);
5253
+ }
5254
+ }
5052
5255
  /**
5053
5256
  * @param {Uint8Array} psbt
5054
5257
  * @returns {WrapPsbt}
Binary file