@bitgo/wasm-utxo 1.34.0 → 1.36.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 (44) hide show
  1. package/dist/cjs/js/bip32.d.ts +19 -0
  2. package/dist/cjs/js/bip32.js +29 -0
  3. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +8 -6
  4. package/dist/cjs/js/index.d.ts +7 -1
  5. package/dist/cjs/js/index.js +2 -2
  6. package/dist/cjs/js/message.d.ts +36 -0
  7. package/dist/cjs/js/message.js +47 -0
  8. package/dist/cjs/js/testutils/descriptor/descriptors.d.ts +27 -0
  9. package/dist/cjs/js/testutils/descriptor/descriptors.js +163 -0
  10. package/dist/cjs/js/testutils/descriptor/index.d.ts +2 -0
  11. package/dist/cjs/js/testutils/descriptor/index.js +18 -0
  12. package/dist/cjs/js/testutils/descriptor/mockPsbt.d.ts +41 -0
  13. package/dist/cjs/js/testutils/descriptor/mockPsbt.js +62 -0
  14. package/dist/cjs/js/testutils/fixtures.d.ts +35 -0
  15. package/dist/cjs/js/testutils/fixtures.js +244 -0
  16. package/dist/cjs/js/testutils/index.d.ts +2 -0
  17. package/dist/cjs/js/testutils/index.js +25 -0
  18. package/dist/cjs/js/wasm/wasm_utxo.d.ts +1417 -1331
  19. package/dist/cjs/js/wasm/wasm_utxo.js +2093 -1996
  20. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  21. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +114 -108
  22. package/dist/esm/js/bip32.d.ts +19 -0
  23. package/dist/esm/js/bip32.js +29 -0
  24. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +8 -6
  25. package/dist/esm/js/index.d.ts +7 -1
  26. package/dist/esm/js/index.js +1 -1
  27. package/dist/esm/js/message.d.ts +36 -0
  28. package/dist/esm/js/message.js +43 -0
  29. package/dist/esm/js/testutils/descriptor/descriptors.d.ts +27 -0
  30. package/dist/esm/js/testutils/descriptor/descriptors.js +150 -0
  31. package/dist/esm/js/testutils/descriptor/index.d.ts +2 -0
  32. package/dist/esm/js/testutils/descriptor/index.js +2 -0
  33. package/dist/esm/js/testutils/descriptor/mockPsbt.d.ts +41 -0
  34. package/dist/esm/js/testutils/descriptor/mockPsbt.js +56 -0
  35. package/dist/esm/js/testutils/fixtures.d.ts +35 -0
  36. package/dist/esm/js/testutils/fixtures.js +205 -0
  37. package/dist/esm/js/testutils/index.d.ts +2 -0
  38. package/dist/esm/js/testutils/index.js +2 -0
  39. package/dist/esm/js/wasm/wasm_utxo.d.ts +1417 -1331
  40. package/dist/esm/js/wasm/wasm_utxo.js +7 -2
  41. package/dist/esm/js/wasm/wasm_utxo_bg.js +2096 -2008
  42. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  43. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +114 -108
  44. package/package.json +11 -1
@@ -2,1383 +2,1469 @@
2
2
  /* eslint-disable */
3
3
 
4
4
  export class AddressNamespace {
5
- private constructor();
6
- free(): void;
7
- [Symbol.dispose](): void;
8
- static to_output_script_with_coin(address: string, coin: string): Uint8Array;
9
- static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
5
+ private constructor();
6
+ free(): void;
7
+ [Symbol.dispose](): void;
8
+ static from_output_script_with_coin(script: Uint8Array, coin: string, format?: string | null): string;
9
+ static to_output_script_with_coin(address: string, coin: string): Uint8Array;
10
10
  }
11
11
 
12
+ /**
13
+ * Namespace for BIP-0322 functions
14
+ */
12
15
  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;
16
+ private constructor();
17
+ free(): void;
18
+ [Symbol.dispose](): void;
19
+ /**
20
+ * Add a BIP-0322 message input to an existing BitGoPsbt
21
+ *
22
+ * If this is the first input, also adds the OP_RETURN output.
23
+ * The PSBT must have version 0 per BIP-0322 specification.
24
+ *
25
+ * # Arguments
26
+ * * `psbt` - The BitGoPsbt to add the input to
27
+ * * `message` - The message to sign
28
+ * * `chain` - The wallet chain (e.g., 10 for external, 20 for internal)
29
+ * * `index` - The address index
30
+ * * `wallet_keys` - The wallet's root keys
31
+ * * `signer` - Optional signer key name for taproot (e.g., "user", "backup", "bitgo")
32
+ * * `cosigner` - Optional cosigner key name for taproot
33
+ * * `tag` - Optional custom tag for message hashing
34
+ *
35
+ * # Returns
36
+ * The index of the added input
37
+ */
38
+ 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;
39
+ /**
40
+ * Verify a single input of a BIP-0322 PSBT proof
41
+ *
42
+ * # Arguments
43
+ * * `psbt` - The signed BitGoPsbt
44
+ * * `input_index` - The index of the input to verify
45
+ * * `message` - The message that was signed
46
+ * * `chain` - The wallet chain
47
+ * * `index` - The address index
48
+ * * `wallet_keys` - The wallet's root keys
49
+ * * `tag` - Optional custom tag for message hashing
50
+ *
51
+ * # Returns
52
+ * An array of signer names ("user", "backup", "bitgo") that have valid signatures
53
+ *
54
+ * # Throws
55
+ * Throws an error if verification fails or no valid signatures found
56
+ */
57
+ static verify_bip322_psbt_input(psbt: BitGoPsbt, input_index: number, message: string, chain: number, index: number, wallet_keys: WasmRootWalletKeys, tag?: string | null): string[];
58
+ /**
59
+ * Verify a single input of a BIP-0322 PSBT proof using pubkeys directly
60
+ *
61
+ * # Arguments
62
+ * * `psbt` - The signed BitGoPsbt
63
+ * * `input_index` - The index of the input to verify
64
+ * * `message` - The message that was signed
65
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
66
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
67
+ * * `is_script_path` - For taproot types, whether script path was used
68
+ * * `tag` - Optional custom tag for message hashing
69
+ *
70
+ * # Returns
71
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
72
+ *
73
+ * # Throws
74
+ * Throws an error if verification fails or no valid signatures found
75
+ */
76
+ 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;
77
+ /**
78
+ * Verify a single input of a BIP-0322 transaction proof
79
+ *
80
+ * # Arguments
81
+ * * `tx` - The signed transaction
82
+ * * `input_index` - The index of the input to verify
83
+ * * `message` - The message that was signed
84
+ * * `chain` - The wallet chain
85
+ * * `index` - The address index
86
+ * * `wallet_keys` - The wallet's root keys
87
+ * * `network` - Network name
88
+ * * `tag` - Optional custom tag for message hashing
89
+ *
90
+ * # Throws
91
+ * Throws an error if verification fails
92
+ */
93
+ 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;
94
+ /**
95
+ * Verify a single input of a BIP-0322 transaction proof using pubkeys directly
96
+ *
97
+ * # Arguments
98
+ * * `tx` - The signed transaction
99
+ * * `input_index` - The index of the input to verify
100
+ * * `message` - The message that was signed
101
+ * * `pubkeys` - Array of 3 hex-encoded pubkeys [user, backup, bitgo]
102
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
103
+ * * `is_script_path` - For taproot types, whether script path was used
104
+ * * `tag` - Optional custom tag for message hashing
105
+ *
106
+ * # Returns
107
+ * An array of pubkey indices (0, 1, 2) that have valid signatures
108
+ *
109
+ * # Throws
110
+ * Throws an error if verification fails
111
+ */
112
+ 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;
110
113
  }
111
114
 
112
115
  export class BitGoPsbt {
113
- private constructor();
114
- free(): void;
115
- [Symbol.dispose](): void;
116
- /**
117
- * Add an output to the PSBT
118
- *
119
- * # Arguments
120
- * * `script` - The output script (scriptPubKey)
121
- * * `value` - The value in satoshis
122
- *
123
- * # Returns
124
- * The index of the newly added output
125
- */
126
- add_output(script: Uint8Array, value: bigint): number;
127
- /**
128
- * Deserialize a PSBT from bytes with network-specific logic
129
- */
130
- static from_bytes(bytes: Uint8Array, network: string): BitGoPsbt;
131
- /**
132
- * Create an empty PSBT for the given network with wallet keys
133
- *
134
- * # Arguments
135
- * * `network` - Network name (utxolib or coin name)
136
- * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
137
- * * `version` - Optional transaction version (default: 2)
138
- * * `lock_time` - Optional lock time (default: 0)
139
- */
140
- static create_empty(network: string, wallet_keys: WasmRootWalletKeys, version?: number | null, lock_time?: number | null): BitGoPsbt;
141
- /**
142
- * Get the Zcash expiry height (returns None for non-Zcash PSBTs)
143
- */
144
- expiry_height(): number | undefined;
145
- /**
146
- * Get the unsigned transaction ID
147
- */
148
- unsigned_txid(): string;
149
- /**
150
- * Check if an input is a MuSig2 keypath input.
151
- *
152
- * MuSig2 inputs require special handling: nonces must be generated first with
153
- * `generate_musig2_nonces()`, then signed with `sign_musig2_input()`.
154
- *
155
- * # Arguments
156
- * - `input_index`: The index of the input to check (0-based)
157
- *
158
- * # Returns
159
- * - `true` if the input is a MuSig2 keypath input
160
- * - `false` otherwise (or if input_index is out of bounds)
161
- */
162
- is_musig2_input(input_index: number): boolean;
163
- /**
164
- * Sign a single input with an extended private key (xpriv)
165
- *
166
- * This method signs a specific input using the provided xpriv. It accepts:
167
- * - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
168
- *
169
- * This method automatically detects and handles different input types:
170
- * - For regular inputs: uses standard PSBT signing
171
- * - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
172
- * - For replay protection inputs: returns error (use sign_with_privkey instead)
173
- *
174
- * # Arguments
175
- * - `input_index`: The index of the input to sign (0-based)
176
- * - `xpriv`: The extended private key as a WasmBIP32 instance
177
- *
178
- * # Returns
179
- * - `Ok(())` if signing was successful
180
- * - `Err(WasmUtxoError)` if signing fails
181
- */
182
- sign_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
183
- /**
184
- * Add a wallet input with full PSBT metadata
185
- *
186
- * This is a higher-level method that adds an input and populates all required
187
- * PSBT fields (scripts, derivation info, etc.) based on the wallet's chain type.
188
- *
189
- * # Arguments
190
- * * `txid` - The transaction ID (hex string)
191
- * * `vout` - The output index being spent
192
- * * `value` - The value in satoshis
193
- * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
194
- * * `index` - The derivation index
195
- * * `wallet_keys` - The root wallet keys
196
- * * `signer` - The key that will sign ("user", "backup", or "bitgo") - required for p2tr/p2trMusig2
197
- * * `cosigner` - The key that will co-sign - required for p2tr/p2trMusig2
198
- * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
199
- * * `prev_tx` - Optional full previous transaction bytes (for non-segwit)
200
- *
201
- * # Returns
202
- * The index of the newly added input
203
- */
204
- add_wallet_input(txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
205
- /**
206
- * Get the network type for transaction extraction
207
- *
208
- * Returns "bitcoin", "dash", or "zcash" to indicate which transaction
209
- * wrapper class should be used in TypeScript.
210
- */
211
- get_network_type(): string;
212
- /**
213
- * Get the Zcash version group ID (returns None for non-Zcash PSBTs)
214
- */
215
- version_group_id(): number | undefined;
216
- /**
217
- * Add a wallet output with full PSBT metadata
218
- *
219
- * This creates a verifiable wallet output (typically for change) with all required
220
- * PSBT fields (scripts, derivation info) based on the wallet's chain type.
221
- *
222
- * # Arguments
223
- * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
224
- * * `index` - The derivation index
225
- * * `value` - The value in satoshis
226
- * * `wallet_keys` - The root wallet keys
227
- *
228
- * # Returns
229
- * The index of the newly added output
230
- */
231
- add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
232
- /**
233
- * Sign a single MuSig2 keypath input.
234
- *
235
- * This uses the FirstRound state generated by `generate_musig2_nonces()`.
236
- * Each FirstRound can only be used once (nonce reuse is a security risk).
237
- *
238
- * For non-MuSig2 inputs, returns an error (use `sign_wallet_input` instead).
239
- *
240
- * # Arguments
241
- * - `input_index`: The index of the input to sign (0-based)
242
- * - `xpriv`: The extended private key as a WasmBIP32 instance
243
- *
244
- * # Returns
245
- * - `Ok(())` if signing was successful
246
- * - `Err(WasmUtxoError)` if signing fails, no FirstRound exists, or not a MuSig2 input
247
- */
248
- sign_musig2_input(input_index: number, xpriv: WasmBIP32): void;
249
- /**
250
- * Sign a single non-MuSig2 wallet input using save/restore pattern.
251
- *
252
- * For MuSig2 inputs, returns an error (use `sign_musig2_input` instead).
253
- * For ECDSA inputs, this uses a save/restore pattern: clones the PSBT,
254
- * signs all inputs on the clone, then copies only the target input's
255
- * signatures back.
256
- *
257
- * **Important:** This is NOT faster than `sign_all_wallet_inputs()` for ECDSA inputs.
258
- * The underlying library signs all inputs regardless. This method just ensures
259
- * that only the specified input gets signatures added to the PSBT.
260
- * Use `sign_all_wallet_inputs()` when signing multiple inputs with the same key.
261
- *
262
- * # Arguments
263
- * - `input_index`: The index of the input to sign (0-based)
264
- * - `xpriv`: The extended private key as a WasmBIP32 instance
265
- *
266
- * # Returns
267
- * - `Ok(())` if the input was signed
268
- * - `Err(WasmUtxoError)` if signing fails or input is MuSig2
269
- */
270
- sign_wallet_input(input_index: number, xpriv: WasmBIP32): void;
271
- /**
272
- * Sign a single input with a raw private key
273
- *
274
- * This method signs a specific input using the provided ECPair. It accepts:
275
- * - A raw privkey (WasmECPair) for replay protection inputs - signs directly
276
- *
277
- * This method automatically detects and handles different input types:
278
- * - For replay protection inputs: signs with legacy P2SH sighash
279
- * - For regular inputs: uses standard PSBT signing
280
- * - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
281
- *
282
- * # Arguments
283
- * - `input_index`: The index of the input to sign (0-based)
284
- * - `ecpair`: The ECPair containing the private key
285
- *
286
- * # Returns
287
- * - `Ok(())` if signing was successful
288
- * - `Err(WasmUtxoError)` if signing fails
289
- */
290
- sign_with_privkey(input_index: number, ecpair: WasmECPair): void;
291
- /**
292
- * Create an empty Zcash PSBT with the required consensus branch ID
293
- *
294
- * This method is specifically for Zcash networks which require additional
295
- * parameters for sighash computation.
296
- *
297
- * # Arguments
298
- * * `network` - Network name (must be "zcash" or "zcashTest")
299
- * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
300
- * * `consensus_branch_id` - Zcash consensus branch ID (e.g., 0xC2D6D0B4 for NU5)
301
- * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
302
- * * `lock_time` - Optional lock time (default: 0)
303
- * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
304
- * * `expiry_height` - Optional expiry height
305
- */
306
- static create_empty_zcash(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
307
- /**
308
- * Extract the final transaction from a finalized PSBT
309
- *
310
- * This method should be called after all inputs have been finalized.
311
- * It extracts the fully signed transaction with network-appropriate serialization.
312
- *
313
- * # Returns
314
- * - `Ok(Vec<u8>)` containing the serialized transaction bytes
315
- * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
316
- */
317
- extract_transaction(): Uint8Array;
318
- /**
319
- * Finalize all inputs in the PSBT
320
- *
321
- * This method attempts to finalize all inputs in the PSBT, computing the final
322
- * scriptSig and witness data for each input.
323
- *
324
- * # Returns
325
- * - `Ok(())` if all inputs were successfully finalized
326
- * - `Err(WasmUtxoError)` if any input failed to finalize
327
- */
328
- finalize_all_inputs(): void;
329
- /**
330
- * Sign all non-MuSig2 inputs with an extended private key (xpriv) in a single pass.
331
- *
332
- * This is more efficient than calling `sign_with_xpriv` for each input individually.
333
- * The underlying miniscript library's `sign` method signs all matching inputs at once.
334
- *
335
- * **Note:** MuSig2 inputs are skipped by this method because they require FirstRound
336
- * state from nonce generation. After calling this method, sign MuSig2 inputs
337
- * individually using `sign_with_xpriv`.
338
- *
339
- * # Arguments
340
- * - `xpriv`: The extended private key as a WasmBIP32 instance
341
- *
342
- * # Returns
343
- * - `Ok(JsValue)` with an array of input indices that were signed
344
- * - `Err(WasmUtxoError)` if signing fails
345
- */
346
- sign_all_with_xpriv(xpriv: WasmBIP32): any;
347
- /**
348
- * Add a PayGo attestation to a PSBT output
349
- *
350
- * # Arguments
351
- * - `output_index`: The index of the output to add the attestation to
352
- * - `entropy`: 64 bytes of entropy
353
- * - `signature`: ECDSA signature bytes
354
- *
355
- * # Returns
356
- * - `Ok(())` if the attestation was successfully added
357
- * - `Err(WasmUtxoError)` if the output index is out of bounds or entropy is invalid
358
- */
359
- add_paygo_attestation(output_index: number, entropy: Uint8Array, signature: Uint8Array): void;
360
- /**
361
- * Combine/merge data from another PSBT into this one
362
- *
363
- * This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
364
- * source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
365
- * and signature collection phases.
366
- *
367
- * # Arguments
368
- * * `source_psbt` - The source PSBT containing data to merge
369
- *
370
- * # Returns
371
- * Ok(()) if data was successfully merged
372
- *
373
- * # Errors
374
- * Returns error if networks don't match
375
- */
376
- combine_musig2_nonces(source_psbt: BitGoPsbt): void;
377
- /**
378
- * Generate and store MuSig2 nonces for all MuSig2 inputs
379
- *
380
- * This method generates nonces using the State-Machine API and stores them in the PSBT.
381
- * The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
382
- * After ALL participants have generated their nonces, they can sign MuSig2 inputs using
383
- * sign_with_xpriv().
384
- *
385
- * # Arguments
386
- * * `xpriv` - The extended private key (xpriv) for signing
387
- * * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
388
- * On mainnets, a secure random session ID is always generated automatically.
389
- * Must be unique per signing session.
390
- *
391
- * # Returns
392
- * Ok(()) if nonces were successfully generated and stored
393
- *
394
- * # Errors
395
- * Returns error if:
396
- * - Nonce generation fails
397
- * - session_id length is invalid
398
- * - Custom session_id is provided on a mainnet (security restriction)
399
- *
400
- * # Security
401
- * The session_id MUST be cryptographically random and unique for each signing session.
402
- * Never reuse a session_id with the same key! On mainnets, session_id is always randomly
403
- * generated for security. Custom session_id is only allowed on testnets for testing purposes.
404
- */
405
- generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
406
- /**
407
- * Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
408
- *
409
- * This is more efficient than calling `sign_musig2_input()` for each input because
410
- * it reuses the SighashCache across all inputs, avoiding redundant computation of
411
- * sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs.
412
- *
413
- * Each MuSig2 input requires a FirstRound from `generate_musig2_nonces()`.
414
- * FirstRounds that have already been consumed (signed) are skipped.
415
- *
416
- * # Arguments
417
- * - `xpriv`: The extended private key as a WasmBIP32 instance
418
- *
419
- * # Returns
420
- * - `Ok(JsValue)` with an array of input indices that were signed
421
- * - `Err(WasmUtxoError)` if signing fails
422
- */
423
- sign_all_musig2_inputs(xpriv: WasmBIP32): any;
424
- /**
425
- * Sign all non-MuSig2 wallet inputs in a single efficient pass.
426
- *
427
- * This signs all ECDSA (P2SH, P2SH-P2WSH, P2WSH) and Taproot script path (P2TR)
428
- * inputs that match the provided xpriv. MuSig2 keypath inputs are skipped.
429
- *
430
- * This is the most efficient way to sign wallet inputs. After calling this,
431
- * sign any MuSig2 inputs using `sign_all_musig2_inputs()` or `sign_musig2_input()`.
432
- *
433
- * # Arguments
434
- * - `xpriv`: The extended private key as a WasmBIP32 instance
435
- *
436
- * # Returns
437
- * - `Ok(JsValue)` with an array of input indices that were signed
438
- * - `Err(WasmUtxoError)` if signing fails
439
- */
440
- sign_all_wallet_inputs(xpriv: WasmBIP32): any;
441
- /**
442
- * Add an output to the PSBT by address
443
- *
444
- * # Arguments
445
- * * `address` - The destination address
446
- * * `value` - The value in satoshis
447
- *
448
- * # Returns
449
- * The index of the newly added output
450
- */
451
- add_output_with_address(address: string, value: bigint): number;
452
- /**
453
- * Extract the final transaction as a WasmDashTransaction (for Dash networks)
454
- *
455
- * This avoids re-parsing bytes by returning the transaction directly.
456
- * Only valid for Dash networks.
457
- */
458
- extract_dash_transaction(): WasmDashTransaction;
459
- /**
460
- * Extract the final transaction as a WasmZcashTransaction (for Zcash networks)
461
- *
462
- * This avoids re-parsing bytes by returning the transaction directly.
463
- * Only valid for Zcash networks.
464
- */
465
- extract_zcash_transaction(): WasmZcashTransaction;
466
- /**
467
- * Verify if a valid signature exists for a given ECPair key at the specified input index
468
- *
469
- * This method verifies the signature directly with the provided ECPair's public key. It supports:
470
- * - ECDSA signatures (for legacy/SegWit inputs)
471
- * - Schnorr signatures (for Taproot script path inputs)
472
- *
473
- * Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
474
- * Use `verify_signature_with_xpub` for MuSig2 inputs.
475
- *
476
- * # Arguments
477
- * - `input_index`: The index of the input to check
478
- * - `ecpair`: The ECPair key (uses the public key for verification)
479
- *
480
- * # Returns
481
- * - `Ok(true)` if a valid signature exists for the public key
482
- * - `Ok(false)` if no signature exists for the public key
483
- * - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
484
- */
485
- verify_signature_with_pub(input_index: number, ecpair: WasmECPair): boolean;
486
- /**
487
- * Verify if a valid signature exists for a given xpub at the specified input index
488
- *
489
- * This method derives the public key from the xpub using the derivation path found in the
490
- * PSBT input, then verifies the signature. It supports:
491
- * - ECDSA signatures (for legacy/SegWit inputs)
492
- * - Schnorr signatures (for Taproot script path inputs)
493
- * - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
494
- *
495
- * # Arguments
496
- * - `input_index`: The index of the input to check
497
- * - `xpub`: The extended public key as a WasmBIP32 instance
498
- *
499
- * # Returns
500
- * - `Ok(true)` if a valid signature exists for the derived public key
501
- * - `Ok(false)` if no signature exists for the derived public key
502
- * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
503
- */
504
- verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
505
- /**
506
- * Add a replay protection input to the PSBT
507
- *
508
- * Replay protection inputs are P2SH-P2PK inputs used on forked networks to prevent
509
- * transaction replay attacks. They use a simple pubkey script without wallet derivation.
510
- *
511
- * # Arguments
512
- * * `ecpair` - The ECPair containing the public key for the replay protection input
513
- * * `txid` - The transaction ID (hex string) of the output being spent
514
- * * `vout` - The output index being spent
515
- * * `value` - The value in satoshis
516
- * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
517
- *
518
- * # Returns
519
- * The index of the newly added input
520
- */
521
- add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null): number;
522
- /**
523
- * Extract the final transaction as a WasmTransaction (for BitcoinLike networks)
524
- *
525
- * This avoids re-parsing bytes by returning the transaction directly.
526
- * Only valid for Bitcoin-like networks (not Dash or Zcash).
527
- */
528
- extract_bitcoin_transaction(): WasmTransaction;
529
- /**
530
- * Create an empty Zcash PSBT with consensus branch ID determined from block height
531
- *
532
- * This method automatically determines the correct consensus branch ID based on
533
- * the network and block height using the network upgrade activation heights.
534
- *
535
- * # Arguments
536
- * * `network` - Network name (must be "zcash" or "zcashTest")
537
- * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
538
- * * `block_height` - Block height to determine consensus rules
539
- * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
540
- * * `lock_time` - Optional lock time (default: 0)
541
- * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
542
- * * `expiry_height` - Optional expiry height
543
- *
544
- * # Errors
545
- * Returns error if block height is before Overwinter activation
546
- */
547
- 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;
548
- /**
549
- * Sign a single input with an extended private key, using save/restore for ECDSA inputs.
550
- *
551
- * For MuSig2 inputs, this returns an error (use sign_with_xpriv which handles FirstRound).
552
- * For ECDSA inputs, this clones the PSBT, signs all, then copies only the target
553
- * input's signatures back.
554
- *
555
- * **Important:** This is NOT faster than `sign_all_with_xpriv` for ECDSA inputs.
556
- * The underlying miniscript library signs all inputs regardless. This method
557
- * just prevents signatures from being added to other inputs.
558
- *
559
- * # Arguments
560
- * - `input_index`: The index of the input to sign (0-based)
561
- * - `xpriv`: The extended private key as a WasmBIP32 instance
562
- *
563
- * # Returns
564
- * - `Ok(())` if the input was signed
565
- * - `Err(WasmUtxoError)` if signing fails
566
- */
567
- sign_single_input_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
568
- /**
569
- * Extract a half-signed transaction in legacy format for p2ms-based script types.
570
- *
571
- * This method extracts a transaction where each input has exactly one signature,
572
- * formatted in the legacy style used by utxo-lib and bitcoinjs-lib. The legacy
573
- * format places signatures in the correct position (0, 1, or 2) based on which
574
- * key signed, with empty placeholders for unsigned positions.
575
- *
576
- * # Requirements
577
- * - All inputs must be p2ms-based (p2sh, p2shP2wsh, or p2wsh)
578
- * - Each input must have exactly 1 partial signature
579
- *
580
- * # Returns
581
- * - `Ok(Vec<u8>)` containing the serialized half-signed transaction bytes
582
- * - `Err(WasmUtxoError)` if validation fails or extraction fails
583
- *
584
- * # Errors
585
- * - Returns error if any input is not a p2ms type (Taproot, replay protection, etc.)
586
- * - Returns error if any input has 0 or more than 1 partial signature
587
- */
588
- extract_half_signed_legacy_tx(): Uint8Array;
589
- /**
590
- * Sign all replay protection inputs with a raw private key.
591
- *
592
- * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
593
- * that match the provided public key and signs them.
594
- *
595
- * # Arguments
596
- * - `ecpair`: The ECPair containing the private key
597
- *
598
- * # Returns
599
- * - `Ok(JsValue)` with an array of input indices that were signed
600
- * - `Err(WasmUtxoError)` if signing fails
601
- */
602
- sign_replay_protection_inputs(ecpair: WasmECPair): any;
603
- /**
604
- * Parse outputs with wallet keys to identify which outputs belong to a wallet
605
- *
606
- * Note: This method does NOT validate wallet inputs. It only parses outputs.
607
- */
608
- parse_outputs_with_wallet_keys(wallet_keys: WasmRootWalletKeys, paygo_pubkeys?: WasmECPair[] | null): any;
609
- /**
610
- * Sign a single input with a raw private key, using save/restore for regular inputs.
611
- *
612
- * For replay protection inputs (P2SH-P2PK), this uses direct signing which is
613
- * already single-input. For regular inputs, this clones the PSBT, signs all,
614
- * then copies only the target input's signatures back.
615
- *
616
- * **Important:** This is NOT faster than signing all inputs for regular (non-RP) inputs.
617
- * The underlying miniscript library signs all inputs regardless.
618
- *
619
- * # Arguments
620
- * - `input_index`: The index of the input to sign (0-based)
621
- * - `ecpair`: The ECPair containing the private key
622
- *
623
- * # Returns
624
- * - `Ok(())` if the input was signed
625
- * - `Err(WasmUtxoError)` if signing fails
626
- */
627
- sign_single_input_with_privkey(input_index: number, ecpair: WasmECPair): void;
628
- /**
629
- * Sign all replay protection inputs with a raw private key.
630
- *
631
- * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
632
- * that match the provided public key and signs them.
633
- *
634
- * # Arguments
635
- * - `ecpair`: The ECPair containing the private key
636
- *
637
- * # Returns
638
- * - `Ok(JsValue)` with an array of input indices that were signed
639
- * - `Err(WasmUtxoError)` if signing fails
640
- */
641
- sign_all_replay_protection_inputs(ecpair: WasmECPair): any;
642
- /**
643
- * Parse transaction with wallet keys to identify wallet inputs/outputs
644
- */
645
- parse_transaction_with_wallet_keys(wallet_keys: WasmRootWalletKeys, replay_protection: WasmReplayProtection, paygo_pubkeys?: WasmECPair[] | null): any;
646
- /**
647
- * Verify if a replay protection input has a valid signature
648
- *
649
- * This method checks if a given input is a replay protection input and cryptographically verifies
650
- * the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
651
- * so this method verifies signatures without deriving from xpub.
652
- *
653
- * # Arguments
654
- * - `input_index`: The index of the input to check
655
- * - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
656
- * Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
657
- *
658
- * # Returns
659
- * - `Ok(true)` if the input is a replay protection input and has a valid signature
660
- * - `Ok(false)` if the input is a replay protection input but has no valid signature
661
- * - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
662
- */
663
- verify_replay_protection_signature(input_index: number, replay_protection: WasmReplayProtection): boolean;
664
- /**
665
- * Get the network of the PSBT
666
- */
667
- network(): string;
668
- /**
669
- * Get the transaction version
670
- */
671
- version(): number;
672
- /**
673
- * Add an input to the PSBT
674
- *
675
- * # Arguments
676
- * * `txid` - The transaction ID (hex string) of the output being spent
677
- * * `vout` - The output index being spent
678
- * * `value` - The value in satoshis of the output being spent
679
- * * `script` - The output script (scriptPubKey) of the output being spent
680
- * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
681
- *
682
- * # Returns
683
- * The index of the newly added input
684
- */
685
- add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
686
- /**
687
- * Get the transaction lock time
688
- */
689
- lock_time(): number;
690
- /**
691
- * Serialize the PSBT to bytes
692
- *
693
- * # Returns
694
- * The serialized PSBT as a byte array
695
- */
696
- serialize(): Uint8Array;
116
+ private constructor();
117
+ free(): void;
118
+ [Symbol.dispose](): void;
119
+ /**
120
+ * Add an input to the PSBT
121
+ *
122
+ * # Arguments
123
+ * * `txid` - The transaction ID (hex string) of the output being spent
124
+ * * `vout` - The output index being spent
125
+ * * `value` - The value in satoshis of the output being spent
126
+ * * `script` - The output script (scriptPubKey) of the output being spent
127
+ * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
128
+ *
129
+ * # Returns
130
+ * The index of the newly added input
131
+ */
132
+ add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null, prev_tx?: Uint8Array | null): number;
133
+ /**
134
+ * Add an output to the PSBT
135
+ *
136
+ * # Arguments
137
+ * * `script` - The output script (scriptPubKey)
138
+ * * `value` - The value in satoshis
139
+ *
140
+ * # Returns
141
+ * The index of the newly added output
142
+ */
143
+ add_output(script: Uint8Array, value: bigint): number;
144
+ /**
145
+ * Add an output to the PSBT by address
146
+ *
147
+ * # Arguments
148
+ * * `address` - The destination address
149
+ * * `value` - The value in satoshis
150
+ *
151
+ * # Returns
152
+ * The index of the newly added output
153
+ */
154
+ add_output_with_address(address: string, value: bigint): number;
155
+ /**
156
+ * Add a PayGo attestation to a PSBT output
157
+ *
158
+ * # Arguments
159
+ * - `output_index`: The index of the output to add the attestation to
160
+ * - `entropy`: 64 bytes of entropy
161
+ * - `signature`: ECDSA signature bytes
162
+ *
163
+ * # Returns
164
+ * - `Ok(())` if the attestation was successfully added
165
+ * - `Err(WasmUtxoError)` if the output index is out of bounds or entropy is invalid
166
+ */
167
+ add_paygo_attestation(output_index: number, entropy: Uint8Array, signature: Uint8Array): void;
168
+ /**
169
+ * Add a replay protection input to the PSBT
170
+ *
171
+ * Replay protection inputs are P2SH-P2PK inputs used on forked networks to prevent
172
+ * transaction replay attacks. They use a simple pubkey script without wallet derivation.
173
+ *
174
+ * # Arguments
175
+ * * `ecpair` - The ECPair containing the public key for the replay protection input
176
+ * * `txid` - The transaction ID (hex string) of the output being spent
177
+ * * `vout` - The output index being spent
178
+ * * `value` - The value in satoshis
179
+ * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
180
+ *
181
+ * # Returns
182
+ * The index of the newly added input
183
+ */
184
+ add_replay_protection_input(ecpair: WasmECPair, txid: string, vout: number, value: bigint, sequence?: number | null): number;
185
+ /**
186
+ * Add a wallet input with full PSBT metadata
187
+ *
188
+ * This is a higher-level method that adds an input and populates all required
189
+ * PSBT fields (scripts, derivation info, etc.) based on the wallet's chain type.
190
+ *
191
+ * # Arguments
192
+ * * `txid` - The transaction ID (hex string)
193
+ * * `vout` - The output index being spent
194
+ * * `value` - The value in satoshis
195
+ * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
196
+ * * `index` - The derivation index
197
+ * * `wallet_keys` - The root wallet keys
198
+ * * `signer` - The key that will sign ("user", "backup", or "bitgo") - required for p2tr/p2trMusig2
199
+ * * `cosigner` - The key that will co-sign - required for p2tr/p2trMusig2
200
+ * * `sequence` - Optional sequence number (default: 0xFFFFFFFE for RBF)
201
+ * * `prev_tx` - Optional full previous transaction bytes (for non-segwit)
202
+ *
203
+ * # Returns
204
+ * The index of the newly added input
205
+ */
206
+ add_wallet_input(txid: string, vout: number, value: bigint, wallet_keys: WasmRootWalletKeys, chain: number, index: number, signer?: string | null, cosigner?: string | null, sequence?: number | null, prev_tx?: Uint8Array | null): number;
207
+ /**
208
+ * Add a wallet output with full PSBT metadata
209
+ *
210
+ * This creates a verifiable wallet output (typically for change) with all required
211
+ * PSBT fields (scripts, derivation info) based on the wallet's chain type.
212
+ *
213
+ * # Arguments
214
+ * * `chain` - The chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
215
+ * * `index` - The derivation index
216
+ * * `value` - The value in satoshis
217
+ * * `wallet_keys` - The root wallet keys
218
+ *
219
+ * # Returns
220
+ * The index of the newly added output
221
+ */
222
+ add_wallet_output(chain: number, index: number, value: bigint, wallet_keys: WasmRootWalletKeys): number;
223
+ /**
224
+ * Combine/merge data from another PSBT into this one
225
+ *
226
+ * This method copies MuSig2 nonces and signatures (proprietary key-value pairs) from the
227
+ * source PSBT to this PSBT. This is useful for merging PSBTs during the nonce exchange
228
+ * and signature collection phases.
229
+ *
230
+ * # Arguments
231
+ * * `source_psbt` - The source PSBT containing data to merge
232
+ *
233
+ * # Returns
234
+ * Ok(()) if data was successfully merged
235
+ *
236
+ * # Errors
237
+ * Returns error if networks don't match
238
+ */
239
+ combine_musig2_nonces(source_psbt: BitGoPsbt): void;
240
+ /**
241
+ * Create an empty PSBT for the given network with wallet keys
242
+ *
243
+ * # Arguments
244
+ * * `network` - Network name (utxolib or coin name)
245
+ * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
246
+ * * `version` - Optional transaction version (default: 2)
247
+ * * `lock_time` - Optional lock time (default: 0)
248
+ */
249
+ static create_empty(network: string, wallet_keys: WasmRootWalletKeys, version?: number | null, lock_time?: number | null): BitGoPsbt;
250
+ /**
251
+ * Create an empty Zcash PSBT with the required consensus branch ID
252
+ *
253
+ * This method is specifically for Zcash networks which require additional
254
+ * parameters for sighash computation.
255
+ *
256
+ * # Arguments
257
+ * * `network` - Network name (must be "zcash" or "zcashTest")
258
+ * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
259
+ * * `consensus_branch_id` - Zcash consensus branch ID (e.g., 0xC2D6D0B4 for NU5)
260
+ * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
261
+ * * `lock_time` - Optional lock time (default: 0)
262
+ * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
263
+ * * `expiry_height` - Optional expiry height
264
+ */
265
+ static create_empty_zcash(network: string, wallet_keys: WasmRootWalletKeys, consensus_branch_id: number, version?: number | null, lock_time?: number | null, version_group_id?: number | null, expiry_height?: number | null): BitGoPsbt;
266
+ /**
267
+ * Create an empty Zcash PSBT with consensus branch ID determined from block height
268
+ *
269
+ * This method automatically determines the correct consensus branch ID based on
270
+ * the network and block height using the network upgrade activation heights.
271
+ *
272
+ * # Arguments
273
+ * * `network` - Network name (must be "zcash" or "zcashTest")
274
+ * * `wallet_keys` - The wallet's root keys (used to set global xpubs)
275
+ * * `block_height` - Block height to determine consensus rules
276
+ * * `version` - Optional transaction version (default: 4 for Zcash Sapling+)
277
+ * * `lock_time` - Optional lock time (default: 0)
278
+ * * `version_group_id` - Optional version group ID (defaults to Sapling: 0x892F2085)
279
+ * * `expiry_height` - Optional expiry height
280
+ *
281
+ * # Errors
282
+ * Returns error if block height is before Overwinter activation
283
+ */
284
+ 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;
285
+ /**
286
+ * Get the Zcash expiry height (returns None for non-Zcash PSBTs)
287
+ */
288
+ expiry_height(): number | undefined;
289
+ /**
290
+ * Extract the final transaction as a WasmTransaction (for BitcoinLike networks)
291
+ *
292
+ * This avoids re-parsing bytes by returning the transaction directly.
293
+ * Only valid for Bitcoin-like networks (not Dash or Zcash).
294
+ */
295
+ extract_bitcoin_transaction(): WasmTransaction;
296
+ /**
297
+ * Extract the final transaction as a WasmDashTransaction (for Dash networks)
298
+ *
299
+ * This avoids re-parsing bytes by returning the transaction directly.
300
+ * Only valid for Dash networks.
301
+ */
302
+ extract_dash_transaction(): WasmDashTransaction;
303
+ /**
304
+ * Extract a half-signed transaction in legacy format for p2ms-based script types.
305
+ *
306
+ * This method extracts a transaction where each input has exactly one signature,
307
+ * formatted in the legacy style used by utxo-lib and bitcoinjs-lib. The legacy
308
+ * format places signatures in the correct position (0, 1, or 2) based on which
309
+ * key signed, with empty placeholders for unsigned positions.
310
+ *
311
+ * # Requirements
312
+ * - All inputs must be p2ms-based (p2sh, p2shP2wsh, or p2wsh)
313
+ * - Each input must have exactly 1 partial signature
314
+ *
315
+ * # Returns
316
+ * - `Ok(Vec<u8>)` containing the serialized half-signed transaction bytes
317
+ * - `Err(WasmUtxoError)` if validation fails or extraction fails
318
+ *
319
+ * # Errors
320
+ * - Returns error if any input is not a p2ms type (Taproot, replay protection, etc.)
321
+ * - Returns error if any input has 0 or more than 1 partial signature
322
+ */
323
+ extract_half_signed_legacy_tx(): Uint8Array;
324
+ /**
325
+ * Extract the final transaction from a finalized PSBT
326
+ *
327
+ * This method should be called after all inputs have been finalized.
328
+ * It extracts the fully signed transaction as a WASM transaction instance
329
+ * appropriate for the network (WasmTransaction, WasmDashTransaction, or WasmZcashTransaction).
330
+ *
331
+ * # Returns
332
+ * - `Ok(JsValue)` containing the WASM transaction instance
333
+ * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
334
+ */
335
+ extract_transaction(): any;
336
+ /**
337
+ * Extract the final transaction as a WasmZcashTransaction (for Zcash networks)
338
+ *
339
+ * This avoids re-parsing bytes by returning the transaction directly.
340
+ * Only valid for Zcash networks.
341
+ */
342
+ extract_zcash_transaction(): WasmZcashTransaction;
343
+ /**
344
+ * Finalize all inputs in the PSBT
345
+ *
346
+ * This method attempts to finalize all inputs in the PSBT, computing the final
347
+ * scriptSig and witness data for each input.
348
+ *
349
+ * # Returns
350
+ * - `Ok(())` if all inputs were successfully finalized
351
+ * - `Err(WasmUtxoError)` if any input failed to finalize
352
+ */
353
+ finalize_all_inputs(): void;
354
+ /**
355
+ * Deserialize a PSBT from bytes with network-specific logic
356
+ */
357
+ static from_bytes(bytes: Uint8Array, network: string): BitGoPsbt;
358
+ /**
359
+ * Generate and store MuSig2 nonces for all MuSig2 inputs
360
+ *
361
+ * This method generates nonces using the State-Machine API and stores them in the PSBT.
362
+ * The nonces are stored as proprietary fields in the PSBT and will be included when serialized.
363
+ * After ALL participants have generated their nonces, they can sign MuSig2 inputs using
364
+ * sign_with_xpriv().
365
+ *
366
+ * # Arguments
367
+ * * `xpriv` - The extended private key (xpriv) for signing
368
+ * * `session_id_bytes` - Optional 32-byte session ID for nonce generation. **Only allowed on testnets**.
369
+ * On mainnets, a secure random session ID is always generated automatically.
370
+ * Must be unique per signing session.
371
+ *
372
+ * # Returns
373
+ * Ok(()) if nonces were successfully generated and stored
374
+ *
375
+ * # Errors
376
+ * Returns error if:
377
+ * - Nonce generation fails
378
+ * - session_id length is invalid
379
+ * - Custom session_id is provided on a mainnet (security restriction)
380
+ *
381
+ * # Security
382
+ * The session_id MUST be cryptographically random and unique for each signing session.
383
+ * Never reuse a session_id with the same key! On mainnets, session_id is always randomly
384
+ * generated for security. Custom session_id is only allowed on testnets for testing purposes.
385
+ */
386
+ generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
387
+ /**
388
+ * Get the network type for transaction extraction
389
+ *
390
+ * Returns "bitcoin", "dash", or "zcash" to indicate which transaction
391
+ * wrapper class should be used in TypeScript.
392
+ */
393
+ get_network_type(): string;
394
+ /**
395
+ * Check if an input is a MuSig2 keypath input.
396
+ *
397
+ * MuSig2 inputs require special handling: nonces must be generated first with
398
+ * `generate_musig2_nonces()`, then signed with `sign_musig2_input()`.
399
+ *
400
+ * # Arguments
401
+ * - `input_index`: The index of the input to check (0-based)
402
+ *
403
+ * # Returns
404
+ * - `true` if the input is a MuSig2 keypath input
405
+ * - `false` otherwise (or if input_index is out of bounds)
406
+ */
407
+ is_musig2_input(input_index: number): boolean;
408
+ /**
409
+ * Get the transaction lock time
410
+ */
411
+ lock_time(): number;
412
+ /**
413
+ * Get the network of the PSBT
414
+ */
415
+ network(): string;
416
+ /**
417
+ * Parse outputs with wallet keys to identify which outputs belong to a wallet
418
+ *
419
+ * Note: This method does NOT validate wallet inputs. It only parses outputs.
420
+ */
421
+ parse_outputs_with_wallet_keys(wallet_keys: WasmRootWalletKeys, paygo_pubkeys?: WasmECPair[] | null): any;
422
+ /**
423
+ * Parse transaction with wallet keys to identify wallet inputs/outputs
424
+ */
425
+ parse_transaction_with_wallet_keys(wallet_keys: WasmRootWalletKeys, replay_protection: WasmReplayProtection, paygo_pubkeys?: WasmECPair[] | null): any;
426
+ /**
427
+ * Serialize the PSBT to bytes
428
+ *
429
+ * # Returns
430
+ * The serialized PSBT as a byte array
431
+ */
432
+ serialize(): Uint8Array;
433
+ /**
434
+ * Sign all MuSig2 keypath inputs in a single pass with optimized sighash computation.
435
+ *
436
+ * This is more efficient than calling `sign_musig2_input()` for each input because
437
+ * it reuses the SighashCache across all inputs, avoiding redundant computation of
438
+ * sha_prevouts, sha_amounts, sha_scriptpubkeys, sha_sequences, and sha_outputs.
439
+ *
440
+ * Each MuSig2 input requires a FirstRound from `generate_musig2_nonces()`.
441
+ * FirstRounds that have already been consumed (signed) are skipped.
442
+ *
443
+ * # Arguments
444
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
445
+ *
446
+ * # Returns
447
+ * - `Ok(JsValue)` with an array of input indices that were signed
448
+ * - `Err(WasmUtxoError)` if signing fails
449
+ */
450
+ sign_all_musig2_inputs(xpriv: WasmBIP32): any;
451
+ /**
452
+ * Sign all replay protection inputs with a raw private key.
453
+ *
454
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
455
+ * that match the provided public key and signs them.
456
+ *
457
+ * # Arguments
458
+ * - `ecpair`: The ECPair containing the private key
459
+ *
460
+ * # Returns
461
+ * - `Ok(JsValue)` with an array of input indices that were signed
462
+ * - `Err(WasmUtxoError)` if signing fails
463
+ */
464
+ sign_all_replay_protection_inputs(ecpair: WasmECPair): any;
465
+ /**
466
+ * Sign all non-MuSig2 wallet inputs in a single efficient pass.
467
+ *
468
+ * This signs all ECDSA (P2SH, P2SH-P2WSH, P2WSH) and Taproot script path (P2TR)
469
+ * inputs that match the provided xpriv. MuSig2 keypath inputs are skipped.
470
+ *
471
+ * This is the most efficient way to sign wallet inputs. After calling this,
472
+ * sign any MuSig2 inputs using `sign_all_musig2_inputs()` or `sign_musig2_input()`.
473
+ *
474
+ * # Arguments
475
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
476
+ *
477
+ * # Returns
478
+ * - `Ok(JsValue)` with an array of input indices that were signed
479
+ * - `Err(WasmUtxoError)` if signing fails
480
+ */
481
+ sign_all_wallet_inputs(xpriv: WasmBIP32): any;
482
+ /**
483
+ * Sign all non-MuSig2 inputs with an extended private key (xpriv) in a single pass.
484
+ *
485
+ * This is more efficient than calling `sign_with_xpriv` for each input individually.
486
+ * The underlying miniscript library's `sign` method signs all matching inputs at once.
487
+ *
488
+ * **Note:** MuSig2 inputs are skipped by this method because they require FirstRound
489
+ * state from nonce generation. After calling this method, sign MuSig2 inputs
490
+ * individually using `sign_with_xpriv`.
491
+ *
492
+ * # Arguments
493
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
494
+ *
495
+ * # Returns
496
+ * - `Ok(JsValue)` with an array of input indices that were signed
497
+ * - `Err(WasmUtxoError)` if signing fails
498
+ */
499
+ sign_all_with_xpriv(xpriv: WasmBIP32): any;
500
+ /**
501
+ * Sign a single MuSig2 keypath input.
502
+ *
503
+ * This uses the FirstRound state generated by `generate_musig2_nonces()`.
504
+ * Each FirstRound can only be used once (nonce reuse is a security risk).
505
+ *
506
+ * For non-MuSig2 inputs, returns an error (use `sign_wallet_input` instead).
507
+ *
508
+ * # Arguments
509
+ * - `input_index`: The index of the input to sign (0-based)
510
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
511
+ *
512
+ * # Returns
513
+ * - `Ok(())` if signing was successful
514
+ * - `Err(WasmUtxoError)` if signing fails, no FirstRound exists, or not a MuSig2 input
515
+ */
516
+ sign_musig2_input(input_index: number, xpriv: WasmBIP32): void;
517
+ /**
518
+ * Sign all replay protection inputs with a raw private key.
519
+ *
520
+ * This iterates through all inputs looking for P2SH-P2PK (replay protection) inputs
521
+ * that match the provided public key and signs them.
522
+ *
523
+ * # Arguments
524
+ * - `ecpair`: The ECPair containing the private key
525
+ *
526
+ * # Returns
527
+ * - `Ok(JsValue)` with an array of input indices that were signed
528
+ * - `Err(WasmUtxoError)` if signing fails
529
+ */
530
+ sign_replay_protection_inputs(ecpair: WasmECPair): any;
531
+ /**
532
+ * Sign a single input with a raw private key, using save/restore for regular inputs.
533
+ *
534
+ * For replay protection inputs (P2SH-P2PK), this uses direct signing which is
535
+ * already single-input. For regular inputs, this clones the PSBT, signs all,
536
+ * then copies only the target input's signatures back.
537
+ *
538
+ * **Important:** This is NOT faster than signing all inputs for regular (non-RP) inputs.
539
+ * The underlying miniscript library signs all inputs regardless.
540
+ *
541
+ * # Arguments
542
+ * - `input_index`: The index of the input to sign (0-based)
543
+ * - `ecpair`: The ECPair containing the private key
544
+ *
545
+ * # Returns
546
+ * - `Ok(())` if the input was signed
547
+ * - `Err(WasmUtxoError)` if signing fails
548
+ */
549
+ sign_single_input_with_privkey(input_index: number, ecpair: WasmECPair): void;
550
+ /**
551
+ * Sign a single input with an extended private key, using save/restore for ECDSA inputs.
552
+ *
553
+ * For MuSig2 inputs, this returns an error (use sign_with_xpriv which handles FirstRound).
554
+ * For ECDSA inputs, this clones the PSBT, signs all, then copies only the target
555
+ * input's signatures back.
556
+ *
557
+ * **Important:** This is NOT faster than `sign_all_with_xpriv` for ECDSA inputs.
558
+ * The underlying miniscript library signs all inputs regardless. This method
559
+ * just prevents signatures from being added to other inputs.
560
+ *
561
+ * # Arguments
562
+ * - `input_index`: The index of the input to sign (0-based)
563
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
564
+ *
565
+ * # Returns
566
+ * - `Ok(())` if the input was signed
567
+ * - `Err(WasmUtxoError)` if signing fails
568
+ */
569
+ sign_single_input_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
570
+ /**
571
+ * Sign a single non-MuSig2 wallet input using save/restore pattern.
572
+ *
573
+ * For MuSig2 inputs, returns an error (use `sign_musig2_input` instead).
574
+ * For ECDSA inputs, this uses a save/restore pattern: clones the PSBT,
575
+ * signs all inputs on the clone, then copies only the target input's
576
+ * signatures back.
577
+ *
578
+ * **Important:** This is NOT faster than `sign_all_wallet_inputs()` for ECDSA inputs.
579
+ * The underlying library signs all inputs regardless. This method just ensures
580
+ * that only the specified input gets signatures added to the PSBT.
581
+ * Use `sign_all_wallet_inputs()` when signing multiple inputs with the same key.
582
+ *
583
+ * # Arguments
584
+ * - `input_index`: The index of the input to sign (0-based)
585
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
586
+ *
587
+ * # Returns
588
+ * - `Ok(())` if the input was signed
589
+ * - `Err(WasmUtxoError)` if signing fails or input is MuSig2
590
+ */
591
+ sign_wallet_input(input_index: number, xpriv: WasmBIP32): void;
592
+ /**
593
+ * Sign a single input with a raw private key
594
+ *
595
+ * This method signs a specific input using the provided ECPair. It accepts:
596
+ * - A raw privkey (WasmECPair) for replay protection inputs - signs directly
597
+ *
598
+ * This method automatically detects and handles different input types:
599
+ * - For replay protection inputs: signs with legacy P2SH sighash
600
+ * - For regular inputs: uses standard PSBT signing
601
+ * - For MuSig2 inputs: returns error (requires FirstRound, use sign_with_xpriv instead)
602
+ *
603
+ * # Arguments
604
+ * - `input_index`: The index of the input to sign (0-based)
605
+ * - `ecpair`: The ECPair containing the private key
606
+ *
607
+ * # Returns
608
+ * - `Ok(())` if signing was successful
609
+ * - `Err(WasmUtxoError)` if signing fails
610
+ */
611
+ sign_with_privkey(input_index: number, ecpair: WasmECPair): void;
612
+ /**
613
+ * Sign a single input with an extended private key (xpriv)
614
+ *
615
+ * This method signs a specific input using the provided xpriv. It accepts:
616
+ * - An xpriv (WasmBIP32) for wallet inputs - derives the key and signs
617
+ *
618
+ * This method automatically detects and handles different input types:
619
+ * - For regular inputs: uses standard PSBT signing
620
+ * - For MuSig2 inputs: uses the FirstRound state stored by generate_musig2_nonces()
621
+ * - For replay protection inputs: returns error (use sign_with_privkey instead)
622
+ *
623
+ * # Arguments
624
+ * - `input_index`: The index of the input to sign (0-based)
625
+ * - `xpriv`: The extended private key as a WasmBIP32 instance
626
+ *
627
+ * # Returns
628
+ * - `Ok(())` if signing was successful
629
+ * - `Err(WasmUtxoError)` if signing fails
630
+ */
631
+ sign_with_xpriv(input_index: number, xpriv: WasmBIP32): void;
632
+ /**
633
+ * Get the unsigned transaction ID
634
+ */
635
+ unsigned_txid(): string;
636
+ /**
637
+ * Verify if a replay protection input has a valid signature
638
+ *
639
+ * This method checks if a given input is a replay protection input and cryptographically verifies
640
+ * the signature. Replay protection inputs (like P2shP2pk) don't use standard derivation paths,
641
+ * so this method verifies signatures without deriving from xpub.
642
+ *
643
+ * # Arguments
644
+ * - `input_index`: The index of the input to check
645
+ * - `replay_protection`: Replay protection configuration (same format as parseTransactionWithWalletKeys)
646
+ * Can be either `{ outputScripts: Buffer[] }` or `{ addresses: string[] }`
647
+ *
648
+ * # Returns
649
+ * - `Ok(true)` if the input is a replay protection input and has a valid signature
650
+ * - `Ok(false)` if the input is a replay protection input but has no valid signature
651
+ * - `Err(WasmUtxoError)` if the input is not a replay protection input, index is out of bounds, or configuration is invalid
652
+ */
653
+ verify_replay_protection_signature(input_index: number, replay_protection: WasmReplayProtection): boolean;
654
+ /**
655
+ * Verify if a valid signature exists for a given ECPair key at the specified input index
656
+ *
657
+ * This method verifies the signature directly with the provided ECPair's public key. It supports:
658
+ * - ECDSA signatures (for legacy/SegWit inputs)
659
+ * - Schnorr signatures (for Taproot script path inputs)
660
+ *
661
+ * Note: This method does NOT support MuSig2 inputs, as MuSig2 requires derivation from xpubs.
662
+ * Use `verify_signature_with_xpub` for MuSig2 inputs.
663
+ *
664
+ * # Arguments
665
+ * - `input_index`: The index of the input to check
666
+ * - `ecpair`: The ECPair key (uses the public key for verification)
667
+ *
668
+ * # Returns
669
+ * - `Ok(true)` if a valid signature exists for the public key
670
+ * - `Ok(false)` if no signature exists for the public key
671
+ * - `Err(WasmUtxoError)` if the input index is out of bounds or verification fails
672
+ */
673
+ verify_signature_with_pub(input_index: number, ecpair: WasmECPair): boolean;
674
+ /**
675
+ * Verify if a valid signature exists for a given xpub at the specified input index
676
+ *
677
+ * This method derives the public key from the xpub using the derivation path found in the
678
+ * PSBT input, then verifies the signature. It supports:
679
+ * - ECDSA signatures (for legacy/SegWit inputs)
680
+ * - Schnorr signatures (for Taproot script path inputs)
681
+ * - MuSig2 partial signatures (for Taproot keypath MuSig2 inputs)
682
+ *
683
+ * # Arguments
684
+ * - `input_index`: The index of the input to check
685
+ * - `xpub`: The extended public key as a WasmBIP32 instance
686
+ *
687
+ * # Returns
688
+ * - `Ok(true)` if a valid signature exists for the derived public key
689
+ * - `Ok(false)` if no signature exists for the derived public key
690
+ * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
691
+ */
692
+ verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
693
+ /**
694
+ * Get the transaction version
695
+ */
696
+ version(): number;
697
+ /**
698
+ * Get the Zcash version group ID (returns None for non-Zcash PSBTs)
699
+ */
700
+ version_group_id(): number | undefined;
697
701
  }
698
702
 
699
703
  export class FixedScriptWalletNamespace {
700
- private constructor();
701
- free(): void;
702
- [Symbol.dispose](): void;
703
- static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
704
- /**
705
- * Get all chain code metadata for building TypeScript lookup tables
706
- *
707
- * Returns an array of [chainCode, scriptType, scope] tuples where:
708
- * - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
709
- * - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
710
- * - scope: string ("external" or "internal")
711
- */
712
- static chain_code_table(): any;
713
- /**
714
- * Check if a network supports a given fixed-script wallet script type
715
- *
716
- * # Arguments
717
- * * `coin` - Coin name (e.g., "btc", "ltc", "doge")
718
- * * `script_type` - Script type name: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
719
- *
720
- * # Returns
721
- * `true` if the network supports the script type, `false` otherwise
722
- *
723
- * # Examples
724
- * - Bitcoin supports all script types (p2sh, p2shP2wsh, p2wsh, p2tr, p2trMusig2)
725
- * - Litecoin supports segwit but not taproot (p2sh, p2shP2wsh, p2wsh)
726
- * - Dogecoin only supports legacy scripts (p2sh)
727
- */
728
- static supports_script_type(coin: string, script_type: string): boolean;
729
- /**
730
- * Create an OP_RETURN output script with optional data
731
- *
732
- * # Arguments
733
- * * `data` - Optional data bytes to include in the OP_RETURN script
734
- *
735
- * # Returns
736
- * The OP_RETURN script as bytes
737
- */
738
- static create_op_return_script(data?: Uint8Array | null): Uint8Array;
739
- static address_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string, address_format?: string | null): string;
740
- static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
741
- static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
704
+ private constructor();
705
+ free(): void;
706
+ [Symbol.dispose](): void;
707
+ static address(keys: WasmRootWalletKeys, chain: number, index: number, network: any, address_format?: string | null): string;
708
+ static address_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string, address_format?: string | null): string;
709
+ /**
710
+ * Get all chain code metadata for building TypeScript lookup tables
711
+ *
712
+ * Returns an array of [chainCode, scriptType, scope] tuples where:
713
+ * - chainCode: u32 (0, 1, 10, 11, 20, 21, 30, 31, 40, 41)
714
+ * - scriptType: string ("p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy", "p2trMusig2")
715
+ * - scope: string ("external" or "internal")
716
+ */
717
+ static chain_code_table(): any;
718
+ /**
719
+ * Create an OP_RETURN output script with optional data
720
+ *
721
+ * # Arguments
722
+ * * `data` - Optional data bytes to include in the OP_RETURN script
723
+ *
724
+ * # Returns
725
+ * The OP_RETURN script as bytes
726
+ */
727
+ static create_op_return_script(data?: Uint8Array | null): Uint8Array;
728
+ static output_script(keys: WasmRootWalletKeys, chain: number, index: number, network: any): Uint8Array;
729
+ static output_script_with_network_str(keys: WasmRootWalletKeys, chain: number, index: number, network: string): Uint8Array;
730
+ /**
731
+ * Check if a network supports a given fixed-script wallet script type
732
+ *
733
+ * # Arguments
734
+ * * `coin` - Coin name (e.g., "btc", "ltc", "doge")
735
+ * * `script_type` - Script type name: "p2sh", "p2shP2wsh", "p2wsh", "p2tr", "p2trMusig2"
736
+ *
737
+ * # Returns
738
+ * `true` if the network supports the script type, `false` otherwise
739
+ *
740
+ * # Examples
741
+ * - Bitcoin supports all script types (p2sh, p2shP2wsh, p2wsh, p2tr, p2trMusig2)
742
+ * - Litecoin supports segwit but not taproot (p2sh, p2shP2wsh, p2wsh)
743
+ * - Dogecoin only supports legacy scripts (p2sh)
744
+ */
745
+ static supports_script_type(coin: string, script_type: string): boolean;
742
746
  }
743
747
 
748
+ /**
749
+ * Namespace for inscription-related functions
750
+ */
744
751
  export class InscriptionsNamespace {
745
- private constructor();
746
- free(): void;
747
- [Symbol.dispose](): void;
748
- /**
749
- * Sign a reveal transaction
750
- *
751
- * # Arguments
752
- * * `private_key` - The private key (32 bytes)
753
- * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
754
- * * `commit_tx` - The commit transaction
755
- * * `commit_output_script` - The commit output script (P2TR)
756
- * * `recipient_output_script` - Where to send the inscription (output script)
757
- * * `output_value_sats` - Value in satoshis for the inscription output
758
- *
759
- * # Returns
760
- * The signed PSBT as bytes
761
- */
762
- static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
763
- /**
764
- * Create inscription reveal data including the commit output script and tap leaf script
765
- *
766
- * # Arguments
767
- * * `x_only_pubkey` - The x-only public key (32 bytes)
768
- * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
769
- * * `inscription_data` - The inscription data bytes
770
- *
771
- * # Returns
772
- * An object containing:
773
- * - `output_script`: The commit output script (P2TR, network-agnostic)
774
- * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
775
- * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
776
- */
777
- static create_inscription_reveal_data(x_only_pubkey: Uint8Array, content_type: string, inscription_data: Uint8Array): any;
752
+ private constructor();
753
+ free(): void;
754
+ [Symbol.dispose](): void;
755
+ /**
756
+ * Create inscription reveal data including the commit output script and tap leaf script
757
+ *
758
+ * # Arguments
759
+ * * `x_only_pubkey` - The x-only public key (32 bytes)
760
+ * * `content_type` - MIME type of the inscription (e.g., "text/plain", "image/png")
761
+ * * `inscription_data` - The inscription data bytes
762
+ *
763
+ * # Returns
764
+ * An object containing:
765
+ * - `output_script`: The commit output script (P2TR, network-agnostic)
766
+ * - `reveal_transaction_vsize`: Estimated vsize of the reveal transaction
767
+ * - `tap_leaf_script`: Object with `leaf_version`, `script`, and `control_block`
768
+ */
769
+ static create_inscription_reveal_data(x_only_pubkey: Uint8Array, content_type: string, inscription_data: Uint8Array): any;
770
+ /**
771
+ * Sign a reveal transaction
772
+ *
773
+ * # Arguments
774
+ * * `private_key` - The private key (32 bytes)
775
+ * * `tap_leaf_script` - The tap leaf script object from `create_inscription_reveal_data`
776
+ * * `commit_tx` - The commit transaction
777
+ * * `commit_output_script` - The commit output script (P2TR)
778
+ * * `recipient_output_script` - Where to send the inscription (output script)
779
+ * * `output_value_sats` - Value in satoshis for the inscription output
780
+ *
781
+ * # Returns
782
+ * The signed PSBT as bytes
783
+ */
784
+ static sign_reveal_transaction(private_key: Uint8Array, tap_leaf_script: any, commit_tx: WasmTransaction, commit_output_script: Uint8Array, recipient_output_script: Uint8Array, output_value_sats: bigint): Uint8Array;
785
+ }
786
+
787
+ export class MessageNamespace {
788
+ private constructor();
789
+ free(): void;
790
+ [Symbol.dispose](): void;
791
+ /**
792
+ * Sign a message using Bitcoin message signing (BIP-137)
793
+ *
794
+ * Returns 65-byte signature (1-byte header + 64-byte signature).
795
+ * The key must have a private key (cannot sign with public key only).
796
+ */
797
+ static sign_message(key: WasmECPair, message_str: string): Uint8Array;
798
+ /**
799
+ * Verify a Bitcoin message signature (BIP-137)
800
+ *
801
+ * Signature must be 65 bytes (1-byte header + 64-byte signature).
802
+ * Returns true if the signature is valid for this key.
803
+ */
804
+ static verify_message(key: WasmECPair, message_str: string, signature: Uint8Array): boolean;
778
805
  }
779
806
 
780
807
  export class UtxolibCompatNamespace {
781
- private constructor();
782
- free(): void;
783
- [Symbol.dispose](): void;
784
- /**
785
- * Convert address string to output script
786
- *
787
- * # Arguments
788
- * * `address` - The address string
789
- * * `network` - The UtxolibNetwork object from JavaScript
790
- * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
791
- */
792
- static to_output_script(address: string, network: any, format?: string | null): Uint8Array;
793
- /**
794
- * Convert output script to address string
795
- *
796
- * # Arguments
797
- * * `script` - The output script as a byte array
798
- * * `network` - The UtxolibNetwork object from JavaScript
799
- * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
800
- */
801
- static from_output_script(script: Uint8Array, network: any, format?: string | null): string;
808
+ private constructor();
809
+ free(): void;
810
+ [Symbol.dispose](): void;
811
+ /**
812
+ * Convert output script to address string
813
+ *
814
+ * # Arguments
815
+ * * `script` - The output script as a byte array
816
+ * * `network` - The UtxolibNetwork object from JavaScript
817
+ * * `format` - Optional address format: "default" or "cashaddr" (only applicable for Bitcoin Cash and eCash)
818
+ */
819
+ static from_output_script(script: Uint8Array, network: any, format?: string | null): string;
820
+ /**
821
+ * Convert address string to output script
822
+ *
823
+ * # Arguments
824
+ * * `address` - The address string
825
+ * * `network` - The UtxolibNetwork object from JavaScript
826
+ * * `format` - Optional address format (currently unused for decoding as all formats are accepted)
827
+ */
828
+ static to_output_script(address: string, network: any, format?: string | null): Uint8Array;
802
829
  }
803
830
 
831
+ /**
832
+ * WASM wrapper for BIP32 extended keys (Xpub/Xpriv)
833
+ * Implements the BIP32Interface TypeScript interface
834
+ */
804
835
  export class WasmBIP32 {
805
- private constructor();
806
- free(): void;
807
- [Symbol.dispose](): void;
808
- /**
809
- * Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
810
- */
811
- derive_path(path: string): WasmBIP32;
812
- /**
813
- * Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
814
- */
815
- static from_base58(base58_str: string): WasmBIP32;
816
- /**
817
- * Check if this is a neutered (public) key
818
- */
819
- is_neutered(): boolean;
820
- /**
821
- * Derive a hardened child key (only works for private keys)
822
- */
823
- derive_hardened(index: number): WasmBIP32;
824
- /**
825
- * Create a BIP32 master key from a string by hashing it with SHA256.
826
- * This is useful for deterministic test key generation.
827
- */
828
- static from_seed_sha256(seed_string: string, network?: string | null): WasmBIP32;
829
- /**
830
- * Create a BIP32 key from a BIP32Interface JavaScript object properties
831
- * Expects an object with: network.bip32.public, depth, parentFingerprint,
832
- * index, chainCode, and publicKey properties
833
- */
834
- static from_bip32_interface(bip32_key: any): WasmBIP32;
835
- /**
836
- * Create a BIP32 key from BIP32 properties
837
- * Extracts properties from a JavaScript object and constructs an xpub or xprv
838
- */
839
- static from_bip32_properties(bip32_key: any): WasmBIP32;
840
- /**
841
- * Derive a normal (non-hardened) child key
842
- */
843
- derive(index: number): WasmBIP32;
844
- /**
845
- * Get the WIF encoding of the private key
846
- */
847
- to_wif(): string;
848
- /**
849
- * Get the neutered (public) version of this key
850
- */
851
- neutered(): WasmBIP32;
852
- /**
853
- * Create a BIP32 master key from a seed
854
- */
855
- static from_seed(seed: Uint8Array, network?: string | null): WasmBIP32;
856
- /**
857
- * Create a BIP32 key from an xprv string (base58-encoded)
858
- */
859
- static from_xprv(xprv_str: string): WasmBIP32;
860
- /**
861
- * Create a BIP32 key from an xpub string (base58-encoded)
862
- */
863
- static from_xpub(xpub_str: string): WasmBIP32;
864
- /**
865
- * Serialize to base58 string
866
- */
867
- to_base58(): string;
868
- /**
869
- * Get the chain code as a Uint8Array
870
- */
871
- readonly chain_code: Uint8Array;
872
- /**
873
- * Get the identifier as a Uint8Array
874
- */
875
- readonly identifier: Uint8Array;
876
- /**
877
- * Get the public key as a Uint8Array
878
- */
879
- readonly public_key: Uint8Array;
880
- /**
881
- * Get the fingerprint as a Uint8Array
882
- */
883
- readonly fingerprint: Uint8Array;
884
- /**
885
- * Get the private key as a Uint8Array (if available)
886
- */
887
- readonly private_key: Uint8Array | undefined;
888
- /**
889
- * Get the parent fingerprint
890
- */
891
- readonly parent_fingerprint: number;
892
- /**
893
- * Get the depth
894
- */
895
- readonly depth: number;
896
- /**
897
- * Get the child index
898
- */
899
- readonly index: number;
836
+ private constructor();
837
+ free(): void;
838
+ [Symbol.dispose](): void;
839
+ /**
840
+ * Derive a normal (non-hardened) child key
841
+ */
842
+ derive(index: number): WasmBIP32;
843
+ /**
844
+ * Derive a hardened child key (only works for private keys)
845
+ */
846
+ derive_hardened(index: number): WasmBIP32;
847
+ /**
848
+ * Derive a key using a derivation path (e.g., "0/1/2" or "m/0/1/2")
849
+ */
850
+ derive_path(path: string): WasmBIP32;
851
+ /**
852
+ * Check equality with another WasmBIP32 key.
853
+ * Two keys are equal if they have the same type (public/private) and identical
854
+ * BIP32 metadata (depth, parent fingerprint, child index, chain code, key data).
855
+ */
856
+ equals(other: WasmBIP32): boolean;
857
+ /**
858
+ * Create a BIP32 key from a base58 string (xpub/xprv/tpub/tprv)
859
+ */
860
+ static from_base58(base58_str: string): WasmBIP32;
861
+ /**
862
+ * Create a BIP32 key from a BIP32Interface JavaScript object properties
863
+ * Expects an object with: network.bip32.public, depth, parentFingerprint,
864
+ * index, chainCode, and publicKey properties
865
+ */
866
+ static from_bip32_interface(bip32_key: any): WasmBIP32;
867
+ /**
868
+ * Create a BIP32 key from BIP32 properties
869
+ * Extracts properties from a JavaScript object and constructs an xpub or xprv
870
+ */
871
+ static from_bip32_properties(bip32_key: any): WasmBIP32;
872
+ /**
873
+ * Create a BIP32 master key from a seed
874
+ */
875
+ static from_seed(seed: Uint8Array, network?: string | null): WasmBIP32;
876
+ /**
877
+ * Create a BIP32 master key from a string by hashing it with SHA256.
878
+ * This is useful for deterministic test key generation.
879
+ */
880
+ static from_seed_sha256(seed_string: string, network?: string | null): WasmBIP32;
881
+ /**
882
+ * Create a BIP32 key from an xprv string (base58-encoded)
883
+ */
884
+ static from_xprv(xprv_str: string): WasmBIP32;
885
+ /**
886
+ * Create a BIP32 key from an xpub string (base58-encoded)
887
+ */
888
+ static from_xpub(xpub_str: string): WasmBIP32;
889
+ /**
890
+ * Check if this is a neutered (public) key
891
+ */
892
+ is_neutered(): boolean;
893
+ /**
894
+ * Get the neutered (public) version of this key
895
+ */
896
+ neutered(): WasmBIP32;
897
+ /**
898
+ * Serialize to base58 string
899
+ */
900
+ to_base58(): string;
901
+ /**
902
+ * Get the WIF encoding of the private key
903
+ */
904
+ to_wif(): string;
905
+ /**
906
+ * Get the chain code as a Uint8Array
907
+ */
908
+ readonly chain_code: Uint8Array;
909
+ /**
910
+ * Get the depth
911
+ */
912
+ readonly depth: number;
913
+ /**
914
+ * Get the fingerprint as a Uint8Array
915
+ */
916
+ readonly fingerprint: Uint8Array;
917
+ /**
918
+ * Get the identifier as a Uint8Array
919
+ */
920
+ readonly identifier: Uint8Array;
921
+ /**
922
+ * Get the child index
923
+ */
924
+ readonly index: number;
925
+ /**
926
+ * Get the parent fingerprint
927
+ */
928
+ readonly parent_fingerprint: number;
929
+ /**
930
+ * Get the private key as a Uint8Array (if available)
931
+ */
932
+ readonly private_key: Uint8Array | undefined;
933
+ /**
934
+ * Get the public key as a Uint8Array
935
+ */
936
+ readonly public_key: Uint8Array;
900
937
  }
901
938
 
939
+ /**
940
+ * Dash transaction wrapper that supports Dash special transactions (EVO) by preserving extra payload.
941
+ */
902
942
  export class WasmDashTransaction {
903
- private constructor();
904
- free(): void;
905
- [Symbol.dispose](): void;
906
- /**
907
- * Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
908
- */
909
- static from_bytes(bytes: Uint8Array): WasmDashTransaction;
910
- /**
911
- * Get the transaction ID (txid)
912
- *
913
- * The txid is the double SHA256 of the full Dash transaction bytes,
914
- * displayed in reverse byte order (big-endian) as is standard.
915
- *
916
- * # Returns
917
- * The transaction ID as a hex string
918
- *
919
- * # Errors
920
- * Returns an error if the transaction cannot be serialized
921
- */
922
- get_txid(): string;
923
- /**
924
- * Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
925
- */
926
- to_bytes(): Uint8Array;
943
+ private constructor();
944
+ free(): void;
945
+ [Symbol.dispose](): void;
946
+ /**
947
+ * Deserialize a Dash transaction from bytes (supports EVO special tx extra payload).
948
+ */
949
+ static from_bytes(bytes: Uint8Array): WasmDashTransaction;
950
+ /**
951
+ * Get the transaction ID (txid)
952
+ *
953
+ * The txid is the double SHA256 of the full Dash transaction bytes,
954
+ * displayed in reverse byte order (big-endian) as is standard.
955
+ *
956
+ * # Returns
957
+ * The transaction ID as a hex string
958
+ *
959
+ * # Errors
960
+ * Returns an error if the transaction cannot be serialized
961
+ */
962
+ get_txid(): string;
963
+ /**
964
+ * Serialize the Dash transaction to bytes (preserving tx_type and extra payload).
965
+ */
966
+ to_bytes(): Uint8Array;
927
967
  }
928
968
 
969
+ /**
970
+ * Dimensions for estimating transaction virtual size.
971
+ *
972
+ * Tracks weight internally with min/max bounds to handle ECDSA signature variance.
973
+ * Schnorr signatures have no variance (always 64 bytes).
974
+ */
929
975
  export class WasmDimensions {
930
- private constructor();
931
- free(): void;
932
- [Symbol.dispose](): void;
933
- /**
934
- * Create dimensions for a single input from chain code
935
- *
936
- * # Arguments
937
- * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
938
- * * `signer` - Optional signer key ("user", "backup", "bitgo")
939
- * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
940
- * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
941
- */
942
- static from_input(chain: number, signer?: string | null, cosigner?: string | null, compat?: boolean | null): WasmDimensions;
943
- /**
944
- * Get total weight (min or max)
945
- *
946
- * # Arguments
947
- * * `size` - "min" or "max", defaults to "max"
948
- */
949
- get_weight(size?: string | null): number;
950
- /**
951
- * Whether any inputs are segwit (affects overhead calculation)
952
- */
953
- has_segwit(): boolean;
954
- /**
955
- * Get input virtual size (min or max)
956
- *
957
- * # Arguments
958
- * * `size` - "min" or "max", defaults to "max"
959
- */
960
- get_input_vsize(size?: string | null): number;
961
- /**
962
- * Get input weight only (min or max)
963
- *
964
- * # Arguments
965
- * * `size` - "min" or "max", defaults to "max"
966
- */
967
- get_input_weight(size?: string | null): number;
968
- /**
969
- * Get output virtual size
970
- */
971
- get_output_vsize(): number;
972
- /**
973
- * Get output weight
974
- */
975
- get_output_weight(): number;
976
- /**
977
- * Create dimensions for a single input from script type string
978
- *
979
- * # Arguments
980
- * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
981
- * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
982
- * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
983
- */
984
- static from_input_script_type(script_type: string, compat?: boolean | null): WasmDimensions;
985
- /**
986
- * Create dimensions for a single output from script type string
987
- *
988
- * # Arguments
989
- * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
990
- */
991
- static from_output_script_type(script_type: string): WasmDimensions;
992
- /**
993
- * Create dimensions for a single output from script length
994
- */
995
- static from_output_script_length(length: number): WasmDimensions;
996
- /**
997
- * Combine with another Dimensions instance
998
- */
999
- plus(other: WasmDimensions): WasmDimensions;
1000
- /**
1001
- * Create empty dimensions (zero weight)
1002
- */
1003
- static empty(): WasmDimensions;
1004
- /**
1005
- * Multiply dimensions by a scalar
1006
- */
1007
- times(n: number): WasmDimensions;
1008
- /**
1009
- * Create dimensions from a BitGoPsbt
1010
- *
1011
- * Parses PSBT inputs and outputs to compute weight bounds without
1012
- * requiring wallet keys. Input types are detected from BIP32 derivation
1013
- * paths stored in the PSBT.
1014
- */
1015
- static from_psbt(psbt: BitGoPsbt): WasmDimensions;
1016
- /**
1017
- * Get virtual size (min or max)
1018
- *
1019
- * # Arguments
1020
- * * `size` - "min" or "max", defaults to "max"
1021
- */
1022
- get_vsize(size?: string | null): number;
976
+ private constructor();
977
+ free(): void;
978
+ [Symbol.dispose](): void;
979
+ /**
980
+ * Create empty dimensions (zero weight)
981
+ */
982
+ static empty(): WasmDimensions;
983
+ /**
984
+ * Create dimensions for a single input from chain code
985
+ *
986
+ * # Arguments
987
+ * * `chain` - Chain code (0/1=p2sh, 10/11=p2shP2wsh, 20/21=p2wsh, 30/31=p2tr, 40/41=p2trMusig2)
988
+ * * `signer` - Optional signer key ("user", "backup", "bitgo")
989
+ * * `cosigner` - Optional cosigner key ("user", "backup", "bitgo")
990
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
991
+ */
992
+ static from_input(chain: number, signer?: string | null, cosigner?: string | null, compat?: boolean | null): WasmDimensions;
993
+ /**
994
+ * Create dimensions for a single input from script type string
995
+ *
996
+ * # Arguments
997
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2trLegacy",
998
+ * "p2trMusig2KeyPath", "p2trMusig2ScriptPath", "p2shP2pk"
999
+ * * `compat` - When true, use 72-byte signatures for max (matches @bitgo/unspents)
1000
+ */
1001
+ static from_input_script_type(script_type: string, compat?: boolean | null): WasmDimensions;
1002
+ /**
1003
+ * Create dimensions for a single output from script length
1004
+ */
1005
+ static from_output_script_length(length: number): WasmDimensions;
1006
+ /**
1007
+ * Create dimensions for a single output from script type string
1008
+ *
1009
+ * # Arguments
1010
+ * * `script_type` - One of: "p2sh", "p2shP2wsh", "p2wsh", "p2tr"/"p2trLegacy", "p2trMusig2"
1011
+ */
1012
+ static from_output_script_type(script_type: string): WasmDimensions;
1013
+ /**
1014
+ * Create dimensions from a BitGoPsbt
1015
+ *
1016
+ * Parses PSBT inputs and outputs to compute weight bounds without
1017
+ * requiring wallet keys. Input types are detected from BIP32 derivation
1018
+ * paths stored in the PSBT.
1019
+ */
1020
+ static from_psbt(psbt: BitGoPsbt): WasmDimensions;
1021
+ /**
1022
+ * Get input virtual size (min or max)
1023
+ *
1024
+ * # Arguments
1025
+ * * `size` - "min" or "max", defaults to "max"
1026
+ */
1027
+ get_input_vsize(size?: string | null): number;
1028
+ /**
1029
+ * Get input weight only (min or max)
1030
+ *
1031
+ * # Arguments
1032
+ * * `size` - "min" or "max", defaults to "max"
1033
+ */
1034
+ get_input_weight(size?: string | null): number;
1035
+ /**
1036
+ * Get output virtual size
1037
+ */
1038
+ get_output_vsize(): number;
1039
+ /**
1040
+ * Get output weight
1041
+ */
1042
+ get_output_weight(): number;
1043
+ /**
1044
+ * Get virtual size (min or max)
1045
+ *
1046
+ * # Arguments
1047
+ * * `size` - "min" or "max", defaults to "max"
1048
+ */
1049
+ get_vsize(size?: string | null): number;
1050
+ /**
1051
+ * Get total weight (min or max)
1052
+ *
1053
+ * # Arguments
1054
+ * * `size` - "min" or "max", defaults to "max"
1055
+ */
1056
+ get_weight(size?: string | null): number;
1057
+ /**
1058
+ * Whether any inputs are segwit (affects overhead calculation)
1059
+ */
1060
+ has_segwit(): boolean;
1061
+ /**
1062
+ * Combine with another Dimensions instance
1063
+ */
1064
+ plus(other: WasmDimensions): WasmDimensions;
1065
+ /**
1066
+ * Multiply dimensions by a scalar
1067
+ */
1068
+ times(n: number): WasmDimensions;
1023
1069
  }
1024
1070
 
1071
+ /**
1072
+ * WASM wrapper for elliptic curve key pairs (always uses compressed keys)
1073
+ */
1025
1074
  export class WasmECPair {
1026
- private constructor();
1027
- free(): void;
1028
- [Symbol.dispose](): void;
1029
- /**
1030
- * Convert to mainnet WIF string
1031
- */
1032
- to_wif_mainnet(): string;
1033
- /**
1034
- * Convert to testnet WIF string
1035
- */
1036
- to_wif_testnet(): string;
1037
- /**
1038
- * Create an ECPair from a public key (always uses compressed keys)
1039
- */
1040
- static from_public_key(public_key: Uint8Array): WasmECPair;
1041
- /**
1042
- * Create an ECPair from a private key (always uses compressed keys)
1043
- */
1044
- static from_private_key(private_key: Uint8Array): WasmECPair;
1045
- /**
1046
- * Create an ECPair from a mainnet WIF string
1047
- */
1048
- static from_wif_mainnet(wif_string: string): WasmECPair;
1049
- /**
1050
- * Create an ECPair from a testnet WIF string
1051
- */
1052
- static from_wif_testnet(wif_string: string): WasmECPair;
1053
- /**
1054
- * Convert to WIF string (mainnet)
1055
- */
1056
- to_wif(): string;
1057
- /**
1058
- * Create an ECPair from a WIF string (auto-detects network)
1059
- */
1060
- static from_wif(wif_string: string): WasmECPair;
1061
- /**
1062
- * Get the compressed public key as a Uint8Array (always 33 bytes)
1063
- */
1064
- readonly public_key: Uint8Array;
1065
- /**
1066
- * Get the private key as a Uint8Array (if available)
1067
- */
1068
- readonly private_key: Uint8Array | undefined;
1075
+ private constructor();
1076
+ free(): void;
1077
+ [Symbol.dispose](): void;
1078
+ /**
1079
+ * Create an ECPair from a private key (always uses compressed keys)
1080
+ */
1081
+ static from_private_key(private_key: Uint8Array): WasmECPair;
1082
+ /**
1083
+ * Create an ECPair from a public key (always uses compressed keys)
1084
+ */
1085
+ static from_public_key(public_key: Uint8Array): WasmECPair;
1086
+ /**
1087
+ * Create an ECPair from a WIF string (auto-detects network)
1088
+ */
1089
+ static from_wif(wif_string: string): WasmECPair;
1090
+ /**
1091
+ * Create an ECPair from a mainnet WIF string
1092
+ */
1093
+ static from_wif_mainnet(wif_string: string): WasmECPair;
1094
+ /**
1095
+ * Create an ECPair from a testnet WIF string
1096
+ */
1097
+ static from_wif_testnet(wif_string: string): WasmECPair;
1098
+ /**
1099
+ * Convert to WIF string (mainnet)
1100
+ */
1101
+ to_wif(): string;
1102
+ /**
1103
+ * Convert to mainnet WIF string
1104
+ */
1105
+ to_wif_mainnet(): string;
1106
+ /**
1107
+ * Convert to testnet WIF string
1108
+ */
1109
+ to_wif_testnet(): string;
1110
+ /**
1111
+ * Get the private key as a Uint8Array (if available)
1112
+ */
1113
+ readonly private_key: Uint8Array | undefined;
1114
+ /**
1115
+ * Get the compressed public key as a Uint8Array (always 33 bytes)
1116
+ */
1117
+ readonly public_key: Uint8Array;
1069
1118
  }
1070
1119
 
1120
+ /**
1121
+ * WASM wrapper for ReplayProtection
1122
+ */
1071
1123
  export class WasmReplayProtection {
1072
- private constructor();
1073
- free(): void;
1074
- [Symbol.dispose](): void;
1075
- /**
1076
- * Create from addresses (requires network for decoding)
1077
- */
1078
- static from_addresses(addresses: any[], network: string): WasmReplayProtection;
1079
- /**
1080
- * Create from public keys (derives P2SH-P2PK output scripts)
1081
- */
1082
- static from_public_keys(public_keys: Uint8Array[]): WasmReplayProtection;
1083
- /**
1084
- * Create from output scripts directly
1085
- */
1086
- static from_output_scripts(output_scripts: Uint8Array[]): WasmReplayProtection;
1124
+ private constructor();
1125
+ free(): void;
1126
+ [Symbol.dispose](): void;
1127
+ /**
1128
+ * Create from addresses (requires network for decoding)
1129
+ */
1130
+ static from_addresses(addresses: any[], network: string): WasmReplayProtection;
1131
+ /**
1132
+ * Create from output scripts directly
1133
+ */
1134
+ static from_output_scripts(output_scripts: Uint8Array[]): WasmReplayProtection;
1135
+ /**
1136
+ * Create from public keys (derives P2SH-P2PK output scripts)
1137
+ */
1138
+ static from_public_keys(public_keys: Uint8Array[]): WasmReplayProtection;
1087
1139
  }
1088
1140
 
1141
+ /**
1142
+ * WASM wrapper for RootWalletKeys
1143
+ * Represents a set of three extended public keys with their derivation prefixes
1144
+ */
1089
1145
  export class WasmRootWalletKeys {
1090
- free(): void;
1091
- [Symbol.dispose](): void;
1092
- /**
1093
- * Get the backup key (second xpub)
1094
- */
1095
- backup_key(): WasmBIP32;
1096
- /**
1097
- * Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
1098
- *
1099
- * # Arguments
1100
- * - `user`: User key (first xpub)
1101
- * - `backup`: Backup key (second xpub)
1102
- * - `bitgo`: BitGo key (third xpub)
1103
- * - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
1104
- * - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
1105
- * - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
1106
- */
1107
- static with_derivation_prefixes(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32, user_derivation: string, backup_derivation: string, bitgo_derivation: string): WasmRootWalletKeys;
1108
- /**
1109
- * Create a RootWalletKeys from three BIP32 keys
1110
- * Uses default derivation prefix of m/0/0 for all three keys
1111
- *
1112
- * # Arguments
1113
- * - `user`: User key (first xpub)
1114
- * - `backup`: Backup key (second xpub)
1115
- * - `bitgo`: BitGo key (third xpub)
1116
- */
1117
- constructor(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32);
1118
- /**
1119
- * Get the user key (first xpub)
1120
- */
1121
- user_key(): WasmBIP32;
1122
- /**
1123
- * Get the bitgo key (third xpub)
1124
- */
1125
- bitgo_key(): WasmBIP32;
1146
+ free(): void;
1147
+ [Symbol.dispose](): void;
1148
+ /**
1149
+ * Get the backup key (second xpub)
1150
+ */
1151
+ backup_key(): WasmBIP32;
1152
+ /**
1153
+ * Get the bitgo key (third xpub)
1154
+ */
1155
+ bitgo_key(): WasmBIP32;
1156
+ /**
1157
+ * Create a RootWalletKeys from three BIP32 keys
1158
+ * Uses default derivation prefix of m/0/0 for all three keys
1159
+ *
1160
+ * # Arguments
1161
+ * - `user`: User key (first xpub)
1162
+ * - `backup`: Backup key (second xpub)
1163
+ * - `bitgo`: BitGo key (third xpub)
1164
+ */
1165
+ constructor(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32);
1166
+ /**
1167
+ * Get the user key (first xpub)
1168
+ */
1169
+ user_key(): WasmBIP32;
1170
+ /**
1171
+ * Create a RootWalletKeys from three BIP32 keys with custom derivation prefixes
1172
+ *
1173
+ * # Arguments
1174
+ * - `user`: User key (first xpub)
1175
+ * - `backup`: Backup key (second xpub)
1176
+ * - `bitgo`: BitGo key (third xpub)
1177
+ * - `user_derivation`: Derivation path for user key (e.g., "m/0/0")
1178
+ * - `backup_derivation`: Derivation path for backup key (e.g., "m/0/0")
1179
+ * - `bitgo_derivation`: Derivation path for bitgo key (e.g., "m/0/0")
1180
+ */
1181
+ static with_derivation_prefixes(user: WasmBIP32, backup: WasmBIP32, bitgo: WasmBIP32, user_derivation: string, backup_derivation: string, bitgo_derivation: string): WasmRootWalletKeys;
1126
1182
  }
1127
1183
 
1184
+ /**
1185
+ * A Bitcoin-like transaction (for all networks except Zcash)
1186
+ *
1187
+ * This class provides basic transaction parsing and serialization for testing
1188
+ * compatibility with third-party transaction fixtures.
1189
+ */
1128
1190
  export class WasmTransaction {
1129
- private constructor();
1130
- free(): void;
1131
- [Symbol.dispose](): void;
1132
- /**
1133
- * Deserialize a transaction from bytes
1134
- *
1135
- * # Arguments
1136
- * * `bytes` - The serialized transaction bytes
1137
- *
1138
- * # Returns
1139
- * A WasmTransaction instance
1140
- *
1141
- * # Errors
1142
- * Returns an error if the bytes cannot be parsed as a valid transaction
1143
- */
1144
- static from_bytes(bytes: Uint8Array): WasmTransaction;
1145
- /**
1146
- * Get the transaction ID (txid)
1147
- *
1148
- * The txid is the double SHA256 of the transaction bytes (excluding witness
1149
- * data for segwit transactions), displayed in reverse byte order (big-endian)
1150
- * as is standard for Bitcoin.
1151
- *
1152
- * # Returns
1153
- * The transaction ID as a hex string
1154
- */
1155
- get_txid(): string;
1156
- /**
1157
- * Serialize the transaction to bytes
1158
- *
1159
- * # Returns
1160
- * The serialized transaction bytes
1161
- */
1162
- to_bytes(): Uint8Array;
1163
- /**
1164
- * Get the virtual size of the transaction
1165
- *
1166
- * Virtual size is calculated as ceil(weight / 4), where weight accounts
1167
- * for the segwit discount on witness data.
1168
- *
1169
- * # Returns
1170
- * The virtual size in virtual bytes (vbytes)
1171
- */
1172
- get_vsize(): number;
1191
+ private constructor();
1192
+ free(): void;
1193
+ [Symbol.dispose](): void;
1194
+ /**
1195
+ * Deserialize a transaction from bytes
1196
+ *
1197
+ * # Arguments
1198
+ * * `bytes` - The serialized transaction bytes
1199
+ *
1200
+ * # Returns
1201
+ * A WasmTransaction instance
1202
+ *
1203
+ * # Errors
1204
+ * Returns an error if the bytes cannot be parsed as a valid transaction
1205
+ */
1206
+ static from_bytes(bytes: Uint8Array): WasmTransaction;
1207
+ /**
1208
+ * Get the transaction ID (txid)
1209
+ *
1210
+ * The txid is the double SHA256 of the transaction bytes (excluding witness
1211
+ * data for segwit transactions), displayed in reverse byte order (big-endian)
1212
+ * as is standard for Bitcoin.
1213
+ *
1214
+ * # Returns
1215
+ * The transaction ID as a hex string
1216
+ */
1217
+ get_txid(): string;
1218
+ /**
1219
+ * Get the virtual size of the transaction
1220
+ *
1221
+ * Virtual size is calculated as ceil(weight / 4), where weight accounts
1222
+ * for the segwit discount on witness data.
1223
+ *
1224
+ * # Returns
1225
+ * The virtual size in virtual bytes (vbytes)
1226
+ */
1227
+ get_vsize(): number;
1228
+ /**
1229
+ * Serialize the transaction to bytes
1230
+ *
1231
+ * # Returns
1232
+ * The serialized transaction bytes
1233
+ */
1234
+ to_bytes(): Uint8Array;
1173
1235
  }
1174
1236
 
1237
+ /**
1238
+ * A Zcash transaction with network-specific fields
1239
+ *
1240
+ * This class provides basic transaction parsing and serialization for Zcash
1241
+ * transactions, which use the Overwinter transaction format.
1242
+ */
1175
1243
  export class WasmZcashTransaction {
1176
- private constructor();
1177
- free(): void;
1178
- [Symbol.dispose](): void;
1179
- /**
1180
- * Deserialize a Zcash transaction from bytes
1181
- *
1182
- * # Arguments
1183
- * * `bytes` - The serialized transaction bytes
1184
- *
1185
- * # Returns
1186
- * A WasmZcashTransaction instance
1187
- *
1188
- * # Errors
1189
- * Returns an error if the bytes cannot be parsed as a valid Zcash transaction
1190
- */
1191
- static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
1192
- /**
1193
- * Get the transaction ID (txid)
1194
- *
1195
- * The txid is the double SHA256 of the full Zcash transaction bytes,
1196
- * displayed in reverse byte order (big-endian) as is standard.
1197
- *
1198
- * # Returns
1199
- * The transaction ID as a hex string
1200
- *
1201
- * # Errors
1202
- * Returns an error if the transaction cannot be serialized
1203
- */
1204
- get_txid(): string;
1205
- /**
1206
- * Serialize the transaction to bytes
1207
- *
1208
- * # Returns
1209
- * The serialized transaction bytes
1210
- */
1211
- to_bytes(): Uint8Array;
1244
+ private constructor();
1245
+ free(): void;
1246
+ [Symbol.dispose](): void;
1247
+ /**
1248
+ * Deserialize a Zcash transaction from bytes
1249
+ *
1250
+ * # Arguments
1251
+ * * `bytes` - The serialized transaction bytes
1252
+ *
1253
+ * # Returns
1254
+ * A WasmZcashTransaction instance
1255
+ *
1256
+ * # Errors
1257
+ * Returns an error if the bytes cannot be parsed as a valid Zcash transaction
1258
+ */
1259
+ static from_bytes(bytes: Uint8Array): WasmZcashTransaction;
1260
+ /**
1261
+ * Get the transaction ID (txid)
1262
+ *
1263
+ * The txid is the double SHA256 of the full Zcash transaction bytes,
1264
+ * displayed in reverse byte order (big-endian) as is standard.
1265
+ *
1266
+ * # Returns
1267
+ * The transaction ID as a hex string
1268
+ *
1269
+ * # Errors
1270
+ * Returns an error if the transaction cannot be serialized
1271
+ */
1272
+ get_txid(): string;
1273
+ /**
1274
+ * Serialize the transaction to bytes
1275
+ *
1276
+ * # Returns
1277
+ * The serialized transaction bytes
1278
+ */
1279
+ to_bytes(): Uint8Array;
1212
1280
  }
1213
1281
 
1214
1282
  export class WrapDescriptor {
1215
- private constructor();
1216
- free(): void;
1217
- [Symbol.dispose](): void;
1218
- hasWildcard(): boolean;
1219
- scriptPubkey(): Uint8Array;
1220
- toAsmString(): string;
1221
- atDerivationIndex(index: number): WrapDescriptor;
1222
- maxWeightToSatisfy(): number;
1223
- node(): any;
1224
- encode(): Uint8Array;
1225
- descType(): any;
1226
- toString(): string;
1283
+ private constructor();
1284
+ free(): void;
1285
+ [Symbol.dispose](): void;
1286
+ atDerivationIndex(index: number): WrapDescriptor;
1287
+ descType(): any;
1288
+ encode(): Uint8Array;
1289
+ hasWildcard(): boolean;
1290
+ maxWeightToSatisfy(): number;
1291
+ node(): any;
1292
+ scriptPubkey(): Uint8Array;
1293
+ toAsmString(): string;
1294
+ toString(): string;
1227
1295
  }
1228
1296
 
1229
1297
  export class WrapMiniscript {
1230
- private constructor();
1231
- free(): void;
1232
- [Symbol.dispose](): void;
1233
- toAsmString(): string;
1234
- node(): any;
1235
- encode(): Uint8Array;
1236
- toString(): string;
1298
+ private constructor();
1299
+ free(): void;
1300
+ [Symbol.dispose](): void;
1301
+ encode(): Uint8Array;
1302
+ node(): any;
1303
+ toAsmString(): string;
1304
+ toString(): string;
1237
1305
  }
1238
1306
 
1239
1307
  export class WrapPsbt {
1240
- free(): void;
1241
- [Symbol.dispose](): void;
1242
- /**
1243
- * Add an output to the PSBT
1244
- *
1245
- * # Arguments
1246
- * * `script` - The output script (scriptPubKey)
1247
- * * `value` - Value in satoshis
1248
- *
1249
- * # Returns
1250
- * The index of the newly added output
1251
- */
1252
- addOutput(script: Uint8Array, value: bigint): number;
1253
- /**
1254
- * Get all PSBT inputs as an array of PsbtInputData
1255
- *
1256
- * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
1257
- * for each input. This is useful for introspecting the PSBT structure.
1258
- */
1259
- getInputs(): any;
1260
- static deserialize(psbt: Uint8Array): WrapPsbt;
1261
- /**
1262
- * Get all PSBT outputs as an array of PsbtOutputData
1263
- *
1264
- * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
1265
- * for each output. This is useful for introspecting the PSBT structure.
1266
- */
1267
- getOutputs(): any;
1268
- /**
1269
- * Get the number of inputs in the PSBT
1270
- */
1271
- inputCount(): number;
1272
- finalize(): void;
1273
- /**
1274
- * Get the number of outputs in the PSBT
1275
- */
1276
- outputCount(): number;
1277
- signWithPrv(prv: Uint8Array): any;
1278
- signWithXprv(xprv: string): any;
1279
- /**
1280
- * Get the unsigned transaction ID as a hex string
1281
- */
1282
- unsignedTxId(): string;
1283
- /**
1284
- * Get the unsigned transaction bytes
1285
- *
1286
- * # Returns
1287
- * The serialized unsigned transaction
1288
- */
1289
- getUnsignedTx(): Uint8Array;
1290
- /**
1291
- * Sign all inputs with a WasmECPair key
1292
- *
1293
- * This method signs all inputs using the private key from the ECPair.
1294
- * Returns a map of input indices to the public keys that were signed.
1295
- *
1296
- * # Arguments
1297
- * * `key` - The WasmECPair key to sign with
1298
- *
1299
- * # Returns
1300
- * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1301
- */
1302
- signAllWithEcpair(key: WasmECPair): any;
1303
- /**
1304
- * Get partial signatures for an input
1305
- * Returns array of { pubkey: Uint8Array, signature: Uint8Array }
1306
- */
1307
- getPartialSignatures(input_index: number): any;
1308
- /**
1309
- * Check if an input has any partial signatures
1310
- */
1311
- hasPartialSignatures(input_index: number): boolean;
1312
- /**
1313
- * Verify a signature at a specific input using a WasmBIP32 key
1314
- *
1315
- * This method verifies if a valid signature exists for the given BIP32 key at the specified input.
1316
- * It handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1317
- *
1318
- * Note: This method checks if the key's public key matches any signature in the input.
1319
- * For proper BIP32 verification, the key should be derived to the correct path first.
1320
- *
1321
- * # Arguments
1322
- * * `input_index` - The index of the input to check
1323
- * * `key` - The WasmBIP32 key to verify against
1324
- *
1325
- * # Returns
1326
- * `true` if a valid signature exists for the key, `false` otherwise
1327
- */
1328
- verifySignatureWithKey(input_index: number, key: WasmBIP32): boolean;
1329
- /**
1330
- * Validate a signature at a specific input against a pubkey
1331
- * Returns true if the signature is valid
1332
- *
1333
- * This method handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1334
- * The pubkey should be provided as bytes (33 bytes for compressed ECDSA, 32 bytes for x-only Schnorr).
1335
- */
1336
- validateSignatureAtInput(input_index: number, pubkey: Uint8Array): boolean;
1337
- updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
1338
- updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
1339
- /**
1340
- * Create an empty PSBT
1341
- *
1342
- * # Arguments
1343
- * * `version` - Transaction version (default: 2)
1344
- * * `lock_time` - Transaction lock time (default: 0)
1345
- */
1346
- constructor(version?: number | null, lock_time?: number | null);
1347
- clone(): WrapPsbt;
1348
- /**
1349
- * Get the transaction version
1350
- */
1351
- version(): number;
1352
- /**
1353
- * Sign all inputs with a WasmBIP32 key
1354
- *
1355
- * This method signs all inputs that match the BIP32 derivation paths in the PSBT.
1356
- * Returns a map of input indices to the public keys that were signed.
1357
- *
1358
- * # Arguments
1359
- * * `key` - The WasmBIP32 key to sign with
1360
- *
1361
- * # Returns
1362
- * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1363
- */
1364
- signAll(key: WasmBIP32): any;
1365
- /**
1366
- * Add an input to the PSBT
1367
- *
1368
- * # Arguments
1369
- * * `txid` - Transaction ID (hex string, 32 bytes reversed)
1370
- * * `vout` - Output index being spent
1371
- * * `value` - Value in satoshis of the output being spent
1372
- * * `script` - The scriptPubKey of the output being spent
1373
- * * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
1374
- *
1375
- * # Returns
1376
- * The index of the newly added input
1377
- */
1378
- addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1379
- /**
1380
- * Get the transaction lock time
1381
- */
1382
- lockTime(): number;
1383
- serialize(): Uint8Array;
1308
+ free(): void;
1309
+ [Symbol.dispose](): void;
1310
+ /**
1311
+ * Add an input to the PSBT
1312
+ *
1313
+ * # Arguments
1314
+ * * `txid` - Transaction ID (hex string, 32 bytes reversed)
1315
+ * * `vout` - Output index being spent
1316
+ * * `value` - Value in satoshis of the output being spent
1317
+ * * `script` - The scriptPubKey of the output being spent
1318
+ * * `sequence` - Sequence number (default: 0xFFFFFFFE for RBF)
1319
+ *
1320
+ * # Returns
1321
+ * The index of the newly added input
1322
+ */
1323
+ addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1324
+ /**
1325
+ * Add an output to the PSBT
1326
+ *
1327
+ * # Arguments
1328
+ * * `script` - The output script (scriptPubKey)
1329
+ * * `value` - Value in satoshis
1330
+ *
1331
+ * # Returns
1332
+ * The index of the newly added output
1333
+ */
1334
+ addOutput(script: Uint8Array, value: bigint): number;
1335
+ clone(): WrapPsbt;
1336
+ static deserialize(psbt: Uint8Array): WrapPsbt;
1337
+ /**
1338
+ * Extract the final transaction from a finalized PSBT
1339
+ *
1340
+ * This method should be called after all inputs have been finalized.
1341
+ * It extracts the fully signed transaction as a WasmTransaction instance.
1342
+ *
1343
+ * # Returns
1344
+ * - `Ok(WasmTransaction)` containing the extracted transaction
1345
+ * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
1346
+ */
1347
+ extractTransaction(): WasmTransaction;
1348
+ finalize(): void;
1349
+ /**
1350
+ * Get all PSBT inputs as an array of PsbtInputData
1351
+ *
1352
+ * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
1353
+ * for each input. This is useful for introspecting the PSBT structure.
1354
+ */
1355
+ getInputs(): any;
1356
+ /**
1357
+ * Get all PSBT outputs as an array of PsbtOutputData
1358
+ *
1359
+ * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
1360
+ * for each output. This is useful for introspecting the PSBT structure.
1361
+ */
1362
+ getOutputs(): any;
1363
+ /**
1364
+ * Get all PSBT outputs with resolved address strings.
1365
+ *
1366
+ * Like `getOutputs()` but each element also includes an `address` field
1367
+ * derived from the output script using the given coin name (e.g. "btc", "tbtc").
1368
+ */
1369
+ getOutputsWithAddress(coin: string): any;
1370
+ /**
1371
+ * Get partial signatures for an input
1372
+ * Returns array of { pubkey: Uint8Array, signature: Uint8Array }
1373
+ */
1374
+ getPartialSignatures(input_index: number): any;
1375
+ /**
1376
+ * Get the unsigned transaction bytes
1377
+ *
1378
+ * # Returns
1379
+ * The serialized unsigned transaction
1380
+ */
1381
+ getUnsignedTx(): Uint8Array;
1382
+ /**
1383
+ * Check if an input has any partial signatures
1384
+ */
1385
+ hasPartialSignatures(input_index: number): boolean;
1386
+ /**
1387
+ * Get the number of inputs in the PSBT
1388
+ */
1389
+ inputCount(): number;
1390
+ /**
1391
+ * Get the transaction lock time
1392
+ */
1393
+ lockTime(): number;
1394
+ /**
1395
+ * Create an empty PSBT
1396
+ *
1397
+ * # Arguments
1398
+ * * `version` - Transaction version (default: 2)
1399
+ * * `lock_time` - Transaction lock time (default: 0)
1400
+ */
1401
+ constructor(version?: number | null, lock_time?: number | null);
1402
+ /**
1403
+ * Get the number of outputs in the PSBT
1404
+ */
1405
+ outputCount(): number;
1406
+ serialize(): Uint8Array;
1407
+ /**
1408
+ * Sign all inputs with a WasmBIP32 key
1409
+ *
1410
+ * This method signs all inputs that match the BIP32 derivation paths in the PSBT.
1411
+ * Returns a map of input indices to the public keys that were signed.
1412
+ *
1413
+ * # Arguments
1414
+ * * `key` - The WasmBIP32 key to sign with
1415
+ *
1416
+ * # Returns
1417
+ * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1418
+ */
1419
+ signAll(key: WasmBIP32): any;
1420
+ /**
1421
+ * Sign all inputs with a WasmECPair key
1422
+ *
1423
+ * This method signs all inputs using the private key from the ECPair.
1424
+ * Returns a map of input indices to the public keys that were signed.
1425
+ *
1426
+ * # Arguments
1427
+ * * `key` - The WasmECPair key to sign with
1428
+ *
1429
+ * # Returns
1430
+ * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1431
+ */
1432
+ signAllWithEcpair(key: WasmECPair): any;
1433
+ signWithPrv(prv: Uint8Array): any;
1434
+ signWithXprv(xprv: string): any;
1435
+ /**
1436
+ * Get the unsigned transaction ID as a hex string
1437
+ */
1438
+ unsignedTxId(): string;
1439
+ updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
1440
+ updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
1441
+ /**
1442
+ * Validate a signature at a specific input against a pubkey
1443
+ * Returns true if the signature is valid
1444
+ *
1445
+ * This method handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1446
+ * The pubkey should be provided as bytes (33 bytes for compressed ECDSA, 32 bytes for x-only Schnorr).
1447
+ */
1448
+ validateSignatureAtInput(input_index: number, pubkey: Uint8Array): boolean;
1449
+ /**
1450
+ * Verify a signature at a specific input using a WasmBIP32 key
1451
+ *
1452
+ * This method verifies if a valid signature exists for the given BIP32 key at the specified input.
1453
+ * It handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1454
+ *
1455
+ * Note: This method checks if the key's public key matches any signature in the input.
1456
+ * For proper BIP32 verification, the key should be derived to the correct path first.
1457
+ *
1458
+ * # Arguments
1459
+ * * `input_index` - The index of the input to check
1460
+ * * `key` - The WasmBIP32 key to verify against
1461
+ *
1462
+ * # Returns
1463
+ * `true` if a valid signature exists for the key, `false` otherwise
1464
+ */
1465
+ verifySignatureWithKey(input_index: number, key: WasmBIP32): boolean;
1466
+ /**
1467
+ * Get the transaction version
1468
+ */
1469
+ version(): number;
1384
1470
  }