@bitgo/wasm-utxo 2.0.0 → 3.0.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 (43) hide show
  1. package/dist/cjs/js/coinName.d.ts +3 -0
  2. package/dist/cjs/js/coinName.js +49 -0
  3. package/dist/cjs/js/descriptorWallet/Psbt.d.ts +49 -0
  4. package/dist/cjs/js/descriptorWallet/Psbt.js +126 -0
  5. package/dist/cjs/js/descriptorWallet/index.d.ts +1 -0
  6. package/dist/cjs/js/descriptorWallet/index.js +4 -0
  7. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -2
  8. package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +22 -0
  9. package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.d.ts +5 -0
  10. package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.js +7 -0
  11. package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -1
  12. package/dist/cjs/js/fixedScriptWallet/index.js +2 -1
  13. package/dist/cjs/js/index.d.ts +1 -30
  14. package/dist/cjs/js/index.js +2 -2
  15. package/dist/cjs/js/psbt.d.ts +2 -0
  16. package/dist/cjs/js/testutils/AcidTest.d.ts +3 -3
  17. package/dist/cjs/js/testutils/AcidTest.js +79 -80
  18. package/dist/cjs/js/wasm/wasm_utxo.d.ts +34 -103
  19. package/dist/cjs/js/wasm/wasm_utxo.js +99 -93
  20. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  21. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +73 -70
  22. package/dist/esm/js/coinName.d.ts +3 -0
  23. package/dist/esm/js/coinName.js +48 -0
  24. package/dist/esm/js/descriptorWallet/Psbt.d.ts +49 -0
  25. package/dist/esm/js/descriptorWallet/Psbt.js +122 -0
  26. package/dist/esm/js/descriptorWallet/index.d.ts +1 -0
  27. package/dist/esm/js/descriptorWallet/index.js +2 -0
  28. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -2
  29. package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +22 -1
  30. package/dist/esm/js/fixedScriptWallet/RootWalletKeys.d.ts +5 -0
  31. package/dist/esm/js/fixedScriptWallet/RootWalletKeys.js +7 -0
  32. package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -1
  33. package/dist/esm/js/fixedScriptWallet/index.js +1 -1
  34. package/dist/esm/js/index.d.ts +1 -30
  35. package/dist/esm/js/index.js +1 -1
  36. package/dist/esm/js/psbt.d.ts +2 -0
  37. package/dist/esm/js/testutils/AcidTest.d.ts +3 -3
  38. package/dist/esm/js/testutils/AcidTest.js +80 -81
  39. package/dist/esm/js/wasm/wasm_utxo.d.ts +34 -103
  40. package/dist/esm/js/wasm/wasm_utxo_bg.js +99 -93
  41. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  42. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +73 -70
  43. 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
  }
@@ -318,12 +318,7 @@ export class BitGoPsbt {
318
318
  * generated for security. Custom session_id is only allowed on testnets for testing purposes.
319
319
  */
320
320
  generate_musig2_nonces(xpriv: WasmBIP32, session_id_bytes?: Uint8Array | null): void;
321
- /**
322
- * Get all PSBT inputs as an array of PsbtInputData
323
- *
324
- * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
325
- * for each input.
326
- */
321
+ get_global_xpubs(): any;
327
322
  get_inputs(): any;
328
323
  /**
329
324
  * Get the network type for transaction extraction
@@ -332,23 +327,8 @@ export class BitGoPsbt {
332
327
  * wrapper class should be used in TypeScript.
333
328
  */
334
329
  get_network_type(): string;
335
- /**
336
- * Get all PSBT outputs as an array of PsbtOutputData
337
- *
338
- * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
339
- * for each output.
340
- */
341
330
  get_outputs(): any;
342
- /**
343
- * Get all PSBT outputs with resolved address strings.
344
- *
345
- * Unlike the generic WrapPsbt which requires a coin parameter, BitGoPsbt
346
- * uses the network it was created/deserialized with to resolve addresses.
347
- */
348
331
  get_outputs_with_address(): any;
349
- /**
350
- * Get the number of inputs in the PSBT
351
- */
352
332
  input_count(): number;
353
333
  /**
354
334
  * Check if an input is a MuSig2 keypath input.
@@ -364,17 +344,11 @@ export class BitGoPsbt {
364
344
  * - `false` otherwise (or if input_index is out of bounds)
365
345
  */
366
346
  is_musig2_input(input_index: number): boolean;
367
- /**
368
- * Get the transaction lock time
369
- */
370
347
  lock_time(): number;
371
348
  /**
372
349
  * Get the network of the PSBT
373
350
  */
374
351
  network(): string;
375
- /**
376
- * Get the number of outputs in the PSBT
377
- */
378
352
  output_count(): number;
379
353
  /**
380
354
  * Parse outputs with wallet keys to identify which outputs belong to a wallet
@@ -655,9 +629,6 @@ export class BitGoPsbt {
655
629
  * - `Err(WasmUtxoError)` if the input index is out of bounds, derivation fails, or verification fails
656
630
  */
657
631
  verify_signature_with_xpub(input_index: number, xpub: WasmBIP32): boolean;
658
- /**
659
- * Get the transaction version
660
- */
661
632
  version(): number;
662
633
  /**
663
634
  * Get the Zcash version group ID (returns None for non-Zcash PSBTs)
@@ -718,6 +689,12 @@ export class FixedScriptWalletNamespace {
718
689
  * - Dogecoin only supports legacy scripts (p2sh)
719
690
  */
720
691
  static supports_script_type(coin: string, script_type: string): boolean;
692
+ /**
693
+ * Sort an xpub triple into [user, backup, bitgo] order by validating
694
+ * against the PSBT's wallet inputs. Returns a RootWalletKeys with the
695
+ * correct ordering.
696
+ */
697
+ static to_wallet_keys(psbt: BitGoPsbt, user_or_a: WasmBIP32, backup_or_b: WasmBIP32, bitgo_or_c: WasmBIP32): WasmRootWalletKeys;
721
698
  }
722
699
 
723
700
  /**
@@ -1301,7 +1278,7 @@ export class WrapMiniscript {
1301
1278
  export class WrapPsbt {
1302
1279
  free(): void;
1303
1280
  [Symbol.dispose](): void;
1304
- addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1281
+ add_input(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1305
1282
  /**
1306
1283
  * Add an input to the PSBT
1307
1284
  *
@@ -1315,8 +1292,8 @@ export class WrapPsbt {
1315
1292
  * # Returns
1316
1293
  * The index of the newly added input
1317
1294
  */
1318
- addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1319
- addOutput(script: Uint8Array, value: bigint): number;
1295
+ add_input_at_index(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number | null): number;
1296
+ add_output(script: Uint8Array, value: bigint): number;
1320
1297
  /**
1321
1298
  * Add an output to the PSBT
1322
1299
  *
@@ -1327,7 +1304,7 @@ export class WrapPsbt {
1327
1304
  * # Returns
1328
1305
  * The index of the newly added output
1329
1306
  */
1330
- addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
1307
+ add_output_at_index(index: number, script: Uint8Array, value: bigint): number;
1331
1308
  clone(): WrapPsbt;
1332
1309
  static deserialize(psbt: Uint8Array): WrapPsbt;
1333
1310
  /**
@@ -1340,53 +1317,23 @@ export class WrapPsbt {
1340
1317
  * - `Ok(WasmTransaction)` containing the extracted transaction
1341
1318
  * - `Err(WasmUtxoError)` if the PSBT is not fully finalized or extraction fails
1342
1319
  */
1343
- extractTransaction(): WasmTransaction;
1344
- finalize(): void;
1345
- /**
1346
- * Get all PSBT inputs as an array of PsbtInputData
1347
- *
1348
- * Returns an array with witness_utxo, bip32_derivation, and tap_bip32_derivation
1349
- * for each input. This is useful for introspecting the PSBT structure.
1350
- */
1351
- getInputs(): any;
1352
- /**
1353
- * Get all PSBT outputs as an array of PsbtOutputData
1354
- *
1355
- * Returns an array with script, value, bip32_derivation, and tap_bip32_derivation
1356
- * for each output. This is useful for introspecting the PSBT structure.
1357
- */
1358
- getOutputs(): any;
1359
- /**
1360
- * Get all PSBT outputs with resolved address strings.
1361
- *
1362
- * Like `getOutputs()` but each element also includes an `address` field
1363
- * derived from the output script using the given coin name (e.g. "btc", "tbtc").
1364
- */
1365
- getOutputsWithAddress(coin: string): any;
1366
- /**
1367
- * Get partial signatures for an input
1368
- * Returns array of { pubkey: Uint8Array, signature: Uint8Array }
1369
- */
1370
- getPartialSignatures(input_index: number): any;
1320
+ extract_transaction(): WasmTransaction;
1321
+ finalize_mut(): void;
1322
+ get_global_xpubs(): any;
1323
+ get_inputs(): any;
1324
+ get_outputs(): any;
1325
+ get_outputs_with_address(coin: string): any;
1326
+ get_partial_signatures(input_index: number): any;
1371
1327
  /**
1372
1328
  * Get the unsigned transaction bytes
1373
1329
  *
1374
1330
  * # Returns
1375
1331
  * The serialized unsigned transaction
1376
1332
  */
1377
- getUnsignedTx(): Uint8Array;
1378
- /**
1379
- * Check if an input has any partial signatures
1380
- */
1381
- hasPartialSignatures(input_index: number): boolean;
1382
- /**
1383
- * Get the number of inputs in the PSBT
1384
- */
1385
- inputCount(): number;
1386
- /**
1387
- * Get the transaction lock time
1388
- */
1389
- lockTime(): number;
1333
+ get_unsigned_tx(): Uint8Array;
1334
+ has_partial_signatures(input_index: number): boolean;
1335
+ input_count(): number;
1336
+ lock_time(): number;
1390
1337
  /**
1391
1338
  * Create an empty PSBT
1392
1339
  *
@@ -1395,12 +1342,9 @@ export class WrapPsbt {
1395
1342
  * * `lock_time` - Transaction lock time (default: 0)
1396
1343
  */
1397
1344
  constructor(version?: number | null, lock_time?: number | null);
1398
- /**
1399
- * Get the number of outputs in the PSBT
1400
- */
1401
- outputCount(): number;
1402
- removeInput(index: number): void;
1403
- removeOutput(index: number): void;
1345
+ output_count(): number;
1346
+ remove_input(index: number): void;
1347
+ remove_output(index: number): void;
1404
1348
  serialize(): Uint8Array;
1405
1349
  /**
1406
1350
  * Sign all inputs with a WasmBIP32 key
@@ -1414,7 +1358,7 @@ export class WrapPsbt {
1414
1358
  * # Returns
1415
1359
  * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1416
1360
  */
1417
- signAll(key: WasmBIP32): any;
1361
+ sign_all(key: WasmBIP32): any;
1418
1362
  /**
1419
1363
  * Sign all inputs with a WasmECPair key
1420
1364
  *
@@ -1427,23 +1371,13 @@ export class WrapPsbt {
1427
1371
  * # Returns
1428
1372
  * A SigningKeysMap converted to JsValue (object mapping input indices to signing keys)
1429
1373
  */
1430
- signAllWithEcpair(key: WasmECPair): any;
1431
- signWithPrv(prv: Uint8Array): any;
1432
- signWithXprv(xprv: string): any;
1433
- /**
1434
- * Get the unsigned transaction ID as a hex string
1435
- */
1436
- unsignedTxId(): string;
1437
- updateInputWithDescriptor(input_index: number, descriptor: WrapDescriptor): void;
1438
- updateOutputWithDescriptor(output_index: number, descriptor: WrapDescriptor): void;
1439
- /**
1440
- * Validate a signature at a specific input against a pubkey
1441
- * Returns true if the signature is valid
1442
- *
1443
- * This method handles both ECDSA (legacy/SegWit) and Schnorr (Taproot) signatures.
1444
- * The pubkey should be provided as bytes (33 bytes for compressed ECDSA, 32 bytes for x-only Schnorr).
1445
- */
1446
- validateSignatureAtInput(input_index: number, pubkey: Uint8Array): boolean;
1374
+ sign_all_with_ecpair(key: WasmECPair): any;
1375
+ sign_with_prv(prv: Uint8Array): any;
1376
+ sign_with_xprv(xprv: string): any;
1377
+ unsigned_tx_id(): string;
1378
+ update_input_with_descriptor(input_index: number, descriptor: WrapDescriptor): void;
1379
+ update_output_with_descriptor(output_index: number, descriptor: WrapDescriptor): void;
1380
+ validate_signature_at_input(input_index: number, pubkey: Uint8Array): boolean;
1447
1381
  /**
1448
1382
  * Verify a signature at a specific input using a WasmBIP32 key
1449
1383
  *
@@ -1460,10 +1394,7 @@ export class WrapPsbt {
1460
1394
  * # Returns
1461
1395
  * `true` if a valid signature exists for the key, `false` otherwise
1462
1396
  */
1463
- verifySignatureWithKey(input_index: number, key: WasmBIP32): boolean;
1464
- /**
1465
- * Get the transaction version
1466
- */
1397
+ verify_signature_with_key(input_index: number, key: WasmBIP32): boolean;
1467
1398
  version(): number;
1468
1399
  }
1469
1400