@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
|
@@ -1,36 +1,19 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
-
export const
|
|
5
|
-
export const
|
|
6
|
-
export const
|
|
7
|
-
export const
|
|
8
|
-
export const
|
|
9
|
-
export const
|
|
10
|
-
export const
|
|
11
|
-
export const
|
|
12
|
-
export const
|
|
13
|
-
export const
|
|
14
|
-
export const
|
|
15
|
-
export const
|
|
16
|
-
export const
|
|
17
|
-
export const wasmtransaction_get_txid: (a: number, b: number) => void;
|
|
18
|
-
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
19
|
-
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
20
|
-
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
21
|
-
export const wasmzcashtransaction_get_txid: (a: number, b: number) => void;
|
|
22
|
-
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
23
|
-
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
24
|
-
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
25
|
-
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
26
|
-
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
27
|
-
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
28
|
-
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
29
|
-
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
30
|
-
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
31
|
-
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
32
|
-
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
33
|
-
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
4
|
+
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
7
|
+
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
8
|
+
export const inscriptionsnamespace_sign_reveal_transaction: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: bigint) => void;
|
|
9
|
+
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
|
+
export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
|
|
11
|
+
export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
|
|
12
|
+
export const wasmrootwalletkeys_backup_key: (a: number) => number;
|
|
13
|
+
export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
14
|
+
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
15
|
+
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
16
|
+
export const wasmrootwalletkeys_with_derivation_prefixes: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
|
|
34
17
|
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
35
18
|
export const __wbg_messagenamespace_free: (a: number, b: number) => void;
|
|
36
19
|
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
@@ -59,50 +42,68 @@ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: num
|
|
|
59
42
|
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
60
43
|
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
61
44
|
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
62
|
-
export const
|
|
63
|
-
export const
|
|
64
|
-
export const
|
|
65
|
-
export const
|
|
45
|
+
export const wrappsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
|
|
46
|
+
export const wrappsbt_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: bigint, h: number, i: number, j: number) => void;
|
|
47
|
+
export const wrappsbt_add_output: (a: number, b: number, c: number, d: bigint) => number;
|
|
48
|
+
export const wrappsbt_add_output_at_index: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
|
|
66
49
|
export const wrappsbt_clone: (a: number) => number;
|
|
67
50
|
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
68
|
-
export const
|
|
69
|
-
export const
|
|
70
|
-
export const
|
|
71
|
-
export const
|
|
72
|
-
export const
|
|
73
|
-
export const
|
|
74
|
-
export const
|
|
75
|
-
export const
|
|
76
|
-
export const
|
|
77
|
-
export const
|
|
51
|
+
export const wrappsbt_extract_transaction: (a: number, b: number) => void;
|
|
52
|
+
export const wrappsbt_finalize_mut: (a: number, b: number) => void;
|
|
53
|
+
export const wrappsbt_get_global_xpubs: (a: number) => number;
|
|
54
|
+
export const wrappsbt_get_inputs: (a: number, b: number) => void;
|
|
55
|
+
export const wrappsbt_get_outputs: (a: number, b: number) => void;
|
|
56
|
+
export const wrappsbt_get_outputs_with_address: (a: number, b: number, c: number, d: number) => void;
|
|
57
|
+
export const wrappsbt_get_partial_signatures: (a: number, b: number, c: number) => void;
|
|
58
|
+
export const wrappsbt_get_unsigned_tx: (a: number, b: number) => void;
|
|
59
|
+
export const wrappsbt_has_partial_signatures: (a: number, b: number, c: number) => void;
|
|
60
|
+
export const wrappsbt_input_count: (a: number) => number;
|
|
61
|
+
export const wrappsbt_lock_time: (a: number) => number;
|
|
78
62
|
export const wrappsbt_new: (a: number, b: number) => number;
|
|
79
|
-
export const
|
|
80
|
-
export const
|
|
81
|
-
export const
|
|
63
|
+
export const wrappsbt_output_count: (a: number) => number;
|
|
64
|
+
export const wrappsbt_remove_input: (a: number, b: number, c: number) => void;
|
|
65
|
+
export const wrappsbt_remove_output: (a: number, b: number, c: number) => void;
|
|
82
66
|
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
83
|
-
export const
|
|
84
|
-
export const
|
|
85
|
-
export const
|
|
86
|
-
export const
|
|
87
|
-
export const
|
|
88
|
-
export const
|
|
89
|
-
export const
|
|
90
|
-
export const
|
|
91
|
-
export const
|
|
67
|
+
export const wrappsbt_sign_all: (a: number, b: number, c: number) => void;
|
|
68
|
+
export const wrappsbt_sign_all_with_ecpair: (a: number, b: number, c: number) => void;
|
|
69
|
+
export const wrappsbt_sign_with_prv: (a: number, b: number, c: number, d: number) => void;
|
|
70
|
+
export const wrappsbt_sign_with_xprv: (a: number, b: number, c: number, d: number) => void;
|
|
71
|
+
export const wrappsbt_unsigned_tx_id: (a: number, b: number) => void;
|
|
72
|
+
export const wrappsbt_update_input_with_descriptor: (a: number, b: number, c: number, d: number) => void;
|
|
73
|
+
export const wrappsbt_update_output_with_descriptor: (a: number, b: number, c: number, d: number) => void;
|
|
74
|
+
export const wrappsbt_validate_signature_at_input: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
75
|
+
export const wrappsbt_verify_signature_with_key: (a: number, b: number, c: number, d: number) => void;
|
|
92
76
|
export const wrappsbt_version: (a: number) => number;
|
|
93
|
-
export const
|
|
94
|
-
export const
|
|
95
|
-
export const
|
|
96
|
-
export const
|
|
97
|
-
export const
|
|
98
|
-
export const
|
|
99
|
-
export const
|
|
100
|
-
export const
|
|
101
|
-
export const
|
|
102
|
-
export const
|
|
103
|
-
export const
|
|
104
|
-
export const
|
|
105
|
-
export const
|
|
77
|
+
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
78
|
+
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
79
|
+
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
80
|
+
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
81
|
+
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
82
|
+
export const wasmdashtransaction_get_txid: (a: number, b: number) => void;
|
|
83
|
+
export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
|
|
84
|
+
export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
85
|
+
export const wasmtransaction_add_input_at_index: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
86
|
+
export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
|
|
87
|
+
export const wasmtransaction_add_output_at_index: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
|
|
88
|
+
export const wasmtransaction_create: () => number;
|
|
89
|
+
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
90
|
+
export const wasmtransaction_get_txid: (a: number, b: number) => void;
|
|
91
|
+
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
92
|
+
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
93
|
+
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
94
|
+
export const wasmzcashtransaction_get_txid: (a: number, b: number) => void;
|
|
95
|
+
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
96
|
+
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
97
|
+
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
98
|
+
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
99
|
+
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
100
|
+
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
101
|
+
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
102
|
+
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
103
|
+
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
104
|
+
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
105
|
+
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
106
|
+
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
106
107
|
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
107
108
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
108
109
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
@@ -139,6 +140,7 @@ export const bitgopsbt_extract_zcash_transaction: (a: number, b: number) => void
|
|
|
139
140
|
export const bitgopsbt_finalize_all_inputs: (a: number, b: number) => void;
|
|
140
141
|
export const bitgopsbt_from_bytes: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
141
142
|
export const bitgopsbt_generate_musig2_nonces: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
143
|
+
export const bitgopsbt_get_global_xpubs: (a: number) => number;
|
|
142
144
|
export const bitgopsbt_get_inputs: (a: number, b: number) => void;
|
|
143
145
|
export const bitgopsbt_get_network_type: (a: number, b: number) => void;
|
|
144
146
|
export const bitgopsbt_get_outputs: (a: number, b: number) => void;
|
|
@@ -175,7 +177,7 @@ export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c:
|
|
|
175
177
|
export const fixedscriptwalletnamespace_output_script_with_network_str: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
176
178
|
export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
|
|
177
179
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
178
|
-
export const
|
|
180
|
+
export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
179
181
|
export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
180
182
|
export const wasmbip32_chain_code: (a: number) => number;
|
|
181
183
|
export const wasmbip32_depth: (a: number) => number;
|
|
@@ -215,6 +217,7 @@ export const wasmdimensions_has_segwit: (a: number) => number;
|
|
|
215
217
|
export const wasmdimensions_plus: (a: number, b: number) => number;
|
|
216
218
|
export const wasmdimensions_times: (a: number, b: number) => number;
|
|
217
219
|
export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
|
|
220
|
+
export const isInspectEnabled: () => number;
|
|
218
221
|
export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
219
222
|
export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
220
223
|
export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
|
|
@@ -4,3 +4,6 @@ export declare function getMainnet(name: CoinName): CoinName;
|
|
|
4
4
|
export declare function isMainnet(name: CoinName): boolean;
|
|
5
5
|
export declare function isTestnet(name: CoinName): boolean;
|
|
6
6
|
export declare function isCoinName(v: string): v is CoinName;
|
|
7
|
+
import type { UtxolibName } from "./utxolibCompat.js";
|
|
8
|
+
/** Convert a CoinName or UtxolibName to CoinName */
|
|
9
|
+
export declare function toCoinName(name: CoinName | UtxolibName): CoinName;
|
package/dist/esm/js/coinName.js
CHANGED
|
@@ -58,3 +58,51 @@ export function isTestnet(name) {
|
|
|
58
58
|
export function isCoinName(v) {
|
|
59
59
|
return coinNames.includes(v);
|
|
60
60
|
}
|
|
61
|
+
/** Convert a CoinName or UtxolibName to CoinName */
|
|
62
|
+
export function toCoinName(name) {
|
|
63
|
+
switch (name) {
|
|
64
|
+
case "bitcoin":
|
|
65
|
+
return "btc";
|
|
66
|
+
case "testnet":
|
|
67
|
+
return "tbtc";
|
|
68
|
+
case "bitcoinTestnet4":
|
|
69
|
+
return "tbtc4";
|
|
70
|
+
case "bitcoinPublicSignet":
|
|
71
|
+
return "tbtcsig";
|
|
72
|
+
case "bitcoinBitGoSignet":
|
|
73
|
+
return "tbtcbgsig";
|
|
74
|
+
case "bitcoincash":
|
|
75
|
+
return "bch";
|
|
76
|
+
case "bitcoincashTestnet":
|
|
77
|
+
return "tbch";
|
|
78
|
+
case "ecash":
|
|
79
|
+
return "bcha";
|
|
80
|
+
case "ecashTest":
|
|
81
|
+
return "tbcha";
|
|
82
|
+
case "bitcoingold":
|
|
83
|
+
return "btg";
|
|
84
|
+
case "bitcoingoldTestnet":
|
|
85
|
+
return "tbtg";
|
|
86
|
+
case "bitcoinsv":
|
|
87
|
+
return "bsv";
|
|
88
|
+
case "bitcoinsvTestnet":
|
|
89
|
+
return "tbsv";
|
|
90
|
+
case "dashTest":
|
|
91
|
+
return "tdash";
|
|
92
|
+
case "dogecoin":
|
|
93
|
+
return "doge";
|
|
94
|
+
case "dogecoinTest":
|
|
95
|
+
return "tdoge";
|
|
96
|
+
case "litecoin":
|
|
97
|
+
return "ltc";
|
|
98
|
+
case "litecoinTest":
|
|
99
|
+
return "tltc";
|
|
100
|
+
case "zcash":
|
|
101
|
+
return "zec";
|
|
102
|
+
case "zcashTest":
|
|
103
|
+
return "tzec";
|
|
104
|
+
default:
|
|
105
|
+
// CoinName values pass through (including "dash" which is both CoinName and UtxolibName)
|
|
106
|
+
return name;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { WrapPsbt as WasmPsbt, type WasmBIP32, type WasmECPair, type WrapDescriptor, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import type { IPsbt } from "../psbt.js";
|
|
3
|
+
import type { CoinName } from "../coinName.js";
|
|
4
|
+
import type { BIP32 } from "../bip32.js";
|
|
5
|
+
import { Transaction } from "../transaction.js";
|
|
6
|
+
export type SignPsbtResult = {
|
|
7
|
+
[inputIndex: number]: [pubkey: string][];
|
|
8
|
+
};
|
|
9
|
+
export declare class Psbt implements IPsbt {
|
|
10
|
+
private _wasm;
|
|
11
|
+
constructor(versionOrWasm?: number | WasmPsbt, lockTime?: number);
|
|
12
|
+
/** @internal Access the underlying WASM instance */
|
|
13
|
+
get wasm(): WasmPsbt;
|
|
14
|
+
static create(version?: number, lockTime?: number): Psbt;
|
|
15
|
+
static deserialize(bytes: Uint8Array): Psbt;
|
|
16
|
+
serialize(): Uint8Array;
|
|
17
|
+
clone(): Psbt;
|
|
18
|
+
inputCount(): number;
|
|
19
|
+
outputCount(): number;
|
|
20
|
+
version(): number;
|
|
21
|
+
lockTime(): number;
|
|
22
|
+
unsignedTxId(): string;
|
|
23
|
+
getInputs(): PsbtInputData[];
|
|
24
|
+
getOutputs(): PsbtOutputData[];
|
|
25
|
+
getGlobalXpubs(): BIP32[];
|
|
26
|
+
getOutputsWithAddress(coin: CoinName): PsbtOutputDataWithAddress[];
|
|
27
|
+
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
28
|
+
addInput(txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
29
|
+
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
30
|
+
addOutput(script: Uint8Array, value: bigint): number;
|
|
31
|
+
removeInput(index: number): void;
|
|
32
|
+
removeOutput(index: number): void;
|
|
33
|
+
updateInputWithDescriptor(inputIndex: number, descriptor: WrapDescriptor): void;
|
|
34
|
+
updateOutputWithDescriptor(outputIndex: number, descriptor: WrapDescriptor): void;
|
|
35
|
+
signWithXprv(xprv: string): SignPsbtResult;
|
|
36
|
+
signWithPrv(prv: Uint8Array): SignPsbtResult;
|
|
37
|
+
signAll(key: WasmBIP32): SignPsbtResult;
|
|
38
|
+
signAllWithEcpair(key: WasmECPair): SignPsbtResult;
|
|
39
|
+
getPartialSignatures(inputIndex: number): Array<{
|
|
40
|
+
pubkey: Uint8Array;
|
|
41
|
+
signature: Uint8Array;
|
|
42
|
+
}>;
|
|
43
|
+
hasPartialSignatures(inputIndex: number): boolean;
|
|
44
|
+
validateSignatureAtInput(inputIndex: number, pubkey: Uint8Array): boolean;
|
|
45
|
+
verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
|
|
46
|
+
getUnsignedTx(): Uint8Array;
|
|
47
|
+
finalize(): void;
|
|
48
|
+
extractTransaction(): Transaction;
|
|
49
|
+
}
|
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
import { WrapPsbt as WasmPsbt, } from "../wasm/wasm_utxo.js";
|
|
2
|
+
import { Transaction } from "../transaction.js";
|
|
3
|
+
export class Psbt {
|
|
4
|
+
_wasm;
|
|
5
|
+
constructor(versionOrWasm, lockTime) {
|
|
6
|
+
if (versionOrWasm instanceof WasmPsbt) {
|
|
7
|
+
this._wasm = versionOrWasm;
|
|
8
|
+
}
|
|
9
|
+
else {
|
|
10
|
+
this._wasm = new WasmPsbt(versionOrWasm, lockTime);
|
|
11
|
+
}
|
|
12
|
+
}
|
|
13
|
+
/** @internal Access the underlying WASM instance */
|
|
14
|
+
get wasm() {
|
|
15
|
+
return this._wasm;
|
|
16
|
+
}
|
|
17
|
+
// -- Static / Factory --
|
|
18
|
+
static create(version, lockTime) {
|
|
19
|
+
return new Psbt(new WasmPsbt(version, lockTime));
|
|
20
|
+
}
|
|
21
|
+
static deserialize(bytes) {
|
|
22
|
+
return new Psbt(WasmPsbt.deserialize(bytes));
|
|
23
|
+
}
|
|
24
|
+
// -- Serialization --
|
|
25
|
+
serialize() {
|
|
26
|
+
return this._wasm.serialize();
|
|
27
|
+
}
|
|
28
|
+
clone() {
|
|
29
|
+
return new Psbt(this._wasm.clone());
|
|
30
|
+
}
|
|
31
|
+
// -- IPsbt: introspection --
|
|
32
|
+
inputCount() {
|
|
33
|
+
return this._wasm.input_count();
|
|
34
|
+
}
|
|
35
|
+
outputCount() {
|
|
36
|
+
return this._wasm.output_count();
|
|
37
|
+
}
|
|
38
|
+
version() {
|
|
39
|
+
return this._wasm.version();
|
|
40
|
+
}
|
|
41
|
+
lockTime() {
|
|
42
|
+
return this._wasm.lock_time();
|
|
43
|
+
}
|
|
44
|
+
unsignedTxId() {
|
|
45
|
+
return this._wasm.unsigned_tx_id();
|
|
46
|
+
}
|
|
47
|
+
getInputs() {
|
|
48
|
+
return this._wasm.get_inputs();
|
|
49
|
+
}
|
|
50
|
+
getOutputs() {
|
|
51
|
+
return this._wasm.get_outputs();
|
|
52
|
+
}
|
|
53
|
+
getGlobalXpubs() {
|
|
54
|
+
return this._wasm.get_global_xpubs();
|
|
55
|
+
}
|
|
56
|
+
getOutputsWithAddress(coin) {
|
|
57
|
+
return this._wasm.get_outputs_with_address(coin);
|
|
58
|
+
}
|
|
59
|
+
// -- IPsbt: mutation --
|
|
60
|
+
addInputAtIndex(index, txid, vout, value, script, sequence) {
|
|
61
|
+
return this._wasm.add_input_at_index(index, txid, vout, value, script, sequence);
|
|
62
|
+
}
|
|
63
|
+
addInput(txid, vout, value, script, sequence) {
|
|
64
|
+
return this._wasm.add_input(txid, vout, value, script, sequence);
|
|
65
|
+
}
|
|
66
|
+
addOutputAtIndex(index, script, value) {
|
|
67
|
+
return this._wasm.add_output_at_index(index, script, value);
|
|
68
|
+
}
|
|
69
|
+
addOutput(script, value) {
|
|
70
|
+
return this._wasm.add_output(script, value);
|
|
71
|
+
}
|
|
72
|
+
removeInput(index) {
|
|
73
|
+
this._wasm.remove_input(index);
|
|
74
|
+
}
|
|
75
|
+
removeOutput(index) {
|
|
76
|
+
this._wasm.remove_output(index);
|
|
77
|
+
}
|
|
78
|
+
// -- Descriptor updates --
|
|
79
|
+
updateInputWithDescriptor(inputIndex, descriptor) {
|
|
80
|
+
this._wasm.update_input_with_descriptor(inputIndex, descriptor);
|
|
81
|
+
}
|
|
82
|
+
updateOutputWithDescriptor(outputIndex, descriptor) {
|
|
83
|
+
this._wasm.update_output_with_descriptor(outputIndex, descriptor);
|
|
84
|
+
}
|
|
85
|
+
// -- Signing --
|
|
86
|
+
signWithXprv(xprv) {
|
|
87
|
+
return this._wasm.sign_with_xprv(xprv);
|
|
88
|
+
}
|
|
89
|
+
signWithPrv(prv) {
|
|
90
|
+
return this._wasm.sign_with_prv(prv);
|
|
91
|
+
}
|
|
92
|
+
signAll(key) {
|
|
93
|
+
return this._wasm.sign_all(key);
|
|
94
|
+
}
|
|
95
|
+
signAllWithEcpair(key) {
|
|
96
|
+
return this._wasm.sign_all_with_ecpair(key);
|
|
97
|
+
}
|
|
98
|
+
// -- Signature introspection --
|
|
99
|
+
getPartialSignatures(inputIndex) {
|
|
100
|
+
return this._wasm.get_partial_signatures(inputIndex);
|
|
101
|
+
}
|
|
102
|
+
hasPartialSignatures(inputIndex) {
|
|
103
|
+
return this._wasm.has_partial_signatures(inputIndex);
|
|
104
|
+
}
|
|
105
|
+
// -- Validation --
|
|
106
|
+
validateSignatureAtInput(inputIndex, pubkey) {
|
|
107
|
+
return this._wasm.validate_signature_at_input(inputIndex, pubkey);
|
|
108
|
+
}
|
|
109
|
+
verifySignatureWithKey(inputIndex, key) {
|
|
110
|
+
return this._wasm.verify_signature_with_key(inputIndex, key);
|
|
111
|
+
}
|
|
112
|
+
// -- Transaction extraction --
|
|
113
|
+
getUnsignedTx() {
|
|
114
|
+
return this._wasm.get_unsigned_tx();
|
|
115
|
+
}
|
|
116
|
+
finalize() {
|
|
117
|
+
this._wasm.finalize_mut();
|
|
118
|
+
}
|
|
119
|
+
extractTransaction() {
|
|
120
|
+
return Transaction.fromWasm(this._wasm.extract_transaction());
|
|
121
|
+
}
|
|
122
|
+
}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { BitGoPsbt as WasmBitGoPsbt, type PsbtInputData, type PsbtOutputData, type PsbtOutputDataWithAddress } from "../wasm/wasm_utxo.js";
|
|
2
2
|
import type { IPsbtWithAddress } from "../psbt.js";
|
|
3
|
-
import { type WalletKeysArg } from "./RootWalletKeys.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";
|
|
@@ -595,4 +595,19 @@ export declare class BitGoPsbt implements IPsbtWithAddress {
|
|
|
595
595
|
* ```
|
|
596
596
|
*/
|
|
597
597
|
getOutputsWithAddress(): PsbtOutputDataWithAddress[];
|
|
598
|
+
/**
|
|
599
|
+
* Returns the unordered global xpubs from this PSBT as BIP32 instances.
|
|
600
|
+
*/
|
|
601
|
+
getGlobalXpubs(): BIP32[];
|
|
598
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,4 +1,4 @@
|
|
|
1
|
-
import { BitGoPsbt as WasmBitGoPsbt, } from "../wasm/wasm_utxo.js";
|
|
1
|
+
import { BitGoPsbt as WasmBitGoPsbt, FixedScriptWalletNamespace, } from "../wasm/wasm_utxo.js";
|
|
2
2
|
import { RootWalletKeys } from "./RootWalletKeys.js";
|
|
3
3
|
import { ReplayProtection } from "./ReplayProtection.js";
|
|
4
4
|
import { BIP32, isBIP32Arg } from "../bip32.js";
|
|
@@ -607,4 +607,25 @@ export class BitGoPsbt {
|
|
|
607
607
|
getOutputsWithAddress() {
|
|
608
608
|
return this._wasm.get_outputs_with_address();
|
|
609
609
|
}
|
|
610
|
+
/**
|
|
611
|
+
* Returns the unordered global xpubs from this PSBT as BIP32 instances.
|
|
612
|
+
*/
|
|
613
|
+
getGlobalXpubs() {
|
|
614
|
+
const result = this._wasm.get_global_xpubs();
|
|
615
|
+
return result.map((w) => BIP32.fromWasm(w));
|
|
616
|
+
}
|
|
617
|
+
}
|
|
618
|
+
/**
|
|
619
|
+
* Extract sorted wallet keys from a PSBT's global xpub fields.
|
|
620
|
+
*
|
|
621
|
+
* This should only be used in exceptional circumstances where the real wallet
|
|
622
|
+
* keys are not available — for example, legacy cold wallets where the PSBT
|
|
623
|
+
* was built with derived keys (from coldDerivationSeed) but the caller only
|
|
624
|
+
* has root xpubs. Prefer passing wallet keys explicitly wherever possible.
|
|
625
|
+
*
|
|
626
|
+
* @returns Sorted [user, backup, bitgo] RootWalletKeys
|
|
627
|
+
*/
|
|
628
|
+
export function getWalletKeysFromPsbt(psbt, xpubs) {
|
|
629
|
+
const wasmKeys = FixedScriptWalletNamespace.to_wallet_keys(psbt.wasm, xpubs[0].wasm, xpubs[1].wasm, xpubs[2].wasm);
|
|
630
|
+
return RootWalletKeys.fromWasm(wasmKeys);
|
|
610
631
|
}
|
|
@@ -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
|
|
@@ -32,6 +32,13 @@ export class RootWalletKeys {
|
|
|
32
32
|
constructor(_wasm) {
|
|
33
33
|
this._wasm = _wasm;
|
|
34
34
|
}
|
|
35
|
+
/**
|
|
36
|
+
* Create a RootWalletKeys instance from a WasmRootWalletKeys instance (internal use)
|
|
37
|
+
* @internal
|
|
38
|
+
*/
|
|
39
|
+
static fromWasm(wasm) {
|
|
40
|
+
return new RootWalletKeys(wasm);
|
|
41
|
+
}
|
|
35
42
|
/**
|
|
36
43
|
* Create a RootWalletKeys from various input formats
|
|
37
44
|
* @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";
|
|
@@ -6,7 +6,7 @@ export { Dimensions } from "./Dimensions.js";
|
|
|
6
6
|
export { outputScriptTypes, inputScriptTypes, } from "./scriptType.js";
|
|
7
7
|
export { ChainCode, chainCodes, assertChainCode } from "./chains.js";
|
|
8
8
|
// Bitcoin-like PSBT (for all non-Zcash networks)
|
|
9
|
-
export { BitGoPsbt, } from "./BitGoPsbt.js";
|
|
9
|
+
export { BitGoPsbt, getWalletKeysFromPsbt, } from "./BitGoPsbt.js";
|
|
10
10
|
// Zcash-specific PSBT subclass
|
|
11
11
|
export { ZcashBitGoPsbt, } from "./ZcashBitGoPsbt.js";
|
|
12
12
|
/**
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -17,9 +17,6 @@ export type { AddressFormat } from "./address.js";
|
|
|
17
17
|
export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.js";
|
|
18
18
|
export type DescriptorPkType = "derivable" | "definite" | "string";
|
|
19
19
|
export type ScriptContext = "tap" | "segwitv0" | "legacy";
|
|
20
|
-
export type SignPsbtResult = {
|
|
21
|
-
[inputIndex: number]: [pubkey: string][];
|
|
22
|
-
};
|
|
23
20
|
declare module "./wasm/wasm_utxo.js" {
|
|
24
21
|
interface WrapDescriptor {
|
|
25
22
|
/** These are not the same types of nodes as in the ast module */
|
|
@@ -64,35 +61,9 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
64
61
|
interface PsbtOutputDataWithAddress extends PsbtOutputData {
|
|
65
62
|
address: string;
|
|
66
63
|
}
|
|
67
|
-
interface WrapPsbt {
|
|
68
|
-
signWithXprv(this: WrapPsbt, xprv: string): SignPsbtResult;
|
|
69
|
-
signWithPrv(this: WrapPsbt, prv: Uint8Array): SignPsbtResult;
|
|
70
|
-
signAll(this: WrapPsbt, key: WasmBIP32): SignPsbtResult;
|
|
71
|
-
signAllWithEcpair(this: WrapPsbt, key: WasmECPair): SignPsbtResult;
|
|
72
|
-
inputCount(): number;
|
|
73
|
-
outputCount(): number;
|
|
74
|
-
getInputs(): PsbtInputData[];
|
|
75
|
-
getOutputs(): PsbtOutputData[];
|
|
76
|
-
getOutputsWithAddress(coin: import("./coinName.js").CoinName): PsbtOutputDataWithAddress[];
|
|
77
|
-
getPartialSignatures(inputIndex: number): Array<{
|
|
78
|
-
pubkey: Uint8Array;
|
|
79
|
-
signature: Uint8Array;
|
|
80
|
-
}>;
|
|
81
|
-
hasPartialSignatures(inputIndex: number): boolean;
|
|
82
|
-
validateSignatureAtInput(inputIndex: number, pubkey: Uint8Array): boolean;
|
|
83
|
-
verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
|
|
84
|
-
extractTransaction(): WasmTransaction;
|
|
85
|
-
addInputAtIndex(index: number, txid: string, vout: number, value: bigint, script: Uint8Array, sequence?: number): number;
|
|
86
|
-
addOutputAtIndex(index: number, script: Uint8Array, value: bigint): number;
|
|
87
|
-
removeInput(index: number): void;
|
|
88
|
-
removeOutput(index: number): void;
|
|
89
|
-
unsignedTxId(): string;
|
|
90
|
-
lockTime(): number;
|
|
91
|
-
version(): number;
|
|
92
|
-
}
|
|
93
64
|
}
|
|
94
65
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
95
66
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
96
|
-
export {
|
|
67
|
+
export { Psbt } from "./descriptorWallet/Psbt.js";
|
|
97
68
|
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
98
69
|
export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
|
package/dist/esm/js/index.js
CHANGED
|
@@ -21,6 +21,6 @@ export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
|
21
21
|
export { getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
22
22
|
export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
|
|
23
23
|
export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
|
|
24
|
-
export {
|
|
24
|
+
export { Psbt } from "./descriptorWallet/Psbt.js";
|
|
25
25
|
export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
|
|
26
26
|
export { hasPsbtMagic } from "./psbt.js";
|
package/dist/esm/js/psbt.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import type { PsbtInputData, PsbtOutputData, PsbtOutputDataWithAddress } from "./wasm/wasm_utxo.js";
|
|
2
|
+
import type { BIP32 } from "./bip32.js";
|
|
2
3
|
/** Common interface for PSBT types */
|
|
3
4
|
export interface IPsbt {
|
|
4
5
|
inputCount(): number;
|
|
5
6
|
outputCount(): number;
|
|
6
7
|
getInputs(): PsbtInputData[];
|
|
7
8
|
getOutputs(): PsbtOutputData[];
|
|
9
|
+
getGlobalXpubs(): BIP32[];
|
|
8
10
|
version(): number;
|
|
9
11
|
lockTime(): number;
|
|
10
12
|
unsignedTxId(): string;
|
|
@@ -94,7 +94,7 @@ export { inputScriptTypes, outputScriptTypes };
|
|
|
94
94
|
* - psbt-lite: Only witness_utxo (no non_witness_utxo)
|
|
95
95
|
*/
|
|
96
96
|
export declare class AcidTest {
|
|
97
|
-
readonly
|
|
97
|
+
readonly coin: CoinName;
|
|
98
98
|
readonly signStage: SignStage;
|
|
99
99
|
readonly txFormat: TxFormat;
|
|
100
100
|
readonly rootWalletKeys: RootWalletKeys;
|
|
@@ -104,11 +104,11 @@ export declare class AcidTest {
|
|
|
104
104
|
private readonly userXprv;
|
|
105
105
|
private readonly backupXprv;
|
|
106
106
|
private readonly bitgoXprv;
|
|
107
|
-
constructor(
|
|
107
|
+
constructor(coin: CoinName, signStage: SignStage, txFormat: TxFormat, rootWalletKeys: RootWalletKeys, otherWalletKeys: RootWalletKeys, inputs: Input[], outputs: Output[], xprvTriple: Triple<BIP32>);
|
|
108
108
|
/**
|
|
109
109
|
* Create an AcidTest with specific configuration
|
|
110
110
|
*/
|
|
111
|
-
static withConfig(
|
|
111
|
+
static withConfig(coin: CoinName, signStage: SignStage, txFormat: TxFormat, suiteConfig?: SuiteConfig): AcidTest;
|
|
112
112
|
/**
|
|
113
113
|
* Get a human-readable name for this test configuration
|
|
114
114
|
*/
|