@bitgo/wasm-utxo 2.1.0 → 3.1.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 (33) hide show
  1. package/dist/cjs/js/bip322/index.d.ts +5 -0
  2. package/dist/cjs/js/bip322/index.js +8 -0
  3. package/dist/cjs/js/coinName.d.ts +3 -0
  4. package/dist/cjs/js/coinName.js +49 -0
  5. package/dist/cjs/js/descriptorWallet/Psbt.d.ts +49 -0
  6. package/dist/cjs/js/descriptorWallet/Psbt.js +126 -0
  7. package/dist/cjs/js/descriptorWallet/index.d.ts +1 -0
  8. package/dist/cjs/js/descriptorWallet/index.js +4 -0
  9. package/dist/cjs/js/index.d.ts +1 -31
  10. package/dist/cjs/js/index.js +2 -2
  11. package/dist/cjs/js/testutils/AcidTest.d.ts +3 -3
  12. package/dist/cjs/js/testutils/AcidTest.js +79 -80
  13. package/dist/cjs/js/wasm/wasm_utxo.d.ts +32 -110
  14. package/dist/cjs/js/wasm/wasm_utxo.js +83 -97
  15. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  16. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +75 -74
  17. package/dist/esm/js/bip322/index.d.ts +5 -0
  18. package/dist/esm/js/bip322/index.js +7 -0
  19. package/dist/esm/js/coinName.d.ts +3 -0
  20. package/dist/esm/js/coinName.js +48 -0
  21. package/dist/esm/js/descriptorWallet/Psbt.d.ts +49 -0
  22. package/dist/esm/js/descriptorWallet/Psbt.js +122 -0
  23. package/dist/esm/js/descriptorWallet/index.d.ts +1 -0
  24. package/dist/esm/js/descriptorWallet/index.js +2 -0
  25. package/dist/esm/js/index.d.ts +1 -31
  26. package/dist/esm/js/index.js +1 -1
  27. package/dist/esm/js/testutils/AcidTest.d.ts +3 -3
  28. package/dist/esm/js/testutils/AcidTest.js +80 -81
  29. package/dist/esm/js/wasm/wasm_utxo.d.ts +32 -110
  30. package/dist/esm/js/wasm/wasm_utxo_bg.js +83 -97
  31. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  32. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +75 -74
  33. package/package.json +1 -1
@@ -1,13 +1,29 @@
1
1
  import { BitGoPsbt } from "../fixedScriptWallet/BitGoPsbt.js";
2
2
  import { ZcashBitGoPsbt } from "../fixedScriptWallet/ZcashBitGoPsbt.js";
3
3
  import { ECPair } from "../ecpair.js";
4
- import { assertChainCode, ChainCode, createOpReturnScript, inputScriptTypes, outputScript, outputScriptTypes, supportsScriptType, } from "../fixedScriptWallet/index.js";
4
+ import { Transaction } from "../transaction.js";
5
+ import { ChainCode, createOpReturnScript, inputScriptTypes, outputScript, outputScriptTypes, p2shP2pkOutputScript, supportsScriptType, } from "../fixedScriptWallet/index.js";
5
6
  import { coinNames, isMainnet } from "../coinName.js";
6
7
  import { getDefaultWalletKeys, getWalletKeysForSeed, getKeyTriple } from "./keys.js";
7
8
  export const signStages = ["unsigned", "halfsigned", "fullsigned"];
8
9
  export const txFormats = ["psbt", "psbt-lite"];
9
10
  // Re-export for convenience
10
11
  export { inputScriptTypes, outputScriptTypes };
12
+ /** Map InputScriptType to the OutputScriptType used for chain code derivation */
13
+ function inputScriptTypeToOutputScriptType(scriptType) {
14
+ switch (scriptType) {
15
+ case "p2sh":
16
+ case "p2shP2wsh":
17
+ case "p2wsh":
18
+ case "p2trLegacy":
19
+ return scriptType;
20
+ case "p2shP2pk":
21
+ return "p2sh";
22
+ case "p2trMusig2ScriptPath":
23
+ case "p2trMusig2KeyPath":
24
+ return "p2trMusig2";
25
+ }
26
+ }
11
27
  /**
12
28
  * Creates a valid PSBT with as many features as possible (kitchen sink).
13
29
  *
@@ -30,7 +46,7 @@ export { inputScriptTypes, outputScriptTypes };
30
46
  * - psbt-lite: Only witness_utxo (no non_witness_utxo)
31
47
  */
32
48
  export class AcidTest {
33
- network;
49
+ coin;
34
50
  signStage;
35
51
  txFormat;
36
52
  rootWalletKeys;
@@ -41,8 +57,8 @@ export class AcidTest {
41
57
  userXprv;
42
58
  backupXprv;
43
59
  bitgoXprv;
44
- constructor(network, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple) {
45
- this.network = network;
60
+ constructor(coin, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple) {
61
+ this.coin = coin;
46
62
  this.signStage = signStage;
47
63
  this.txFormat = txFormat;
48
64
  this.rootWalletKeys = rootWalletKeys;
@@ -56,7 +72,7 @@ export class AcidTest {
56
72
  /**
57
73
  * Create an AcidTest with specific configuration
58
74
  */
59
- static withConfig(network, signStage, txFormat, suiteConfig = {}) {
75
+ static withConfig(coin, signStage, txFormat, suiteConfig = {}) {
60
76
  const rootWalletKeys = getDefaultWalletKeys();
61
77
  const otherWalletKeys = getWalletKeysForSeed("too many secrets");
62
78
  // Filter inputs based on network support
@@ -67,9 +83,9 @@ export class AcidTest {
67
83
  return true;
68
84
  // Map input script types to output script types for support check
69
85
  if (scriptType === "p2trMusig2KeyPath" || scriptType === "p2trMusig2ScriptPath") {
70
- return supportsScriptType(network, "p2trMusig2");
86
+ return supportsScriptType(coin, "p2trMusig2");
71
87
  }
72
- return supportsScriptType(network, scriptType);
88
+ return supportsScriptType(coin, scriptType);
73
89
  })
74
90
  .filter((scriptType) => (suiteConfig.includeP2trMusig2ScriptPath ?? false) ||
75
91
  scriptType !== "p2trMusig2ScriptPath")
@@ -79,7 +95,7 @@ export class AcidTest {
79
95
  }));
80
96
  // Filter outputs based on network support
81
97
  const outputs = outputScriptTypes
82
- .filter((scriptType) => supportsScriptType(network, scriptType))
98
+ .filter((scriptType) => supportsScriptType(coin, scriptType))
83
99
  .map((scriptType, index) => ({
84
100
  scriptType,
85
101
  value: BigInt(900 + index * 100), // Deterministic amounts
@@ -92,13 +108,13 @@ export class AcidTest {
92
108
  outputs.push({ opReturn: "setec astronomy", value: BigInt(0) });
93
109
  // Get private keys for signing
94
110
  const xprvTriple = getKeyTriple("default");
95
- return new AcidTest(network, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple);
111
+ return new AcidTest(coin, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple);
96
112
  }
97
113
  /**
98
114
  * Get a human-readable name for this test configuration
99
115
  */
100
116
  get name() {
101
- return `${this.network} ${this.signStage} ${this.txFormat}`;
117
+ return `${this.coin} ${this.signStage} ${this.txFormat}`;
102
118
  }
103
119
  /**
104
120
  * Get the BIP32 user key for replay protection (p2shP2pk)
@@ -111,58 +127,55 @@ export class AcidTest {
111
127
  */
112
128
  createPsbt() {
113
129
  // Use ZcashBitGoPsbt for Zcash networks
114
- const isZcash = this.network === "zec" || this.network === "tzec";
130
+ const isZcash = this.coin === "zec" || this.coin === "tzec";
115
131
  const psbt = isZcash
116
- ? ZcashBitGoPsbt.createEmptyWithConsensusBranchId(this.network, this.rootWalletKeys, {
117
- version: 2,
118
- lockTime: 0,
119
- consensusBranchId: 0xc2d6d0b4, // NU5
132
+ ? ZcashBitGoPsbt.createEmpty(this.coin, this.rootWalletKeys, {
133
+ // Sapling activation height: mainnet=419200, testnet=280000
134
+ blockHeight: this.coin === "zec" ? 419200 : 280000,
120
135
  })
121
- : BitGoPsbt.createEmpty(this.network, this.rootWalletKeys, {
136
+ : BitGoPsbt.createEmpty(this.coin, this.rootWalletKeys, {
122
137
  version: 2,
123
138
  lockTime: 0,
124
139
  });
140
+ // Build a fake previous transaction for non_witness_utxo (psbt format)
141
+ const usePrevTx = this.txFormat === "psbt" && !isZcash;
142
+ const buildPrevTx = (vout, script, value) => {
143
+ if (!usePrevTx)
144
+ return undefined;
145
+ const tx = Transaction.create();
146
+ tx.addInput("0".repeat(64), 0xffffffff);
147
+ for (let i = 0; i < vout; i++) {
148
+ tx.addOutput(new Uint8Array(0), 0n);
149
+ }
150
+ tx.addOutput(script, value);
151
+ return tx.toBytes();
152
+ };
125
153
  // Add inputs with deterministic outpoints
126
154
  this.inputs.forEach((input, index) => {
127
- // Resolve scriptId: either from explicit scriptId or from scriptType + index
128
- const scriptId = input.scriptId ?? {
129
- chain: ChainCode.value("p2sh", "external"),
130
- index: input.index ?? index,
131
- };
132
155
  const walletKeys = input.walletKeys ?? this.rootWalletKeys;
133
- // Get scriptType: either explicit or derive from scriptId chain
134
- const scriptType = input.scriptType ?? ChainCode.scriptType(assertChainCode(scriptId.chain));
135
- if (scriptType === "p2shP2pk") {
136
- // Add replay protection input
137
- const replayKey = this.getReplayProtectionKey();
138
- // Convert BIP32 to ECPair using public key
139
- const ecpair = ECPair.fromPublicKey(replayKey.publicKey);
140
- psbt.addReplayProtectionInput({
141
- txid: "0".repeat(64),
142
- vout: index,
143
- value: input.value,
144
- }, ecpair);
156
+ const outpoint = { txid: "0".repeat(64), vout: index, value: input.value };
157
+ // scriptId variant: caller provides explicit chain + index
158
+ if (input.scriptId) {
159
+ const script = outputScript(walletKeys, input.scriptId.chain, input.scriptId.index, this.coin);
160
+ psbt.addWalletInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, walletKeys, { scriptId: input.scriptId, signPath: { signer: "user", cosigner: "bitgo" } });
161
+ return;
145
162
  }
146
- else {
147
- // Determine signing path based on input type
148
- let signPath;
149
- if (scriptType === "p2trMusig2ScriptPath") {
150
- // Script path uses user + backup
151
- signPath = { signer: "user", cosigner: "backup" };
152
- }
153
- else {
154
- // Default: user + bitgo
155
- signPath = { signer: "user", cosigner: "bitgo" };
156
- }
157
- psbt.addWalletInput({
158
- txid: "0".repeat(64),
159
- vout: index,
160
- value: input.value,
161
- }, walletKeys, {
162
- scriptId,
163
- signPath,
164
- });
163
+ const scriptType = input.scriptType ?? "p2sh";
164
+ if (scriptType === "p2shP2pk") {
165
+ const ecpair = ECPair.fromPublicKey(this.getReplayProtectionKey().publicKey);
166
+ const script = p2shP2pkOutputScript(ecpair.publicKey);
167
+ psbt.addReplayProtectionInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, ecpair);
168
+ return;
165
169
  }
170
+ const scriptId = {
171
+ chain: ChainCode.value(inputScriptTypeToOutputScriptType(scriptType), "external"),
172
+ index: input.index ?? index,
173
+ };
174
+ const signPath = scriptType === "p2trMusig2ScriptPath"
175
+ ? { signer: "user", cosigner: "backup" }
176
+ : { signer: "user", cosigner: "bitgo" };
177
+ const script = outputScript(walletKeys, scriptId.chain, scriptId.index, this.coin);
178
+ psbt.addWalletInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, walletKeys, { scriptId, signPath });
166
179
  });
167
180
  // Add outputs
168
181
  this.outputs.forEach((output, index) => {
@@ -193,7 +206,7 @@ export class AcidTest {
193
206
  chain: scriptId.chain,
194
207
  index: output.index ?? 1000 + index,
195
208
  };
196
- const script = outputScript(this.rootWalletKeys, externalScriptId.chain, externalScriptId.index, this.network);
209
+ const script = outputScript(this.rootWalletKeys, externalScriptId.chain, externalScriptId.index, this.coin);
197
210
  psbt.addOutput(script, output.value);
198
211
  }
199
212
  else {
@@ -224,36 +237,22 @@ export class AcidTest {
224
237
  // Generate MuSig2 nonces for user if needed
225
238
  const hasMusig2Inputs = this.inputs.some((input) => input.scriptType === "p2trMusig2KeyPath" || input.scriptType === "p2trMusig2ScriptPath");
226
239
  if (hasMusig2Inputs) {
227
- const isZcash = this.network === "zec" || this.network === "tzec";
228
- if (isZcash) {
240
+ if (this.coin === "zec" || this.coin === "tzec") {
229
241
  throw new Error("Zcash does not support MuSig2/Taproot inputs");
230
242
  }
231
- // Generate nonces with user key
243
+ // MuSig2 requires ALL participant nonces before ANY signing.
244
+ // Generate nonces directly on the same PSBT for each participant key.
232
245
  psbt.generateMusig2Nonces(userKey);
233
- if (this.signStage === "fullsigned") {
234
- // Create a second PSBT with cosigner nonces for combination
235
- // For p2trMusig2ScriptPath use backup, for p2trMusig2KeyPath use bitgo
236
- // Since we might have both types, we need to generate nonces separately
237
- const bytes = psbt.serialize();
238
- const hasKeyPath = this.inputs.some((input) => input.scriptType === "p2trMusig2KeyPath");
239
- const hasScriptPath = this.inputs.some((input) => input.scriptType === "p2trMusig2ScriptPath");
240
- if (hasKeyPath && !hasScriptPath) {
241
- // Only key path inputs - generate bitgo nonces for all
242
- const psbt2 = BitGoPsbt.fromBytes(bytes, this.network);
243
- psbt2.generateMusig2Nonces(bitgoKey);
244
- psbt.combineMusig2Nonces(psbt2);
245
- }
246
- else if (hasScriptPath && !hasKeyPath) {
247
- // Only script path inputs - generate backup nonces for all
248
- const psbt2 = BitGoPsbt.fromBytes(bytes, this.network);
249
- psbt2.generateMusig2Nonces(backupKey);
250
- psbt.combineMusig2Nonces(psbt2);
251
- }
252
- else {
253
- const psbt2 = BitGoPsbt.fromBytes(bytes, this.network);
254
- psbt2.generateMusig2Nonces(bitgoKey);
255
- psbt.combineMusig2Nonces(psbt2);
256
- }
246
+ const hasKeyPath = this.inputs.some((input) => input.scriptType === "p2trMusig2KeyPath");
247
+ const hasScriptPath = this.inputs.some((input) => input.scriptType === "p2trMusig2ScriptPath");
248
+ // Key path uses user+bitgo, script path uses user+backup.
249
+ // generateMusig2Nonces fails if the key isn't a participant in any musig2 input,
250
+ // so we only call it for keys that match.
251
+ if (hasKeyPath) {
252
+ psbt.generateMusig2Nonces(bitgoKey);
253
+ }
254
+ if (hasScriptPath) {
255
+ psbt.generateMusig2Nonces(backupKey);
257
256
  }
258
257
  }
259
258
  // Sign all wallet inputs with user key (bulk - more efficient)
@@ -296,7 +295,7 @@ export class AcidTest {
296
295
  */
297
296
  static forAllNetworksSignStagesTxFormats(suiteConfig = {}) {
298
297
  return coinNames
299
- .filter((network) => isMainnet(network) && network !== "bsv") // Exclude bitcoinsv
298
+ .filter((network) => isMainnet(network) && network !== "bsv")
300
299
  .flatMap((network) => signStages.flatMap((signStage) => txFormats.map((txFormat) => AcidTest.withConfig(network, signStage, txFormat, suiteConfig))));
301
300
  }
302
301
  }
@@ -36,6 +36,11 @@ export class Bip322Namespace {
36
36
  * The index of the added input
37
37
  */
38
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
+ * Get the BIP322 message stored at a PSBT input index.
41
+ * Returns null if no message is stored.
42
+ */
43
+ static get_bip322_message(psbt: BitGoPsbt, input_index: number): string | undefined;
39
44
  /**
40
45
  * Verify a single input of a BIP-0322 PSBT proof
41
46
  *
@@ -318,16 +323,7 @@ export class BitGoPsbt {
318
323
  * generated for security. Custom session_id is only allowed on testnets for testing purposes.
319
324
  */
320
325
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
321
- /**
322
- * Returns the global xpubs from the PSBT as an array of WasmBIP32 instances.
323
- */
324
326
  get_global_xpubs(): any;
325
- /**
326
- * Get all PSBT inputs as an array of PsbtInputData
327
- *
328
- * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
329
- * for each input.
330
- */
331
327
  get_inputs(): any;
332
328
  /**
333
329
  * Get the network type for transaction extraction
@@ -336,23 +332,8 @@ export class BitGoPsbt {
336
332
  * wrapper class should be used in TypeScript.
337
333
  */
338
334
  get_network_type(): string;
339
- /**
340
- * Get all PSBT outputs as an array of PsbtOutputData
341
- *
342
- * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
343
- * for each output.
344
- */
345
335
  get_outputs(): any;
346
- /**
347
- * Get all PSBT outputs with resolved address strings.
348
- *
349
- * Unlike the generic WrapPsbt which requires a coin parameter, BitGoPsbt
350
- * uses the network it was created/deserialized with to resolve addresses.
351
- */
352
336
  get_outputs_with_address(): any;
353
- /**
354
- * Get the number of inputs in the PSBT
355
- */
356
337
  input_count(): number;
357
338
  /**
358
339
  * Check if an input is a MuSig2 keypath input.
@@ -368,17 +349,11 @@ export class BitGoPsbt {
368
349
  * - `false` otherwise (or if input_index is out of bounds)
369
350
  */
370
351
  is_musig2_input(input_index: number): boolean;
371
- /**
372
- * Get the transaction lock time
373
- */
374
352
  lock_time(): number;
375
353
  /**
376
354
  * Get the network of the PSBT
377
355
  */
378
356
  network(): string;
379
- /**
380
- * Get the number of outputs in the PSBT
381
- */
382
357
  output_count(): number;
383
358
  /**
384
359
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
@@ -659,9 +634,6 @@ export class BitGoPsbt {
659
634
  * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
660
635
  */
661
636
  verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
662
- /**
663
- * Get the transaction version
664
- */
665
637
  version(): number;
666
638
  /**
667
639
  * Get the Zcash version group ID (returns None for non-Zcash PSBTs)
@@ -1311,7 +1283,7 @@ export class WrapMiniscript {
1311
1283
  export class WrapPsbt {
1312
1284
  free(): void;
1313
1285
  [Symbol.dispose](): void;
1314
- addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1286
+ add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1315
1287
  /**
1316
1288
  * Add an input to the PSBT
1317
1289
  *
@@ -1325,8 +1297,8 @@ export class WrapPsbt {
1325
1297
  * # Returns
1326
1298
  * The index of the newly added input
1327
1299
  */
1328
- addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1329
- addOutput(script: Uint8Array, value: bigint): number;
1300
+ add_input_at_index(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1301
+ add_output(script: Uint8Array, value: bigint): number;
1330
1302
  /**
1331
1303
  * Add an output to the PSBT
1332
1304
  *
@@ -1337,7 +1309,7 @@ export class WrapPsbt {
1337
1309
  * # Returns
1338
1310
  * The index of the newly added output
1339
1311
  */
1340
- addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
1312
+ add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
1341
1313
  clone(): WrapPsbt;
1342
1314
  static deserialize(psbt: Uint8Array): WrapPsbt;
1343
1315
  /**
@@ -1350,57 +1322,23 @@ export class WrapPsbt {
1350
1322
  * - `Ok(WasmTransaction)` containing the extracted transaction
1351
1323
  * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
1352
1324
  */
1353
- extractTransaction(): WasmTransaction;
1354
- finalize(): void;
1355
- /**
1356
- * Get global xpubs from the PSBT as an array of WasmBIP32 instances.
1357
- */
1358
- getGlobalXpubs(): any;
1359
- /**
1360
- * Get all PSBT inputs as an array of PsbtInputData
1361
- *
1362
- * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
1363
- * for each input. This is useful for introspecting the PSBT structure.
1364
- */
1365
- getInputs(): any;
1366
- /**
1367
- * Get all PSBT outputs as an array of PsbtOutputData
1368
- *
1369
- * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
1370
- * for each output. This is useful for introspecting the PSBT structure.
1371
- */
1372
- getOutputs(): any;
1373
- /**
1374
- * Get all PSBT outputs with resolved address strings.
1375
- *
1376
- * Like `getOutputs()` but each element also includes an `address` field
1377
- * derived from the output script using the given coin name (e.g. "btc", "tbtc").
1378
- */
1379
- getOutputsWithAddress(coin: string): any;
1380
- /**
1381
- * Get partial signatures for an input
1382
- * Returns array of { pubkey: Uint8Array, signature: Uint8Array }
1383
- */
1384
- getPartialSignatures(input_index: number): any;
1325
+ extract_transaction(): WasmTransaction;
1326
+ finalize_mut(): void;
1327
+ get_global_xpubs(): any;
1328
+ get_inputs(): any;
1329
+ get_outputs(): any;
1330
+ get_outputs_with_address(coin: string): any;
1331
+ get_partial_signatures(input_index: number): any;
1385
1332
  /**
1386
1333
  * Get the unsigned transaction bytes
1387
1334
  *
1388
1335
  * # Returns
1389
1336
  * The serialized unsigned transaction
1390
1337
  */
1391
- getUnsignedTx(): Uint8Array;
1392
- /**
1393
- * Check if an input has any partial signatures
1394
- */
1395
- hasPartialSignatures(input_index: number): boolean;
1396
- /**
1397
- * Get the number of inputs in the PSBT
1398
- */
1399
- inputCount(): number;
1400
- /**
1401
- * Get the transaction lock time
1402
- */
1403
- lockTime(): number;
1338
+ get_unsigned_tx(): Uint8Array;
1339
+ has_partial_signatures(input_index: number): boolean;
1340
+ input_count(): number;
1341
+ lock_time(): number;
1404
1342
  /**
1405
1343
  * Create an empty PSBT
1406
1344
  *
@@ -1409,12 +1347,9 @@ export class WrapPsbt {
1409
1347
  * * `lock_time` - Transaction lock time (default: 0)
1410
1348
  */
1411
1349
  constructor(version?: number | null, lock_time?: number | null);
1412
- /**
1413
- * Get the number of outputs in the PSBT
1414
- */
1415
- outputCount(): number;
1416
- removeInput(index: number): void;
1417
- removeOutput(index: number): void;
1350
+ output_count(): number;
1351
+ remove_input(index: number): void;
1352
+ remove_output(index: number): void;
1418
1353
  serialize(): Uint8Array;
1419
1354
  /**
1420
1355
  * Sign all inputs with a WasmBIP32 key
@@ -1428,7 +1363,7 @@ export class WrapPsbt {
1428
1363
  * # Returns
1429
1364
  * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1430
1365
  */
1431
- signAll(key: WasmBIP32): any;
1366
+ sign_all(key: WasmBIP32): any;
1432
1367
  /**
1433
1368
  * Sign all inputs with a WasmECPair key
1434
1369
  *
@@ -1441,23 +1376,13 @@ export class WrapPsbt {
1441
1376
  * # Returns
1442
1377
  * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1443
1378
  */
1444
- signAllWithEcpair(key: WasmECPair): any;
1445
- signWithPrv(prv: Uint8Array): any;
1446
- signWithXprv(xprv: string): any;
1447
- /**
1448
- * Get the unsigned transaction ID as a hex string
1449
- */
1450
- unsignedTxId(): string;
1451
- updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
1452
- updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
1453
- /**
1454
- * Validate a signature at a specific input against a pubkey
1455
- * Returns true if the signature is valid
1456
- *
1457
- * This method handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1458
- * The pubkey should be provided as bytes (33 bytes for compressed ECDSA, 32 bytes for x-only Schnorr).
1459
- */
1460
- validateSignatureAtInput(input_index: number, pubkey: Uint8Array): boolean;
1379
+ sign_all_with_ecpair(key: WasmECPair): any;
1380
+ sign_with_prv(prv: Uint8Array): any;
1381
+ sign_with_xprv(xprv: string): any;
1382
+ unsigned_tx_id(): string;
1383
+ update_input_with_descriptor(input_index: number, descriptor: WrapDescriptor): void;
1384
+ update_output_with_descriptor(output_index: number, descriptor: WrapDescriptor): void;
1385
+ validate_signature_at_input(input_index: number, pubkey: Uint8Array): boolean;
1461
1386
  /**
1462
1387
  * Verify a signature at a specific input using a WasmBIP32 key
1463
1388
  *
@@ -1474,10 +1399,7 @@ export class WrapPsbt {
1474
1399
  * # Returns
1475
1400
  * `true` if a valid signature exists for the key, `false` otherwise
1476
1401
  */
1477
- verifySignatureWithKey(input_index: number, key: WasmBIP32): boolean;
1478
- /**
1479
- * Get the transaction version
1480
- */
1402
+ verify_signature_with_key(input_index: number, key: WasmBIP32): boolean;
1481
1403
  version(): number;
1482
1404
  }
1483
1405