@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.
- package/dist/cjs/js/coinName.d.ts +3 -0
- package/dist/cjs/js/coinName.js +49 -0
- package/dist/cjs/js/descriptorWallet/Psbt.d.ts +49 -0
- package/dist/cjs/js/descriptorWallet/Psbt.js +126 -0
- package/dist/cjs/js/descriptorWallet/index.d.ts +1 -0
- package/dist/cjs/js/descriptorWallet/index.js +4 -0
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -2
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +22 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.d.ts +5 -0
- package/dist/cjs/js/fixedScriptWallet/RootWalletKeys.js +7 -0
- package/dist/cjs/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/cjs/js/fixedScriptWallet/index.js +2 -1
- package/dist/cjs/js/index.d.ts +1 -30
- package/dist/cjs/js/index.js +2 -2
- package/dist/cjs/js/psbt.d.ts +2 -0
- package/dist/cjs/js/testutils/AcidTest.d.ts +3 -3
- package/dist/cjs/js/testutils/AcidTest.js +79 -80
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +34 -103
- package/dist/cjs/js/wasm/wasm_utxo.js +99 -93
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +73 -70
- package/dist/esm/js/coinName.d.ts +3 -0
- package/dist/esm/js/coinName.js +48 -0
- package/dist/esm/js/descriptorWallet/Psbt.d.ts +49 -0
- package/dist/esm/js/descriptorWallet/Psbt.js +122 -0
- package/dist/esm/js/descriptorWallet/index.d.ts +1 -0
- package/dist/esm/js/descriptorWallet/index.js +2 -0
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +17 -2
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +22 -1
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.d.ts +5 -0
- package/dist/esm/js/fixedScriptWallet/RootWalletKeys.js +7 -0
- package/dist/esm/js/fixedScriptWallet/index.d.ts +1 -1
- package/dist/esm/js/fixedScriptWallet/index.js +1 -1
- package/dist/esm/js/index.d.ts +1 -30
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/psbt.d.ts +2 -0
- package/dist/esm/js/testutils/AcidTest.d.ts +3 -3
- package/dist/esm/js/testutils/AcidTest.js +80 -81
- package/dist/esm/js/wasm/wasm_utxo.d.ts +34 -103
- package/dist/esm/js/wasm/wasm_utxo_bg.js +99 -93
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +73 -70
- package/package.json +1 -1
|
@@ -4,6 +4,7 @@ exports.AcidTest = exports.outputScriptTypes = exports.inputScriptTypes = export
|
|
|
4
4
|
const BitGoPsbt_js_1 = require("../fixedScriptWallet/BitGoPsbt.js");
|
|
5
5
|
const ZcashBitGoPsbt_js_1 = require("../fixedScriptWallet/ZcashBitGoPsbt.js");
|
|
6
6
|
const ecpair_js_1 = require("../ecpair.js");
|
|
7
|
+
const transaction_js_1 = require("../transaction.js");
|
|
7
8
|
const index_js_1 = require("../fixedScriptWallet/index.js");
|
|
8
9
|
Object.defineProperty(exports, "inputScriptTypes", { enumerable: true, get: function () { return index_js_1.inputScriptTypes; } });
|
|
9
10
|
Object.defineProperty(exports, "outputScriptTypes", { enumerable: true, get: function () { return index_js_1.outputScriptTypes; } });
|
|
@@ -11,6 +12,21 @@ const coinName_js_1 = require("../coinName.js");
|
|
|
11
12
|
const keys_js_1 = require("./keys.js");
|
|
12
13
|
exports.signStages = ["unsigned", "halfsigned", "fullsigned"];
|
|
13
14
|
exports.txFormats = ["psbt", "psbt-lite"];
|
|
15
|
+
/** Map InputScriptType to the OutputScriptType used for chain code derivation */
|
|
16
|
+
function inputScriptTypeToOutputScriptType(scriptType) {
|
|
17
|
+
switch (scriptType) {
|
|
18
|
+
case "p2sh":
|
|
19
|
+
case "p2shP2wsh":
|
|
20
|
+
case "p2wsh":
|
|
21
|
+
case "p2trLegacy":
|
|
22
|
+
return scriptType;
|
|
23
|
+
case "p2shP2pk":
|
|
24
|
+
return "p2sh";
|
|
25
|
+
case "p2trMusig2ScriptPath":
|
|
26
|
+
case "p2trMusig2KeyPath":
|
|
27
|
+
return "p2trMusig2";
|
|
28
|
+
}
|
|
29
|
+
}
|
|
14
30
|
/**
|
|
15
31
|
* Creates a valid PSBT with as many features as possible (kitchen sink).
|
|
16
32
|
*
|
|
@@ -33,7 +49,7 @@ exports.txFormats = ["psbt", "psbt-lite"];
|
|
|
33
49
|
* - psbt-lite: Only witness_utxo (no non_witness_utxo)
|
|
34
50
|
*/
|
|
35
51
|
class AcidTest {
|
|
36
|
-
|
|
52
|
+
coin;
|
|
37
53
|
signStage;
|
|
38
54
|
txFormat;
|
|
39
55
|
rootWalletKeys;
|
|
@@ -44,8 +60,8 @@ class AcidTest {
|
|
|
44
60
|
userXprv;
|
|
45
61
|
backupXprv;
|
|
46
62
|
bitgoXprv;
|
|
47
|
-
constructor(
|
|
48
|
-
this.
|
|
63
|
+
constructor(coin, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple) {
|
|
64
|
+
this.coin = coin;
|
|
49
65
|
this.signStage = signStage;
|
|
50
66
|
this.txFormat = txFormat;
|
|
51
67
|
this.rootWalletKeys = rootWalletKeys;
|
|
@@ -59,7 +75,7 @@ class AcidTest {
|
|
|
59
75
|
/**
|
|
60
76
|
* Create an AcidTest with specific configuration
|
|
61
77
|
*/
|
|
62
|
-
static withConfig(
|
|
78
|
+
static withConfig(coin, signStage, txFormat, suiteConfig = {}) {
|
|
63
79
|
const rootWalletKeys = (0, keys_js_1.getDefaultWalletKeys)();
|
|
64
80
|
const otherWalletKeys = (0, keys_js_1.getWalletKeysForSeed)("too many secrets");
|
|
65
81
|
// Filter inputs based on network support
|
|
@@ -70,9 +86,9 @@ class AcidTest {
|
|
|
70
86
|
return true;
|
|
71
87
|
// Map input script types to output script types for support check
|
|
72
88
|
if (scriptType === "p2trMusig2KeyPath" || scriptType === "p2trMusig2ScriptPath") {
|
|
73
|
-
return (0, index_js_1.supportsScriptType)(
|
|
89
|
+
return (0, index_js_1.supportsScriptType)(coin, "p2trMusig2");
|
|
74
90
|
}
|
|
75
|
-
return (0, index_js_1.supportsScriptType)(
|
|
91
|
+
return (0, index_js_1.supportsScriptType)(coin, scriptType);
|
|
76
92
|
})
|
|
77
93
|
.filter((scriptType) => (suiteConfig.includeP2trMusig2ScriptPath ?? false) ||
|
|
78
94
|
scriptType !== "p2trMusig2ScriptPath")
|
|
@@ -82,7 +98,7 @@ class AcidTest {
|
|
|
82
98
|
}));
|
|
83
99
|
// Filter outputs based on network support
|
|
84
100
|
const outputs = index_js_1.outputScriptTypes
|
|
85
|
-
.filter((scriptType) => (0, index_js_1.supportsScriptType)(
|
|
101
|
+
.filter((scriptType) => (0, index_js_1.supportsScriptType)(coin, scriptType))
|
|
86
102
|
.map((scriptType, index) => ({
|
|
87
103
|
scriptType,
|
|
88
104
|
value: BigInt(900 + index * 100), // Deterministic amounts
|
|
@@ -95,13 +111,13 @@ class AcidTest {
|
|
|
95
111
|
outputs.push({ opReturn: "setec astronomy", value: BigInt(0) });
|
|
96
112
|
// Get private keys for signing
|
|
97
113
|
const xprvTriple = (0, keys_js_1.getKeyTriple)("default");
|
|
98
|
-
return new AcidTest(
|
|
114
|
+
return new AcidTest(coin, signStage, txFormat, rootWalletKeys, otherWalletKeys, inputs, outputs, xprvTriple);
|
|
99
115
|
}
|
|
100
116
|
/**
|
|
101
117
|
* Get a human-readable name for this test configuration
|
|
102
118
|
*/
|
|
103
119
|
get name() {
|
|
104
|
-
return `${this.
|
|
120
|
+
return `${this.coin} ${this.signStage} ${this.txFormat}`;
|
|
105
121
|
}
|
|
106
122
|
/**
|
|
107
123
|
* Get the BIP32 user key for replay protection (p2shP2pk)
|
|
@@ -114,58 +130,55 @@ class AcidTest {
|
|
|
114
130
|
*/
|
|
115
131
|
createPsbt() {
|
|
116
132
|
// Use ZcashBitGoPsbt for Zcash networks
|
|
117
|
-
const isZcash = this.
|
|
133
|
+
const isZcash = this.coin === "zec" || this.coin === "tzec";
|
|
118
134
|
const psbt = isZcash
|
|
119
|
-
? ZcashBitGoPsbt_js_1.ZcashBitGoPsbt.
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
consensusBranchId: 0xc2d6d0b4, // NU5
|
|
135
|
+
? ZcashBitGoPsbt_js_1.ZcashBitGoPsbt.createEmpty(this.coin, this.rootWalletKeys, {
|
|
136
|
+
// Sapling activation height: mainnet=419200, testnet=280000
|
|
137
|
+
blockHeight: this.coin === "zec" ? 419200 : 280000,
|
|
123
138
|
})
|
|
124
|
-
: BitGoPsbt_js_1.BitGoPsbt.createEmpty(this.
|
|
139
|
+
: BitGoPsbt_js_1.BitGoPsbt.createEmpty(this.coin, this.rootWalletKeys, {
|
|
125
140
|
version: 2,
|
|
126
141
|
lockTime: 0,
|
|
127
142
|
});
|
|
143
|
+
// Build a fake previous transaction for non_witness_utxo (psbt format)
|
|
144
|
+
const usePrevTx = this.txFormat === "psbt" && !isZcash;
|
|
145
|
+
const buildPrevTx = (vout, script, value) => {
|
|
146
|
+
if (!usePrevTx)
|
|
147
|
+
return undefined;
|
|
148
|
+
const tx = transaction_js_1.Transaction.create();
|
|
149
|
+
tx.addInput("0".repeat(64), 0xffffffff);
|
|
150
|
+
for (let i = 0; i < vout; i++) {
|
|
151
|
+
tx.addOutput(new Uint8Array(0), 0n);
|
|
152
|
+
}
|
|
153
|
+
tx.addOutput(script, value);
|
|
154
|
+
return tx.toBytes();
|
|
155
|
+
};
|
|
128
156
|
// Add inputs with deterministic outpoints
|
|
129
157
|
this.inputs.forEach((input, index) => {
|
|
130
|
-
// Resolve scriptId: either from explicit scriptId or from scriptType + index
|
|
131
|
-
const scriptId = input.scriptId ?? {
|
|
132
|
-
chain: index_js_1.ChainCode.value("p2sh", "external"),
|
|
133
|
-
index: input.index ?? index,
|
|
134
|
-
};
|
|
135
158
|
const walletKeys = input.walletKeys ?? this.rootWalletKeys;
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
if (
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
const ecpair = ecpair_js_1.ECPair.fromPublicKey(replayKey.publicKey);
|
|
143
|
-
psbt.addReplayProtectionInput({
|
|
144
|
-
txid: "0".repeat(64),
|
|
145
|
-
vout: index,
|
|
146
|
-
value: input.value,
|
|
147
|
-
}, ecpair);
|
|
159
|
+
const outpoint = { txid: "0".repeat(64), vout: index, value: input.value };
|
|
160
|
+
// scriptId variant: caller provides explicit chain + index
|
|
161
|
+
if (input.scriptId) {
|
|
162
|
+
const script = (0, index_js_1.outputScript)(walletKeys, input.scriptId.chain, input.scriptId.index, this.coin);
|
|
163
|
+
psbt.addWalletInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, walletKeys, { scriptId: input.scriptId, signPath: { signer: "user", cosigner: "bitgo" } });
|
|
164
|
+
return;
|
|
148
165
|
}
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
}
|
|
156
|
-
else {
|
|
157
|
-
// Default: user + bitgo
|
|
158
|
-
signPath = { signer: "user", cosigner: "bitgo" };
|
|
159
|
-
}
|
|
160
|
-
psbt.addWalletInput({
|
|
161
|
-
txid: "0".repeat(64),
|
|
162
|
-
vout: index,
|
|
163
|
-
value: input.value,
|
|
164
|
-
}, walletKeys, {
|
|
165
|
-
scriptId,
|
|
166
|
-
signPath,
|
|
167
|
-
});
|
|
166
|
+
const scriptType = input.scriptType ?? "p2sh";
|
|
167
|
+
if (scriptType === "p2shP2pk") {
|
|
168
|
+
const ecpair = ecpair_js_1.ECPair.fromPublicKey(this.getReplayProtectionKey().publicKey);
|
|
169
|
+
const script = (0, index_js_1.p2shP2pkOutputScript)(ecpair.publicKey);
|
|
170
|
+
psbt.addReplayProtectionInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, ecpair);
|
|
171
|
+
return;
|
|
168
172
|
}
|
|
173
|
+
const scriptId = {
|
|
174
|
+
chain: index_js_1.ChainCode.value(inputScriptTypeToOutputScriptType(scriptType), "external"),
|
|
175
|
+
index: input.index ?? index,
|
|
176
|
+
};
|
|
177
|
+
const signPath = scriptType === "p2trMusig2ScriptPath"
|
|
178
|
+
? { signer: "user", cosigner: "backup" }
|
|
179
|
+
: { signer: "user", cosigner: "bitgo" };
|
|
180
|
+
const script = (0, index_js_1.outputScript)(walletKeys, scriptId.chain, scriptId.index, this.coin);
|
|
181
|
+
psbt.addWalletInput({ ...outpoint, prevTx: buildPrevTx(index, script, input.value) }, walletKeys, { scriptId, signPath });
|
|
169
182
|
});
|
|
170
183
|
// Add outputs
|
|
171
184
|
this.outputs.forEach((output, index) => {
|
|
@@ -196,7 +209,7 @@ class AcidTest {
|
|
|
196
209
|
chain: scriptId.chain,
|
|
197
210
|
index: output.index ?? 1000 + index,
|
|
198
211
|
};
|
|
199
|
-
const script = (0, index_js_1.outputScript)(this.rootWalletKeys, externalScriptId.chain, externalScriptId.index, this.
|
|
212
|
+
const script = (0, index_js_1.outputScript)(this.rootWalletKeys, externalScriptId.chain, externalScriptId.index, this.coin);
|
|
200
213
|
psbt.addOutput(script, output.value);
|
|
201
214
|
}
|
|
202
215
|
else {
|
|
@@ -227,36 +240,22 @@ class AcidTest {
|
|
|
227
240
|
// Generate MuSig2 nonces for user if needed
|
|
228
241
|
const hasMusig2Inputs = this.inputs.some((input) => input.scriptType === "p2trMusig2KeyPath" || input.scriptType === "p2trMusig2ScriptPath");
|
|
229
242
|
if (hasMusig2Inputs) {
|
|
230
|
-
|
|
231
|
-
if (isZcash) {
|
|
243
|
+
if (this.coin === "zec" || this.coin === "tzec") {
|
|
232
244
|
throw new Error("Zcash does not support MuSig2/Taproot inputs");
|
|
233
245
|
}
|
|
234
|
-
//
|
|
246
|
+
// MuSig2 requires ALL participant nonces before ANY signing.
|
|
247
|
+
// Generate nonces directly on the same PSBT for each participant key.
|
|
235
248
|
psbt.generateMusig2Nonces(userKey);
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
psbt2.generateMusig2Nonces(bitgoKey);
|
|
247
|
-
psbt.combineMusig2Nonces(psbt2);
|
|
248
|
-
}
|
|
249
|
-
else if (hasScriptPath && !hasKeyPath) {
|
|
250
|
-
// Only script path inputs - generate backup nonces for all
|
|
251
|
-
const psbt2 = BitGoPsbt_js_1.BitGoPsbt.fromBytes(bytes, this.network);
|
|
252
|
-
psbt2.generateMusig2Nonces(backupKey);
|
|
253
|
-
psbt.combineMusig2Nonces(psbt2);
|
|
254
|
-
}
|
|
255
|
-
else {
|
|
256
|
-
const psbt2 = BitGoPsbt_js_1.BitGoPsbt.fromBytes(bytes, this.network);
|
|
257
|
-
psbt2.generateMusig2Nonces(bitgoKey);
|
|
258
|
-
psbt.combineMusig2Nonces(psbt2);
|
|
259
|
-
}
|
|
249
|
+
const hasKeyPath = this.inputs.some((input) => input.scriptType === "p2trMusig2KeyPath");
|
|
250
|
+
const hasScriptPath = this.inputs.some((input) => input.scriptType === "p2trMusig2ScriptPath");
|
|
251
|
+
// Key path uses user+bitgo, script path uses user+backup.
|
|
252
|
+
// generateMusig2Nonces fails if the key isn't a participant in any musig2 input,
|
|
253
|
+
// so we only call it for keys that match.
|
|
254
|
+
if (hasKeyPath) {
|
|
255
|
+
psbt.generateMusig2Nonces(bitgoKey);
|
|
256
|
+
}
|
|
257
|
+
if (hasScriptPath) {
|
|
258
|
+
psbt.generateMusig2Nonces(backupKey);
|
|
260
259
|
}
|
|
261
260
|
}
|
|
262
261
|
// Sign all wallet inputs with user key (bulk - more efficient)
|
|
@@ -299,7 +298,7 @@ class AcidTest {
|
|
|
299
298
|
*/
|
|
300
299
|
static forAllNetworksSignStagesTxFormats(suiteConfig = {}) {
|
|
301
300
|
return coinName_js_1.coinNames
|
|
302
|
-
.filter((network) => (0, coinName_js_1.isMainnet)(network) && network !== "bsv")
|
|
301
|
+
.filter((network) => (0, coinName_js_1.isMainnet)(network) && network !== "bsv")
|
|
303
302
|
.flatMap((network) => exports.signStages.flatMap((signStage) => exports.txFormats.map((txFormat) => AcidTest.withConfig(network, signStage, txFormat, suiteConfig))));
|
|
304
303
|
}
|
|
305
304
|
}
|
|
@@ -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
|
-
|
|
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
|
-
|
|
1319
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1344
|
-
|
|
1345
|
-
|
|
1346
|
-
|
|
1347
|
-
|
|
1348
|
-
|
|
1349
|
-
|
|
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
|
-
|
|
1378
|
-
|
|
1379
|
-
|
|
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
|
-
|
|
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
|
-
|
|
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
|
-
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1435
|
-
|
|
1436
|
-
|
|
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
|
-
|
|
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
|
|