@bitgo/wasm-utxo 1.44.0 → 2.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.
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.d.ts +34 -50
- package/dist/cjs/js/fixedScriptWallet/BitGoPsbt.js +71 -32
- 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 +6 -1
- package/dist/cjs/js/psbt.d.ts +15 -6
- package/dist/cjs/js/transaction.d.ts +2 -6
- package/dist/cjs/js/transaction.js +6 -6
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +32 -86
- package/dist/cjs/js/wasm/wasm_utxo.js +463 -81
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +71 -54
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.d.ts +34 -50
- package/dist/esm/js/fixedScriptWallet/BitGoPsbt.js +71 -33
- 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 +6 -1
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/psbt.d.ts +15 -6
- package/dist/esm/js/transaction.d.ts +2 -6
- package/dist/esm/js/transaction.js +6 -6
- package/dist/esm/js/wasm/wasm_utxo.d.ts +32 -86
- package/dist/esm/js/wasm/wasm_utxo_bg.js +463 -81
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +71 -54
- package/package.json +11 -4
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BitGoPsbt as WasmBitGoPsbt, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
|
|
2
|
-
import type {
|
|
3
|
-
import { type WalletKeysArg } from "./RootWalletKeys.js";
|
|
2
|
+
import type { IPsbtWithAddress } from "../psbt.js";
|
|
3
|
+
import { type WalletKeysArg, RootWalletKeys } from "./RootWalletKeys.js";
|
|
4
4
|
import { type ReplayProtectionArg } from "./ReplayProtection.js";
|
|
5
|
-
import { type BIP32Arg } from "../bip32.js";
|
|
5
|
+
import { type BIP32Arg, BIP32 } from "../bip32.js";
|
|
6
6
|
import { type ECPairArg } from "../ecpair.js";
|
|
7
7
|
import type { UtxolibName } from "../utxolibCompat.js";
|
|
8
8
|
import type { CoinName } from "../coinName.js";
|
|
@@ -98,7 +98,7 @@ export type ParseTransactionOptions = {
|
|
|
98
98
|
export type ParseOutputsOptions = {
|
|
99
99
|
payGoPubkeys?: ECPairArg[];
|
|
100
100
|
};
|
|
101
|
-
export declare class BitGoPsbt implements
|
|
101
|
+
export declare class BitGoPsbt implements IPsbtWithAddress {
|
|
102
102
|
protected _wasm: WasmBitGoPsbt;
|
|
103
103
|
protected constructor(_wasm: WasmBitGoPsbt);
|
|
104
104
|
/**
|
|
@@ -155,6 +155,8 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
155
155
|
* }, outputScript);
|
|
156
156
|
* ```
|
|
157
157
|
*/
|
|
158
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
159
|
+
addInputAtIndex(index: number, options: AddInputOptions, script: Uint8Array): number;
|
|
158
160
|
addInput(options: AddInputOptions, script: Uint8Array): number;
|
|
159
161
|
/**
|
|
160
162
|
* Add an output to the PSBT
|
|
@@ -168,41 +170,11 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
168
170
|
* const outputIndex = psbt.addOutput(outputScript, 50000n);
|
|
169
171
|
* ```
|
|
170
172
|
*/
|
|
173
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
174
|
+
addOutputAtIndex(index: number, address: string, value: bigint): number;
|
|
175
|
+
addOutputAtIndex(index: number, options: AddOutputOptions): number;
|
|
171
176
|
addOutput(script: Uint8Array, value: bigint): number;
|
|
172
|
-
/**
|
|
173
|
-
* Add an output to the PSBT by address
|
|
174
|
-
*
|
|
175
|
-
* @param address - The destination address
|
|
176
|
-
* @param value - Value in satoshis
|
|
177
|
-
* @returns The index of the newly added output
|
|
178
|
-
*
|
|
179
|
-
* @example
|
|
180
|
-
* ```typescript
|
|
181
|
-
* const outputIndex = psbt.addOutput("bc1q...", 50000n);
|
|
182
|
-
* ```
|
|
183
|
-
*/
|
|
184
177
|
addOutput(address: string, value: bigint): number;
|
|
185
|
-
/**
|
|
186
|
-
* Add an output to the PSBT
|
|
187
|
-
*
|
|
188
|
-
* @param options - Output options (script or address, and value)
|
|
189
|
-
* @returns The index of the newly added output
|
|
190
|
-
*
|
|
191
|
-
* @example
|
|
192
|
-
* ```typescript
|
|
193
|
-
* // Using script
|
|
194
|
-
* const outputIndex = psbt.addOutput({
|
|
195
|
-
* script: outputScript,
|
|
196
|
-
* value: 50000n,
|
|
197
|
-
* });
|
|
198
|
-
*
|
|
199
|
-
* // Using address
|
|
200
|
-
* const outputIndex = psbt.addOutput({
|
|
201
|
-
* address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4",
|
|
202
|
-
* value: 50000n,
|
|
203
|
-
* });
|
|
204
|
-
* ```
|
|
205
|
-
*/
|
|
206
178
|
addOutput(options: AddOutputOptions): number;
|
|
207
179
|
/**
|
|
208
180
|
* Add a wallet input with full PSBT metadata
|
|
@@ -243,6 +215,7 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
243
215
|
* );
|
|
244
216
|
* ```
|
|
245
217
|
*/
|
|
218
|
+
addWalletInputAtIndex(index: number, inputOptions: AddInputOptions, walletKeys: WalletKeysArg, walletOptions: AddWalletInputOptions): number;
|
|
246
219
|
addWalletInput(inputOptions: AddInputOptions, walletKeys: WalletKeysArg, walletOptions: AddWalletInputOptions): number;
|
|
247
220
|
/**
|
|
248
221
|
* Add a wallet output with full PSBT metadata
|
|
@@ -274,6 +247,7 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
274
247
|
* });
|
|
275
248
|
* ```
|
|
276
249
|
*/
|
|
250
|
+
addWalletOutputAtIndex(index: number, walletKeys: WalletKeysArg, options: AddWalletOutputOptions): number;
|
|
277
251
|
addWalletOutput(walletKeys: WalletKeysArg, options: AddWalletOutputOptions): number;
|
|
278
252
|
/**
|
|
279
253
|
* Add a replay protection input to the PSBT
|
|
@@ -294,22 +268,21 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
294
268
|
* );
|
|
295
269
|
* ```
|
|
296
270
|
*/
|
|
271
|
+
addReplayProtectionInputAtIndex(index: number, inputOptions: AddInputOptions, key: ECPairArg): number;
|
|
297
272
|
addReplayProtectionInput(inputOptions: AddInputOptions, key: ECPairArg): number;
|
|
273
|
+
removeInput(index: number): void;
|
|
274
|
+
removeOutput(index: number): void;
|
|
298
275
|
/**
|
|
299
276
|
* Get the unsigned transaction ID
|
|
300
277
|
* @returns The unsigned transaction ID
|
|
301
278
|
*/
|
|
302
|
-
|
|
279
|
+
unsignedTxId(): string;
|
|
303
280
|
/**
|
|
304
281
|
* Get the transaction version
|
|
305
282
|
* @returns The transaction version number
|
|
306
283
|
*/
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
* Get the transaction lock time
|
|
310
|
-
* @returns The transaction lock time
|
|
311
|
-
*/
|
|
312
|
-
get lockTime(): number;
|
|
284
|
+
version(): number;
|
|
285
|
+
lockTime(): number;
|
|
313
286
|
/**
|
|
314
287
|
* Parse transaction with wallet keys to identify wallet inputs/outputs
|
|
315
288
|
* @param walletKeys - The wallet keys to use for identification
|
|
@@ -584,12 +557,8 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
584
557
|
* Get the number of inputs in the PSBT
|
|
585
558
|
* @returns The number of inputs
|
|
586
559
|
*/
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
* Get the number of outputs in the PSBT
|
|
590
|
-
* @returns The number of outputs
|
|
591
|
-
*/
|
|
592
|
-
get outputCount(): number;
|
|
560
|
+
inputCount(): number;
|
|
561
|
+
outputCount(): number;
|
|
593
562
|
/**
|
|
594
563
|
* Get all PSBT inputs as an array
|
|
595
564
|
*
|
|
@@ -626,4 +595,19 @@ export declare class BitGoPsbt implements IPsbtIntrospectionWithAddress {
|
|
|
626
595
|
* ```
|
|
627
596
|
*/
|
|
628
597
|
getOutputsWithAddress(): PsbtOutputDataWithAddress[];
|
|
598
|
+
/**
|
|
599
|
+
* Returns the unordered global xpubs from this PSBT as BIP32 instances.
|
|
600
|
+
*/
|
|
601
|
+
getGlobalXpubs(): BIP32[];
|
|
629
602
|
}
|
|
603
|
+
/**
|
|
604
|
+
* Extract sorted wallet keys from a PSBT's global xpub fields.
|
|
605
|
+
*
|
|
606
|
+
* This should only be used in exceptional circumstances where the real wallet
|
|
607
|
+
* keys are not available — for example, legacy cold wallets where the PSBT
|
|
608
|
+
* was built with derived keys (from coldDerivationSeed) but the caller only
|
|
609
|
+
* has root xpubs. Prefer passing wallet keys explicitly wherever possible.
|
|
610
|
+
*
|
|
611
|
+
* @returns Sorted [user, backup, bitgo] RootWalletKeys
|
|
612
|
+
*/
|
|
613
|
+
export declare function getWalletKeysFromPsbt(psbt: BitGoPsbt, xpubs: BIP32[]): RootWalletKeys;
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.BitGoPsbt = void 0;
|
|
4
|
+
exports.getWalletKeysFromPsbt = getWalletKeysFromPsbt;
|
|
4
5
|
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
5
6
|
const RootWalletKeys_js_1 = require("./RootWalletKeys.js");
|
|
6
7
|
const ReplayProtection_js_1 = require("./ReplayProtection.js");
|
|
@@ -56,28 +57,35 @@ class BitGoPsbt {
|
|
|
56
57
|
const wasm = wasm_utxo_js_1.BitGoPsbt.from_bytes(bytes, network);
|
|
57
58
|
return new BitGoPsbt(wasm);
|
|
58
59
|
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
* @param script - Output script of the UTXO being spent
|
|
67
|
-
* @returns The index of the newly added input
|
|
68
|
-
*
|
|
69
|
-
* @example
|
|
70
|
-
* ```typescript
|
|
71
|
-
* const inputIndex = psbt.addInput({
|
|
72
|
-
* txid: "abc123...",
|
|
73
|
-
* vout: 0,
|
|
74
|
-
* value: 100000n,
|
|
75
|
-
* }, outputScript);
|
|
76
|
-
* ```
|
|
77
|
-
*/
|
|
60
|
+
addInputAtIndex(index, txidOrOptions, voutOrScript, value, script, sequence) {
|
|
61
|
+
if (typeof txidOrOptions === "string") {
|
|
62
|
+
return this._wasm.add_input_at_index(index, txidOrOptions, voutOrScript, value, script, sequence);
|
|
63
|
+
}
|
|
64
|
+
const options = txidOrOptions;
|
|
65
|
+
return this._wasm.add_input_at_index(index, options.txid, options.vout, options.value, voutOrScript, options.sequence, options.prevTx);
|
|
66
|
+
}
|
|
78
67
|
addInput(options, script) {
|
|
79
68
|
return this._wasm.add_input(options.txid, options.vout, options.value, script, options.sequence, options.prevTx);
|
|
80
69
|
}
|
|
70
|
+
addOutputAtIndex(index, scriptOrOptions, value) {
|
|
71
|
+
if (scriptOrOptions instanceof Uint8Array || typeof scriptOrOptions === "string") {
|
|
72
|
+
if (value === undefined) {
|
|
73
|
+
throw new Error("Value is required when passing a script or address");
|
|
74
|
+
}
|
|
75
|
+
if (scriptOrOptions instanceof Uint8Array) {
|
|
76
|
+
return this._wasm.add_output_at_index(index, scriptOrOptions, value);
|
|
77
|
+
}
|
|
78
|
+
return this._wasm.add_output_with_address_at_index(index, scriptOrOptions, value);
|
|
79
|
+
}
|
|
80
|
+
const options = scriptOrOptions;
|
|
81
|
+
if ("script" in options) {
|
|
82
|
+
return this._wasm.add_output_at_index(index, options.script, options.value);
|
|
83
|
+
}
|
|
84
|
+
if ("address" in options) {
|
|
85
|
+
return this._wasm.add_output_with_address_at_index(index, options.address, options.value);
|
|
86
|
+
}
|
|
87
|
+
throw new Error("Invalid output options");
|
|
88
|
+
}
|
|
81
89
|
addOutput(scriptOrOptions, value) {
|
|
82
90
|
if (scriptOrOptions instanceof Uint8Array || typeof scriptOrOptions === "string") {
|
|
83
91
|
if (value === undefined) {
|
|
@@ -136,6 +144,10 @@ class BitGoPsbt {
|
|
|
136
144
|
* );
|
|
137
145
|
* ```
|
|
138
146
|
*/
|
|
147
|
+
addWalletInputAtIndex(index, inputOptions, walletKeys, walletOptions) {
|
|
148
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
149
|
+
return this._wasm.add_wallet_input_at_index(index, inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
|
|
150
|
+
}
|
|
139
151
|
addWalletInput(inputOptions, walletKeys, walletOptions) {
|
|
140
152
|
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
141
153
|
return this._wasm.add_wallet_input(inputOptions.txid, inputOptions.vout, inputOptions.value, keys.wasm, walletOptions.scriptId.chain, walletOptions.scriptId.index, walletOptions.signPath?.signer, walletOptions.signPath?.cosigner, inputOptions.sequence, inputOptions.prevTx);
|
|
@@ -170,6 +182,10 @@ class BitGoPsbt {
|
|
|
170
182
|
* });
|
|
171
183
|
* ```
|
|
172
184
|
*/
|
|
185
|
+
addWalletOutputAtIndex(index, walletKeys, options) {
|
|
186
|
+
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
187
|
+
return this._wasm.add_wallet_output_at_index(index, options.chain, options.index, options.value, keys.wasm);
|
|
188
|
+
}
|
|
173
189
|
addWalletOutput(walletKeys, options) {
|
|
174
190
|
const keys = RootWalletKeys_js_1.RootWalletKeys.from(walletKeys);
|
|
175
191
|
return this._wasm.add_wallet_output(options.chain, options.index, options.value, keys.wasm);
|
|
@@ -193,29 +209,35 @@ class BitGoPsbt {
|
|
|
193
209
|
* );
|
|
194
210
|
* ```
|
|
195
211
|
*/
|
|
212
|
+
addReplayProtectionInputAtIndex(index, inputOptions, key) {
|
|
213
|
+
const ecpair = ecpair_js_1.ECPair.from(key);
|
|
214
|
+
return this._wasm.add_replay_protection_input_at_index(index, ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
|
|
215
|
+
}
|
|
196
216
|
addReplayProtectionInput(inputOptions, key) {
|
|
197
217
|
const ecpair = ecpair_js_1.ECPair.from(key);
|
|
198
218
|
return this._wasm.add_replay_protection_input(ecpair.wasm, inputOptions.txid, inputOptions.vout, inputOptions.value, inputOptions.sequence, inputOptions.prevTx);
|
|
199
219
|
}
|
|
220
|
+
removeInput(index) {
|
|
221
|
+
this._wasm.remove_input(index);
|
|
222
|
+
}
|
|
223
|
+
removeOutput(index) {
|
|
224
|
+
this._wasm.remove_output(index);
|
|
225
|
+
}
|
|
200
226
|
/**
|
|
201
227
|
* Get the unsigned transaction ID
|
|
202
228
|
* @returns The unsigned transaction ID
|
|
203
229
|
*/
|
|
204
|
-
|
|
230
|
+
unsignedTxId() {
|
|
205
231
|
return this._wasm.unsigned_txid();
|
|
206
232
|
}
|
|
207
233
|
/**
|
|
208
234
|
* Get the transaction version
|
|
209
235
|
* @returns The transaction version number
|
|
210
236
|
*/
|
|
211
|
-
|
|
237
|
+
version() {
|
|
212
238
|
return this._wasm.version();
|
|
213
239
|
}
|
|
214
|
-
|
|
215
|
-
* Get the transaction lock time
|
|
216
|
-
* @returns The transaction lock time
|
|
217
|
-
*/
|
|
218
|
-
get lockTime() {
|
|
240
|
+
lockTime() {
|
|
219
241
|
return this._wasm.lock_time();
|
|
220
242
|
}
|
|
221
243
|
/**
|
|
@@ -541,14 +563,10 @@ class BitGoPsbt {
|
|
|
541
563
|
* Get the number of inputs in the PSBT
|
|
542
564
|
* @returns The number of inputs
|
|
543
565
|
*/
|
|
544
|
-
|
|
566
|
+
inputCount() {
|
|
545
567
|
return this._wasm.input_count();
|
|
546
568
|
}
|
|
547
|
-
|
|
548
|
-
* Get the number of outputs in the PSBT
|
|
549
|
-
* @returns The number of outputs
|
|
550
|
-
*/
|
|
551
|
-
get outputCount() {
|
|
569
|
+
outputCount() {
|
|
552
570
|
return this._wasm.output_count();
|
|
553
571
|
}
|
|
554
572
|
/**
|
|
@@ -593,5 +611,26 @@ class BitGoPsbt {
|
|
|
593
611
|
getOutputsWithAddress() {
|
|
594
612
|
return this._wasm.get_outputs_with_address();
|
|
595
613
|
}
|
|
614
|
+
/**
|
|
615
|
+
* Returns the unordered global xpubs from this PSBT as BIP32 instances.
|
|
616
|
+
*/
|
|
617
|
+
getGlobalXpubs() {
|
|
618
|
+
const result = this._wasm.get_global_xpubs();
|
|
619
|
+
return result.map((w) => bip32_js_1.BIP32.fromWasm(w));
|
|
620
|
+
}
|
|
596
621
|
}
|
|
597
622
|
exports.BitGoPsbt = BitGoPsbt;
|
|
623
|
+
/**
|
|
624
|
+
* Extract sorted wallet keys from a PSBT's global xpub fields.
|
|
625
|
+
*
|
|
626
|
+
* This should only be used in exceptional circumstances where the real wallet
|
|
627
|
+
* keys are not available — for example, legacy cold wallets where the PSBT
|
|
628
|
+
* was built with derived keys (from coldDerivationSeed) but the caller only
|
|
629
|
+
* has root xpubs. Prefer passing wallet keys explicitly wherever possible.
|
|
630
|
+
*
|
|
631
|
+
* @returns Sorted [user, backup, bitgo] RootWalletKeys
|
|
632
|
+
*/
|
|
633
|
+
function getWalletKeysFromPsbt(psbt, xpubs) {
|
|
634
|
+
const wasmKeys = wasm_utxo_js_1.FixedScriptWalletNamespace.to_wallet_keys(psbt.wasm, xpubs[0].wasm, xpubs[1].wasm, xpubs[2].wasm);
|
|
635
|
+
return RootWalletKeys_js_1.RootWalletKeys.fromWasm(wasmKeys);
|
|
636
|
+
}
|
|
@@ -23,6 +23,11 @@ Triple<string>
|
|
|
23
23
|
export declare class RootWalletKeys {
|
|
24
24
|
private _wasm;
|
|
25
25
|
private constructor();
|
|
26
|
+
/**
|
|
27
|
+
* Create a RootWalletKeys instance from a WasmRootWalletKeys instance (internal use)
|
|
28
|
+
* @internal
|
|
29
|
+
*/
|
|
30
|
+
static fromWasm(wasm: WasmRootWalletKeys): RootWalletKeys;
|
|
26
31
|
/**
|
|
27
32
|
* Create a RootWalletKeys from various input formats
|
|
28
33
|
* @param keys - Can be a triple of xpub strings, an IWalletKeys object, or another RootWalletKeys instance
|
|
@@ -35,6 +35,13 @@ class RootWalletKeys {
|
|
|
35
35
|
constructor(_wasm) {
|
|
36
36
|
this._wasm = _wasm;
|
|
37
37
|
}
|
|
38
|
+
/**
|
|
39
|
+
* Create a RootWalletKeys instance from a WasmRootWalletKeys instance (internal use)
|
|
40
|
+
* @internal
|
|
41
|
+
*/
|
|
42
|
+
static fromWasm(wasm) {
|
|
43
|
+
return new RootWalletKeys(wasm);
|
|
44
|
+
}
|
|
38
45
|
/**
|
|
39
46
|
* Create a RootWalletKeys from various input formats
|
|
40
47
|
* @param keys - Can be a triple of xpub strings, an IWalletKeys object, or another RootWalletKeys instance
|
|
@@ -5,7 +5,7 @@ export { outputScript, address } from "./address.js";
|
|
|
5
5
|
export { Dimensions } from "./Dimensions.js";
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, type OutputScriptType, type InputScriptType, type ScriptType, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode, type Scope } from "./chains.js";
|
|
8
|
-
export { BitGoPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, } from "./BitGoPsbt.js";
|
|
8
|
+
export { BitGoPsbt, getWalletKeysFromPsbt, type NetworkName, type ScriptId, type ParsedInput, type ParsedOutput, type ParsedTransaction, type SignPath, type CreateEmptyOptions, type AddInputOptions, type AddOutputOptions, type AddWalletInputOptions, type AddWalletOutputOptions, type ParseTransactionOptions, type ParseOutputsOptions, } from "./BitGoPsbt.js";
|
|
9
9
|
export { ZcashBitGoPsbt, type ZcashNetworkName, type CreateEmptyZcashOptions, } from "./ZcashBitGoPsbt.js";
|
|
10
10
|
export type { PsbtBip32Derivation, PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress, PsbtWitnessUtxo, } from "../wasm/wasm_utxo.js";
|
|
11
11
|
import type { ScriptType } from "./scriptType.js";
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ZcashBitGoPsbt = exports.BitGoPsbt = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
3
|
+
exports.ZcashBitGoPsbt = exports.getWalletKeysFromPsbt = exports.BitGoPsbt = exports.assertChainCode = exports.chainCodes = exports.ChainCode = exports.inputScriptTypes = exports.outputScriptTypes = exports.Dimensions = exports.address = exports.outputScript = exports.ReplayProtection = exports.RootWalletKeys = void 0;
|
|
4
4
|
exports.supportsScriptType = supportsScriptType;
|
|
5
5
|
exports.createOpReturnScript = createOpReturnScript;
|
|
6
6
|
exports.p2shP2pkOutputScript = p2shP2pkOutputScript;
|
|
@@ -24,6 +24,7 @@ Object.defineProperty(exports, "assertChainCode", { enumerable: true, get: funct
|
|
|
24
24
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
25
25
|
var BitGoPsbt_js_1 = require("./BitGoPsbt.js");
|
|
26
26
|
Object.defineProperty(exports, "BitGoPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.BitGoPsbt; } });
|
|
27
|
+
Object.defineProperty(exports, "getWalletKeysFromPsbt", { enumerable: true, get: function () { return BitGoPsbt_js_1.getWalletKeysFromPsbt; } });
|
|
27
28
|
// Zcash-specific PSBT subclass
|
|
28
29
|
var ZcashBitGoPsbt_js_1 = require("./ZcashBitGoPsbt.js");
|
|
29
30
|
Object.defineProperty(exports, "ZcashBitGoPsbt", { enumerable: true, get: function () { return ZcashBitGoPsbt_js_1.ZcashBitGoPsbt; } });
|
package/dist/cjs/js/index.d.ts
CHANGED
|
@@ -74,6 +74,7 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
74
74
|
getInputs(): PsbtInputData[];
|
|
75
75
|
getOutputs(): PsbtOutputData[];
|
|
76
76
|
getOutputsWithAddress(coin: import("./coinName.js").CoinName): PsbtOutputDataWithAddress[];
|
|
77
|
+
getGlobalXpubs(): WasmBIP32[];
|
|
77
78
|
getPartialSignatures(inputIndex: number): Array<{
|
|
78
79
|
pubkey: Uint8Array;
|
|
79
80
|
signature: Uint8Array;
|
|
@@ -82,6 +83,10 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
82
83
|
validateSignatureAtInput(inputIndex: number, pubkey: Uint8Array): boolean;
|
|
83
84
|
verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
|
|
84
85
|
extractTransaction(): WasmTransaction;
|
|
86
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
87
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
88
|
+
removeInput(index: number): void;
|
|
89
|
+
removeOutput(index: number): void;
|
|
85
90
|
unsignedTxId(): string;
|
|
86
91
|
lockTime(): number;
|
|
87
92
|
version(): number;
|
|
@@ -91,4 +96,4 @@ export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
|
91
96
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
92
97
|
export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
|
|
93
98
|
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
94
|
-
export { hasPsbtMagic, type
|
|
99
|
+
export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
|
package/dist/cjs/js/psbt.d.ts
CHANGED
|
@@ -1,13 +1,22 @@
|
|
|
1
1
|
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
2
|
+
import type { BIP32 } from "./bip32.js";
|
|
3
|
+
/** Common interface for PSBT types */
|
|
4
|
+
export interface IPsbt {
|
|
5
|
+
inputCount(): number;
|
|
6
|
+
outputCount(): number;
|
|
6
7
|
getInputs(): PsbtInputData[];
|
|
7
8
|
getOutputs(): PsbtOutputData[];
|
|
9
|
+
getGlobalXpubs(): BIP32[];
|
|
10
|
+
version(): number;
|
|
11
|
+
lockTime(): number;
|
|
12
|
+
unsignedTxId(): string;
|
|
13
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
14
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
15
|
+
removeInput(index: number): void;
|
|
16
|
+
removeOutput(index: number): void;
|
|
8
17
|
}
|
|
9
|
-
/** Extended
|
|
10
|
-
export interface
|
|
18
|
+
/** Extended PSBT with address resolution (no coin parameter needed) */
|
|
19
|
+
export interface IPsbtWithAddress extends IPsbt {
|
|
11
20
|
getOutputsWithAddress(): PsbtOutputDataWithAddress[];
|
|
12
21
|
}
|
|
13
22
|
/**
|
|
@@ -30,13 +30,9 @@ export declare class Transaction implements ITransaction {
|
|
|
30
30
|
* @param sequence - Optional sequence number (default: 0xFFFFFFFF)
|
|
31
31
|
* @returns The index of the newly added input
|
|
32
32
|
*/
|
|
33
|
+
addInputAtIndex(index: number, txid: string, vout: number, sequence?: number): number;
|
|
33
34
|
addInput(txid: string, vout: number, sequence?: number): number;
|
|
34
|
-
|
|
35
|
-
* Add an output to the transaction
|
|
36
|
-
* @param script - Output script (scriptPubKey)
|
|
37
|
-
* @param value - Value in satoshis
|
|
38
|
-
* @returns The index of the newly added output
|
|
39
|
-
*/
|
|
35
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
40
36
|
addOutput(script: Uint8Array, value: bigint): number;
|
|
41
37
|
toBytes(): Uint8Array;
|
|
42
38
|
/**
|
|
@@ -34,15 +34,15 @@ class Transaction {
|
|
|
34
34
|
* @param sequence - Optional sequence number (default: 0xFFFFFFFF)
|
|
35
35
|
* @returns The index of the newly added input
|
|
36
36
|
*/
|
|
37
|
+
addInputAtIndex(index, txid, vout, sequence) {
|
|
38
|
+
return this._wasm.add_input_at_index(index, txid, vout, sequence);
|
|
39
|
+
}
|
|
37
40
|
addInput(txid, vout, sequence) {
|
|
38
41
|
return this._wasm.add_input(txid, vout, sequence);
|
|
39
42
|
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
* @param value - Value in satoshis
|
|
44
|
-
* @returns The index of the newly added output
|
|
45
|
-
*/
|
|
43
|
+
addOutputAtIndex(index, script, value) {
|
|
44
|
+
return this._wasm.add_output_at_index(index, script, value);
|
|
45
|
+
}
|
|
46
46
|
addOutput(script, value) {
|
|
47
47
|
return this._wasm.add_output(script, value);
|
|
48
48
|
}
|