@bitgo/wasm-utxo 1.35.0 → 1.37.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/bip32.d.ts +19 -0
- package/dist/cjs/js/bip32.js +29 -0
- package/dist/cjs/js/index.d.ts +7 -2
- package/dist/cjs/js/index.js +2 -2
- package/dist/cjs/js/message.d.ts +36 -0
- package/dist/cjs/js/message.js +47 -0
- package/dist/cjs/js/testutils/descriptor/descriptors.d.ts +27 -0
- package/dist/cjs/js/testutils/descriptor/descriptors.js +163 -0
- package/dist/cjs/js/testutils/descriptor/index.d.ts +2 -0
- package/dist/cjs/js/testutils/descriptor/index.js +18 -0
- package/dist/cjs/js/testutils/descriptor/mockPsbt.d.ts +41 -0
- package/dist/cjs/js/testutils/descriptor/mockPsbt.js +62 -0
- package/dist/cjs/js/testutils/fixtures.d.ts +35 -0
- package/dist/cjs/js/testutils/fixtures.js +244 -0
- package/dist/cjs/js/testutils/index.d.ts +2 -0
- package/dist/cjs/js/testutils/index.js +25 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +33 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +112 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +103 -98
- package/dist/esm/js/bip32.d.ts +19 -0
- package/dist/esm/js/bip32.js +29 -0
- package/dist/esm/js/index.d.ts +7 -2
- package/dist/esm/js/index.js +1 -1
- package/dist/esm/js/message.d.ts +36 -0
- package/dist/esm/js/message.js +43 -0
- package/dist/esm/js/testutils/descriptor/descriptors.d.ts +27 -0
- package/dist/esm/js/testutils/descriptor/descriptors.js +150 -0
- package/dist/esm/js/testutils/descriptor/index.d.ts +2 -0
- package/dist/esm/js/testutils/descriptor/index.js +2 -0
- package/dist/esm/js/testutils/descriptor/mockPsbt.d.ts +41 -0
- package/dist/esm/js/testutils/descriptor/mockPsbt.js +56 -0
- package/dist/esm/js/testutils/fixtures.d.ts +35 -0
- package/dist/esm/js/testutils/fixtures.js +205 -0
- package/dist/esm/js/testutils/index.d.ts +2 -0
- package/dist/esm/js/testutils/index.js +2 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +33 -0
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +111 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +103 -98
- package/package.json +11 -1
|
@@ -1,6 +1,51 @@
|
|
|
1
1
|
/* tslint:disable */
|
|
2
2
|
/* eslint-disable */
|
|
3
3
|
export const memory: WebAssembly.Memory;
|
|
4
|
+
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
5
|
+
export const __wbg_messagenamespace_free: (a: number, b: number) => void;
|
|
6
|
+
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
7
|
+
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
8
|
+
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
9
|
+
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
10
|
+
export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
|
|
11
|
+
export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
12
|
+
export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
|
|
13
|
+
export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
|
|
14
|
+
export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
|
|
15
|
+
export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
|
|
16
|
+
export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
|
|
17
|
+
export const wasmecpair_private_key: (a: number) => number;
|
|
18
|
+
export const wasmecpair_public_key: (a: number) => number;
|
|
19
|
+
export const wasmecpair_to_wif: (a: number, b: number) => void;
|
|
20
|
+
export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
|
|
21
|
+
export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
22
|
+
export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
|
|
23
|
+
export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
|
|
24
|
+
export const wrappsbt_clone: (a: number) => number;
|
|
25
|
+
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
26
|
+
export const wrappsbt_extractTransaction: (a: number, b: number) => void;
|
|
27
|
+
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
28
|
+
export const wrappsbt_getInputs: (a: number, b: number) => void;
|
|
29
|
+
export const wrappsbt_getOutputs: (a: number, b: number) => void;
|
|
30
|
+
export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
|
|
31
|
+
export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
|
|
32
|
+
export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
|
|
33
|
+
export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
|
|
34
|
+
export const wrappsbt_inputCount: (a: number) => number;
|
|
35
|
+
export const wrappsbt_lockTime: (a: number) => number;
|
|
36
|
+
export const wrappsbt_new: (a: number, b: number) => number;
|
|
37
|
+
export const wrappsbt_outputCount: (a: number) => number;
|
|
38
|
+
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
39
|
+
export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
|
|
40
|
+
export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
|
|
41
|
+
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
42
|
+
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
43
|
+
export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
|
|
44
|
+
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
45
|
+
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
46
|
+
export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
47
|
+
export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
|
|
48
|
+
export const wrappsbt_version: (a: number) => number;
|
|
4
49
|
export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
|
|
5
50
|
export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
|
|
6
51
|
export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
@@ -11,9 +56,65 @@ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
|
|
|
11
56
|
export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
|
|
12
57
|
export const wasmrootwalletkeys_user_key: (a: number) => number;
|
|
13
58
|
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;
|
|
59
|
+
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
60
|
+
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
61
|
+
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
62
|
+
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
63
|
+
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
64
|
+
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
65
|
+
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
66
|
+
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;
|
|
67
|
+
export const wasmbip32_chain_code: (a: number) => number;
|
|
68
|
+
export const wasmbip32_depth: (a: number) => number;
|
|
69
|
+
export const wasmbip32_derive: (a: number, b: number, c: number) => void;
|
|
70
|
+
export const wasmbip32_derive_hardened: (a: number, b: number, c: number) => void;
|
|
71
|
+
export const wasmbip32_derive_path: (a: number, b: number, c: number, d: number) => void;
|
|
72
|
+
export const wasmbip32_equals: (a: number, b: number) => number;
|
|
73
|
+
export const wasmbip32_fingerprint: (a: number) => number;
|
|
74
|
+
export const wasmbip32_from_base58: (a: number, b: number, c: number) => void;
|
|
75
|
+
export const wasmbip32_from_bip32_interface: (a: number, b: number) => void;
|
|
76
|
+
export const wasmbip32_from_seed: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
77
|
+
export const wasmbip32_from_seed_sha256: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
78
|
+
export const wasmbip32_from_xprv: (a: number, b: number, c: number) => void;
|
|
79
|
+
export const wasmbip32_from_xpub: (a: number, b: number, c: number) => void;
|
|
80
|
+
export const wasmbip32_identifier: (a: number) => number;
|
|
81
|
+
export const wasmbip32_index: (a: number) => number;
|
|
82
|
+
export const wasmbip32_is_neutered: (a: number) => number;
|
|
83
|
+
export const wasmbip32_neutered: (a: number) => number;
|
|
84
|
+
export const wasmbip32_parent_fingerprint: (a: number) => number;
|
|
85
|
+
export const wasmbip32_private_key: (a: number) => number;
|
|
86
|
+
export const wasmbip32_public_key: (a: number) => number;
|
|
87
|
+
export const wasmbip32_to_base58: (a: number, b: number) => void;
|
|
88
|
+
export const wasmbip32_to_wif: (a: number, b: number) => void;
|
|
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;
|
|
107
|
+
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
108
|
+
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
109
|
+
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
110
|
+
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
111
|
+
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
112
|
+
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
113
|
+
export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
|
|
14
114
|
export const __wbg_bip322namespace_free: (a: number, b: number) => void;
|
|
15
115
|
export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
|
|
16
116
|
export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
|
|
117
|
+
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
17
118
|
export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
|
|
18
119
|
export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
|
|
19
120
|
export const bip322namespace_add_bip322_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number, m: number) => void;
|
|
@@ -69,6 +170,8 @@ export const fixedscriptwalletnamespace_create_op_return_script: (a: number, b:
|
|
|
69
170
|
export const fixedscriptwalletnamespace_output_script: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
70
171
|
export const fixedscriptwalletnamespace_output_script_with_network_str: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
71
172
|
export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
173
|
+
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
174
|
+
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
72
175
|
export const wasmdashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
73
176
|
export const wasmdashtransaction_get_txid: (a: number, b: number) => void;
|
|
74
177
|
export const wasmdashtransaction_to_bytes: (a: number, b: number) => void;
|
|
@@ -90,104 +193,6 @@ export const wasmdimensions_times: (a: number, b: number) => number;
|
|
|
90
193
|
export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
|
|
91
194
|
export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
|
|
92
195
|
export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
|
|
93
|
-
export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
|
|
94
|
-
export const __wbg_wasmbip32_free: (a: number, b: number) => void;
|
|
95
|
-
export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
|
|
96
|
-
export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
|
|
97
|
-
export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
|
|
98
|
-
export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
|
|
99
|
-
export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
100
|
-
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;
|
|
101
|
-
export const wasmbip32_chain_code: (a: number) => number;
|
|
102
|
-
export const wasmbip32_depth: (a: number) => number;
|
|
103
|
-
export const wasmbip32_derive: (a: number, b: number, c: number) => void;
|
|
104
|
-
export const wasmbip32_derive_hardened: (a: number, b: number, c: number) => void;
|
|
105
|
-
export const wasmbip32_derive_path: (a: number, b: number, c: number, d: number) => void;
|
|
106
|
-
export const wasmbip32_fingerprint: (a: number) => number;
|
|
107
|
-
export const wasmbip32_from_base58: (a: number, b: number, c: number) => void;
|
|
108
|
-
export const wasmbip32_from_bip32_interface: (a: number, b: number) => void;
|
|
109
|
-
export const wasmbip32_from_seed: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
110
|
-
export const wasmbip32_from_seed_sha256: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
111
|
-
export const wasmbip32_from_xprv: (a: number, b: number, c: number) => void;
|
|
112
|
-
export const wasmbip32_from_xpub: (a: number, b: number, c: number) => void;
|
|
113
|
-
export const wasmbip32_identifier: (a: number) => number;
|
|
114
|
-
export const wasmbip32_index: (a: number) => number;
|
|
115
|
-
export const wasmbip32_is_neutered: (a: number) => number;
|
|
116
|
-
export const wasmbip32_neutered: (a: number) => number;
|
|
117
|
-
export const wasmbip32_parent_fingerprint: (a: number) => number;
|
|
118
|
-
export const wasmbip32_private_key: (a: number) => number;
|
|
119
|
-
export const wasmbip32_public_key: (a: number) => number;
|
|
120
|
-
export const wasmbip32_to_base58: (a: number, b: number) => void;
|
|
121
|
-
export const wasmbip32_to_wif: (a: number, b: number) => void;
|
|
122
|
-
export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
123
|
-
export const wasmtransaction_get_txid: (a: number, b: number) => void;
|
|
124
|
-
export const wasmtransaction_get_vsize: (a: number) => number;
|
|
125
|
-
export const wasmtransaction_to_bytes: (a: number, b: number) => void;
|
|
126
|
-
export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
|
|
127
|
-
export const wasmzcashtransaction_get_txid: (a: number, b: number) => void;
|
|
128
|
-
export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
|
|
129
|
-
export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
|
|
130
|
-
export const wrapdescriptor_descType: (a: number, b: number) => void;
|
|
131
|
-
export const wrapdescriptor_encode: (a: number, b: number) => void;
|
|
132
|
-
export const wrapdescriptor_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
133
|
-
export const wrapdescriptor_fromStringDetectType: (a: number, b: number, c: number) => void;
|
|
134
|
-
export const wrapdescriptor_hasWildcard: (a: number) => number;
|
|
135
|
-
export const wrapdescriptor_maxWeightToSatisfy: (a: number, b: number) => void;
|
|
136
|
-
export const wrapdescriptor_node: (a: number, b: number) => void;
|
|
137
|
-
export const wrapdescriptor_scriptPubkey: (a: number, b: number) => void;
|
|
138
|
-
export const wrapdescriptor_toAsmString: (a: number, b: number) => void;
|
|
139
|
-
export const wrapdescriptor_toString: (a: number, b: number) => void;
|
|
140
|
-
export const wrapminiscript_encode: (a: number, b: number) => void;
|
|
141
|
-
export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
142
|
-
export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
143
|
-
export const wrapminiscript_node: (a: number, b: number) => void;
|
|
144
|
-
export const wrapminiscript_toAsmString: (a: number, b: number) => void;
|
|
145
|
-
export const wrapminiscript_toString: (a: number, b: number) => void;
|
|
146
|
-
export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
|
|
147
|
-
export const __wbg_addressnamespace_free: (a: number, b: number) => void;
|
|
148
|
-
export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
|
|
149
|
-
export const __wbg_wasmecpair_free: (a: number, b: number) => void;
|
|
150
|
-
export const __wbg_wrappsbt_free: (a: number, b: number) => void;
|
|
151
|
-
export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
|
|
152
|
-
export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
153
|
-
export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
154
|
-
export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
|
|
155
|
-
export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
|
|
156
|
-
export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
|
|
157
|
-
export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
|
|
158
|
-
export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
|
|
159
|
-
export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
|
|
160
|
-
export const wasmecpair_private_key: (a: number) => number;
|
|
161
|
-
export const wasmecpair_public_key: (a: number) => number;
|
|
162
|
-
export const wasmecpair_to_wif: (a: number, b: number) => void;
|
|
163
|
-
export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
|
|
164
|
-
export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
|
|
165
|
-
export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
|
|
166
|
-
export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
|
|
167
|
-
export const wrappsbt_clone: (a: number) => number;
|
|
168
|
-
export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
|
|
169
|
-
export const wrappsbt_extractTransaction: (a: number, b: number) => void;
|
|
170
|
-
export const wrappsbt_finalize: (a: number, b: number) => void;
|
|
171
|
-
export const wrappsbt_getInputs: (a: number, b: number) => void;
|
|
172
|
-
export const wrappsbt_getOutputs: (a: number, b: number) => void;
|
|
173
|
-
export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
|
|
174
|
-
export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
|
|
175
|
-
export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
|
|
176
|
-
export const wrappsbt_inputCount: (a: number) => number;
|
|
177
|
-
export const wrappsbt_lockTime: (a: number) => number;
|
|
178
|
-
export const wrappsbt_new: (a: number, b: number) => number;
|
|
179
|
-
export const wrappsbt_outputCount: (a: number) => number;
|
|
180
|
-
export const wrappsbt_serialize: (a: number, b: number) => void;
|
|
181
|
-
export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
|
|
182
|
-
export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
|
|
183
|
-
export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
|
|
184
|
-
export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
|
|
185
|
-
export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
|
|
186
|
-
export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
187
|
-
export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
|
|
188
|
-
export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
|
|
189
|
-
export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
|
|
190
|
-
export const wrappsbt_version: (a: number) => number;
|
|
191
196
|
export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
|
|
192
197
|
export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
|
|
193
198
|
export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
|
package/dist/esm/js/bip32.d.ts
CHANGED
|
@@ -140,6 +140,25 @@ export declare class BIP32 implements BIP32Interface {
|
|
|
140
140
|
* @returns A new BIP32 instance for the derived key
|
|
141
141
|
*/
|
|
142
142
|
derivePath(path: string): BIP32;
|
|
143
|
+
/**
|
|
144
|
+
* Check equality with another BIP32 key.
|
|
145
|
+
* Two keys are equal if they have the same type (public/private) and identical
|
|
146
|
+
* BIP32 metadata (depth, parent fingerprint, child index, chain code, key data).
|
|
147
|
+
* This is a fast comparison that does not require serialization.
|
|
148
|
+
*
|
|
149
|
+
* @param other - The other key to compare with. Accepts BIP32, or any BIP32Interface.
|
|
150
|
+
* @returns True if the keys are equal
|
|
151
|
+
*/
|
|
152
|
+
equals(other: BIP32Interface): boolean;
|
|
153
|
+
/**
|
|
154
|
+
* Custom JSON representation for debugging.
|
|
155
|
+
* Always serializes the public key (xpub) to avoid leaking private keys.
|
|
156
|
+
* Includes a `hasPrivateKey` flag to indicate whether the key is neutered.
|
|
157
|
+
*/
|
|
158
|
+
toJSON(): {
|
|
159
|
+
xpub: string;
|
|
160
|
+
hasPrivateKey: boolean;
|
|
161
|
+
};
|
|
143
162
|
/**
|
|
144
163
|
* Get the underlying WASM instance (internal use only)
|
|
145
164
|
* @internal
|
package/dist/esm/js/bip32.js
CHANGED
|
@@ -174,6 +174,35 @@ export class BIP32 {
|
|
|
174
174
|
const wasm = this._wasm.derive_path(path);
|
|
175
175
|
return new BIP32(wasm);
|
|
176
176
|
}
|
|
177
|
+
/**
|
|
178
|
+
* Check equality with another BIP32 key.
|
|
179
|
+
* Two keys are equal if they have the same type (public/private) and identical
|
|
180
|
+
* BIP32 metadata (depth, parent fingerprint, child index, chain code, key data).
|
|
181
|
+
* This is a fast comparison that does not require serialization.
|
|
182
|
+
*
|
|
183
|
+
* @param other - The other key to compare with. Accepts BIP32, or any BIP32Interface.
|
|
184
|
+
* @returns True if the keys are equal
|
|
185
|
+
*/
|
|
186
|
+
equals(other) {
|
|
187
|
+
const otherWasm = other instanceof BIP32 ? other._wasm : BIP32.from(other)._wasm;
|
|
188
|
+
return this._wasm.equals(otherWasm);
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Custom JSON representation for debugging.
|
|
192
|
+
* Always serializes the public key (xpub) to avoid leaking private keys.
|
|
193
|
+
* Includes a `hasPrivateKey` flag to indicate whether the key is neutered.
|
|
194
|
+
*/
|
|
195
|
+
toJSON() {
|
|
196
|
+
return { xpub: this.neutered().toBase58(), hasPrivateKey: !this.isNeutered() };
|
|
197
|
+
}
|
|
198
|
+
/**
|
|
199
|
+
* Custom inspect representation for Node.js util.inspect and console.log.
|
|
200
|
+
* Always shows the public key (xpub) to avoid leaking private keys.
|
|
201
|
+
*/
|
|
202
|
+
[Symbol.for("nodejs.util.inspect.custom")]() {
|
|
203
|
+
const flag = this.isNeutered() ? "" : ", hasPrivateKey";
|
|
204
|
+
return `BIP32(${this.neutered().toBase58()}${flag})`;
|
|
205
|
+
}
|
|
177
206
|
/**
|
|
178
207
|
* Get the underlying WASM instance (internal use only)
|
|
179
208
|
* @internal
|
package/dist/esm/js/index.d.ts
CHANGED
|
@@ -2,16 +2,16 @@ export * as address from "./address.js";
|
|
|
2
2
|
export * as ast from "./ast/index.js";
|
|
3
3
|
export * as bip322 from "./bip322/index.js";
|
|
4
4
|
export * as inscriptions from "./inscriptions.js";
|
|
5
|
+
export * as message from "./message.js";
|
|
5
6
|
export * as utxolibCompat from "./utxolibCompat.js";
|
|
6
7
|
export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
|
|
7
8
|
export * as descriptorWallet from "./descriptorWallet/index.js";
|
|
8
9
|
export * as bip32 from "./bip32.js";
|
|
9
10
|
export * as ecpair from "./ecpair.js";
|
|
10
|
-
export * as testutils from "./testutils/index.js";
|
|
11
11
|
export { ECPair } from "./ecpair.js";
|
|
12
12
|
export { BIP32 } from "./bip32.js";
|
|
13
13
|
export { Dimensions } from "./fixedScriptWallet/Dimensions.js";
|
|
14
|
-
export type { CoinName } from "./coinName.js";
|
|
14
|
+
export type { CoinName, getMainnet, isMainnet, isTestnet, isCoinName } from "./coinName.js";
|
|
15
15
|
export type { Triple } from "./triple.js";
|
|
16
16
|
export type { AddressFormat } from "./address.js";
|
|
17
17
|
export type { TapLeafScript, PreparedInscriptionRevealData } from "./inscriptions.js";
|
|
@@ -60,6 +60,10 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
60
60
|
bip32Derivation: PsbtBip32Derivation[];
|
|
61
61
|
tapBip32Derivation: PsbtBip32Derivation[];
|
|
62
62
|
}
|
|
63
|
+
/** PSBT output data with resolved address, returned by getOutputsWithAddress() */
|
|
64
|
+
interface PsbtOutputDataWithAddress extends PsbtOutputData {
|
|
65
|
+
address: string;
|
|
66
|
+
}
|
|
63
67
|
interface WrapPsbt {
|
|
64
68
|
signWithXprv(this: WrapPsbt, xprv: string): SignPsbtResult;
|
|
65
69
|
signWithPrv(this: WrapPsbt, prv: Uint8Array): SignPsbtResult;
|
|
@@ -69,6 +73,7 @@ declare module "./wasm/wasm_utxo.js" {
|
|
|
69
73
|
outputCount(): number;
|
|
70
74
|
getInputs(): PsbtInputData[];
|
|
71
75
|
getOutputs(): PsbtOutputData[];
|
|
76
|
+
getOutputsWithAddress(coin: import("./coinName.js").CoinName): PsbtOutputDataWithAddress[];
|
|
72
77
|
getPartialSignatures(inputIndex: number): Array<{
|
|
73
78
|
pubkey: Uint8Array;
|
|
74
79
|
signature: Uint8Array;
|
package/dist/esm/js/index.js
CHANGED
|
@@ -8,12 +8,12 @@ export * as address from "./address.js";
|
|
|
8
8
|
export * as ast from "./ast/index.js";
|
|
9
9
|
export * as bip322 from "./bip322/index.js";
|
|
10
10
|
export * as inscriptions from "./inscriptions.js";
|
|
11
|
+
export * as message from "./message.js";
|
|
11
12
|
export * as utxolibCompat from "./utxolibCompat.js";
|
|
12
13
|
export * as fixedScriptWallet from "./fixedScriptWallet/index.js";
|
|
13
14
|
export * as descriptorWallet from "./descriptorWallet/index.js";
|
|
14
15
|
export * as bip32 from "./bip32.js";
|
|
15
16
|
export * as ecpair from "./ecpair.js";
|
|
16
|
-
export * as testutils from "./testutils/index.js";
|
|
17
17
|
// Only the most commonly used classes and types are exported at the top level for convenience
|
|
18
18
|
export { ECPair } from "./ecpair.js";
|
|
19
19
|
export { BIP32 } from "./bip32.js";
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitcoin message signing and verification (BIP-137)
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for signing and verifying Bitcoin messages
|
|
5
|
+
* using the standard Bitcoin Signed Message format (BIP-137).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { message, ECPair } from '@bitgo/wasm-utxo';
|
|
10
|
+
*
|
|
11
|
+
* // Sign a message
|
|
12
|
+
* const key = ECPair.fromWIF('L1TnU2zbNaAqMoVh65Cyvmcjzbrj41Gs9iTLcWbpJCpV1iNMXpuR');
|
|
13
|
+
* const signature = message.signMessage('Hello, Bitcoin!', key);
|
|
14
|
+
*
|
|
15
|
+
* // Verify a message
|
|
16
|
+
* const isValid = message.verifyMessage('Hello, Bitcoin!', key, signature);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { type ECPairArg } from "./ecpair.js";
|
|
20
|
+
/**
|
|
21
|
+
* Sign a message using Bitcoin message signing (BIP-137)
|
|
22
|
+
*
|
|
23
|
+
* @param message - The message to sign
|
|
24
|
+
* @param key - The key to sign with (must have a private key)
|
|
25
|
+
* @returns 65-byte signature (1-byte header + 64-byte signature)
|
|
26
|
+
*/
|
|
27
|
+
export declare function signMessage(message: string, key: ECPairArg): Uint8Array;
|
|
28
|
+
/**
|
|
29
|
+
* Verify a Bitcoin message signature (BIP-137)
|
|
30
|
+
*
|
|
31
|
+
* @param message - The message that was signed
|
|
32
|
+
* @param key - The key to verify against
|
|
33
|
+
* @param signature - 65-byte signature (1-byte header + 64-byte signature)
|
|
34
|
+
* @returns True if the signature is valid for this key
|
|
35
|
+
*/
|
|
36
|
+
export declare function verifyMessage(message: string, key: ECPairArg, signature: Uint8Array): boolean;
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bitcoin message signing and verification (BIP-137)
|
|
3
|
+
*
|
|
4
|
+
* This module provides functions for signing and verifying Bitcoin messages
|
|
5
|
+
* using the standard Bitcoin Signed Message format (BIP-137).
|
|
6
|
+
*
|
|
7
|
+
* @example
|
|
8
|
+
* ```typescript
|
|
9
|
+
* import { message, ECPair } from '@bitgo/wasm-utxo';
|
|
10
|
+
*
|
|
11
|
+
* // Sign a message
|
|
12
|
+
* const key = ECPair.fromWIF('L1TnU2zbNaAqMoVh65Cyvmcjzbrj41Gs9iTLcWbpJCpV1iNMXpuR');
|
|
13
|
+
* const signature = message.signMessage('Hello, Bitcoin!', key);
|
|
14
|
+
*
|
|
15
|
+
* // Verify a message
|
|
16
|
+
* const isValid = message.verifyMessage('Hello, Bitcoin!', key, signature);
|
|
17
|
+
* ```
|
|
18
|
+
*/
|
|
19
|
+
import { MessageNamespace } from "./wasm/wasm_utxo.js";
|
|
20
|
+
import { ECPair } from "./ecpair.js";
|
|
21
|
+
/**
|
|
22
|
+
* Sign a message using Bitcoin message signing (BIP-137)
|
|
23
|
+
*
|
|
24
|
+
* @param message - The message to sign
|
|
25
|
+
* @param key - The key to sign with (must have a private key)
|
|
26
|
+
* @returns 65-byte signature (1-byte header + 64-byte signature)
|
|
27
|
+
*/
|
|
28
|
+
export function signMessage(message, key) {
|
|
29
|
+
const ecpair = ECPair.from(key);
|
|
30
|
+
return new Uint8Array(MessageNamespace.sign_message(ecpair.wasm, message));
|
|
31
|
+
}
|
|
32
|
+
/**
|
|
33
|
+
* Verify a Bitcoin message signature (BIP-137)
|
|
34
|
+
*
|
|
35
|
+
* @param message - The message that was signed
|
|
36
|
+
* @param key - The key to verify against
|
|
37
|
+
* @param signature - 65-byte signature (1-byte header + 64-byte signature)
|
|
38
|
+
* @returns True if the signature is valid for this key
|
|
39
|
+
*/
|
|
40
|
+
export function verifyMessage(message, key, signature) {
|
|
41
|
+
const ecpair = ECPair.from(key);
|
|
42
|
+
return MessageNamespace.verify_message(ecpair.wasm, message, signature);
|
|
43
|
+
}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { BIP32Interface } from "../../bip32.js";
|
|
2
|
+
import { Descriptor, Miniscript, ast } from "../../index.js";
|
|
3
|
+
import type { Triple } from "../../triple.js";
|
|
4
|
+
import { DescriptorMap, PsbtParams } from "../../descriptorWallet/index.js";
|
|
5
|
+
type KeyTriple = Triple<BIP32Interface>;
|
|
6
|
+
export type DescriptorTemplate = "Wsh2Of3" | "Tr1Of3-NoKeyPath-Tree" | "Tr1Of3-NoKeyPath-Tree-Plain" | "Tr2Of3-NoKeyPath" | "Wsh2Of2"
|
|
7
|
+
/**
|
|
8
|
+
* Wrapped segwit 2of3 multisig with a relative locktime OP_DROP
|
|
9
|
+
* (requiring a miniscript extension). Used in CoreDao staking transactions.
|
|
10
|
+
*/
|
|
11
|
+
| "Wsh2Of3CltvDrop";
|
|
12
|
+
/**
|
|
13
|
+
* Get the BIP-341 "Nothing Up My Sleeve" (NUMS) unspendable key.
|
|
14
|
+
* This is the x-only public key with unknown discrete logarithm
|
|
15
|
+
* constructed by hashing the uncompressed secp256k1 base point G.
|
|
16
|
+
*
|
|
17
|
+
* @see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs
|
|
18
|
+
*/
|
|
19
|
+
export declare function getUnspendableKey(): string;
|
|
20
|
+
export declare function getDefaultXPubs(seed?: string): Triple<string>;
|
|
21
|
+
export declare function getPsbtParams(t: DescriptorTemplate): Partial<PsbtParams>;
|
|
22
|
+
export declare function getDescriptorNode(template: DescriptorTemplate, keys?: KeyTriple | string[], path?: string): ast.DescriptorNode;
|
|
23
|
+
export declare function containsKey(script: Miniscript | ast.MiniscriptNode, key: BIP32Interface | string): boolean;
|
|
24
|
+
export declare function getTapLeafScripts(d: Descriptor): string[];
|
|
25
|
+
export declare function getDescriptor(template: DescriptorTemplate, keys?: KeyTriple | string[], path?: string): Descriptor;
|
|
26
|
+
export declare function getDescriptorMap(template: DescriptorTemplate, keys?: KeyTriple | string[]): DescriptorMap;
|
|
27
|
+
export {};
|
|
@@ -0,0 +1,150 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Descriptor test utilities for building common descriptor templates.
|
|
3
|
+
* Ported from @bitgo/utxo-core/testutil/descriptor/descriptors.ts.
|
|
4
|
+
*/
|
|
5
|
+
import assert from "assert";
|
|
6
|
+
import { BIP32 } from "../../bip32.js";
|
|
7
|
+
import { Descriptor, Miniscript, ast } from "../../index.js";
|
|
8
|
+
import { getKeyTriple } from "../keys.js";
|
|
9
|
+
/**
|
|
10
|
+
* Get the BIP-341 "Nothing Up My Sleeve" (NUMS) unspendable key.
|
|
11
|
+
* This is the x-only public key with unknown discrete logarithm
|
|
12
|
+
* constructed by hashing the uncompressed secp256k1 base point G.
|
|
13
|
+
*
|
|
14
|
+
* @see https://github.com/bitcoin/bips/blob/master/bip-0341.mediawiki#constructing-and-spending-taproot-outputs
|
|
15
|
+
*/
|
|
16
|
+
export function getUnspendableKey() {
|
|
17
|
+
return "50929b74c1a04954b78b4b6035e97a5e078a5a0f28ec96d547bfee9ace803ac0";
|
|
18
|
+
}
|
|
19
|
+
export function getDefaultXPubs(seed) {
|
|
20
|
+
return getKeyTriple(seed ?? "default").map((k) => k.neutered().toBase58());
|
|
21
|
+
}
|
|
22
|
+
function toDescriptorMap(v) {
|
|
23
|
+
return new Map(Object.entries(v).map(([k, v]) => [k, Descriptor.fromString(v, "derivable")]));
|
|
24
|
+
}
|
|
25
|
+
function toXPub(k, path) {
|
|
26
|
+
if (typeof k === "string") {
|
|
27
|
+
return k + "/" + path;
|
|
28
|
+
}
|
|
29
|
+
return k.neutered().toBase58() + "/" + path;
|
|
30
|
+
}
|
|
31
|
+
function toPlain(k, { xonly = false } = {}) {
|
|
32
|
+
if (typeof k === "string") {
|
|
33
|
+
if (k.startsWith("xpub") || k.startsWith("xprv")) {
|
|
34
|
+
return toPlain(BIP32.fromBase58(k), { xonly });
|
|
35
|
+
}
|
|
36
|
+
return k;
|
|
37
|
+
}
|
|
38
|
+
return toHex(k.publicKey.subarray(xonly ? 1 : 0));
|
|
39
|
+
}
|
|
40
|
+
function toHex(bytes) {
|
|
41
|
+
return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
|
|
42
|
+
}
|
|
43
|
+
function toXOnly(k) {
|
|
44
|
+
return toPlain(k, { xonly: true });
|
|
45
|
+
}
|
|
46
|
+
function multiArgs(m, n, keys, path) {
|
|
47
|
+
if (n < m) {
|
|
48
|
+
throw new Error(`Cannot create ${m} of ${n} multisig`);
|
|
49
|
+
}
|
|
50
|
+
if (keys.length < n) {
|
|
51
|
+
throw new Error(`Not enough keys for ${m} of ${n} multisig: keys.length=${keys.length}`);
|
|
52
|
+
}
|
|
53
|
+
keys = keys.slice(0, n);
|
|
54
|
+
return [m, ...keys.map((k) => toXPub(k, path))];
|
|
55
|
+
}
|
|
56
|
+
export function getPsbtParams(t) {
|
|
57
|
+
switch (t) {
|
|
58
|
+
case "Wsh2Of3CltvDrop":
|
|
59
|
+
return { locktime: 1 };
|
|
60
|
+
default:
|
|
61
|
+
return {};
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
export function getDescriptorNode(template, keys = getDefaultXPubs(), path = "0/*") {
|
|
65
|
+
switch (template) {
|
|
66
|
+
case "Wsh2Of3":
|
|
67
|
+
return {
|
|
68
|
+
wsh: { multi: multiArgs(2, 3, keys, path) },
|
|
69
|
+
};
|
|
70
|
+
case "Wsh2Of3CltvDrop": {
|
|
71
|
+
const { locktime } = getPsbtParams(template);
|
|
72
|
+
assert(locktime);
|
|
73
|
+
return {
|
|
74
|
+
wsh: {
|
|
75
|
+
and_v: [{ "r:after": locktime }, { multi: multiArgs(2, 3, keys, path) }],
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
}
|
|
79
|
+
case "Wsh2Of2":
|
|
80
|
+
return {
|
|
81
|
+
wsh: { multi: multiArgs(2, 2, keys, path) },
|
|
82
|
+
};
|
|
83
|
+
case "Tr2Of3-NoKeyPath":
|
|
84
|
+
return {
|
|
85
|
+
tr: [getUnspendableKey(), { multi_a: multiArgs(2, 3, keys, path) }],
|
|
86
|
+
};
|
|
87
|
+
case "Tr1Of3-NoKeyPath-Tree":
|
|
88
|
+
return {
|
|
89
|
+
tr: [
|
|
90
|
+
getUnspendableKey(),
|
|
91
|
+
[
|
|
92
|
+
{ pk: toXPub(keys[0], path) },
|
|
93
|
+
[{ pk: toXPub(keys[1], path) }, { pk: toXPub(keys[2], path) }],
|
|
94
|
+
],
|
|
95
|
+
],
|
|
96
|
+
};
|
|
97
|
+
case "Tr1Of3-NoKeyPath-Tree-Plain":
|
|
98
|
+
return {
|
|
99
|
+
tr: [
|
|
100
|
+
getUnspendableKey(),
|
|
101
|
+
[{ pk: toXOnly(keys[0]) }, [{ pk: toXOnly(keys[1]) }, { pk: toXOnly(keys[2]) }]],
|
|
102
|
+
],
|
|
103
|
+
};
|
|
104
|
+
}
|
|
105
|
+
throw new Error(`Unknown descriptor template: ${template}`);
|
|
106
|
+
}
|
|
107
|
+
function getTapLeafScriptNodes(t) {
|
|
108
|
+
if (Array.isArray(t)) {
|
|
109
|
+
if (t.length !== 2) {
|
|
110
|
+
throw new Error(`expected tuple, got: ${JSON.stringify(t)}`);
|
|
111
|
+
}
|
|
112
|
+
return t.map((v) => (Array.isArray(v) ? getTapLeafScriptNodes(v) : v)).flat();
|
|
113
|
+
}
|
|
114
|
+
if (typeof t === "object") {
|
|
115
|
+
const node = t;
|
|
116
|
+
if (!("tr" in node)) {
|
|
117
|
+
throw new Error(`TapLeafScripts are only supported for Taproot descriptors, got: ${JSON.stringify(t)}`);
|
|
118
|
+
}
|
|
119
|
+
if (!Array.isArray(node.tr) || node.tr.length !== 2) {
|
|
120
|
+
throw new Error(`expected tuple, got: ${JSON.stringify(node.tr)}`);
|
|
121
|
+
}
|
|
122
|
+
const tapscript = node.tr[1];
|
|
123
|
+
if (!Array.isArray(tapscript)) {
|
|
124
|
+
throw new Error(`expected tapscript to be an array, got: ${JSON.stringify(tapscript)}`);
|
|
125
|
+
}
|
|
126
|
+
return getTapLeafScriptNodes(tapscript);
|
|
127
|
+
}
|
|
128
|
+
throw new Error(`Invalid input: ${JSON.stringify(t)}`);
|
|
129
|
+
}
|
|
130
|
+
export function containsKey(script, key) {
|
|
131
|
+
if (script instanceof Miniscript) {
|
|
132
|
+
script = ast.fromMiniscript(script);
|
|
133
|
+
}
|
|
134
|
+
if ("pk" in script) {
|
|
135
|
+
return script.pk === toXOnly(key);
|
|
136
|
+
}
|
|
137
|
+
throw new Error(`Unsupported script type: ${JSON.stringify(script)}`);
|
|
138
|
+
}
|
|
139
|
+
export function getTapLeafScripts(d) {
|
|
140
|
+
return getTapLeafScriptNodes(ast.fromDescriptor(d)).map((n) => Miniscript.fromString(ast.formatNode(n), "tap").toString());
|
|
141
|
+
}
|
|
142
|
+
export function getDescriptor(template, keys = getDefaultXPubs(), path = "0/*") {
|
|
143
|
+
return Descriptor.fromStringDetectType(ast.formatNode(getDescriptorNode(template, keys, path)));
|
|
144
|
+
}
|
|
145
|
+
export function getDescriptorMap(template, keys = getDefaultXPubs()) {
|
|
146
|
+
return toDescriptorMap({
|
|
147
|
+
external: getDescriptor(template, keys, "0/*").toString(),
|
|
148
|
+
internal: getDescriptor(template, keys, "1/*").toString(),
|
|
149
|
+
});
|
|
150
|
+
}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Mock PSBT utilities for descriptor wallet testing.
|
|
3
|
+
* Ported from @bitgo/utxo-core/testutil/descriptor/mock.utils.ts.
|
|
4
|
+
*
|
|
5
|
+
* Key difference from utxo-core: returns wasm-utxo Psbt instances directly
|
|
6
|
+
* instead of utxolib.bitgo.UtxoPsbt. PsbtParams does not require a network field.
|
|
7
|
+
*/
|
|
8
|
+
import { Descriptor, Miniscript, Psbt } from "../../index.js";
|
|
9
|
+
import { PsbtParams, DerivedDescriptorTransactionInput } from "../../descriptorWallet/index.js";
|
|
10
|
+
import { DescriptorTemplate } from "./descriptors.js";
|
|
11
|
+
type MockOutputIdParams = {
|
|
12
|
+
hash?: string;
|
|
13
|
+
vout?: number;
|
|
14
|
+
};
|
|
15
|
+
type BaseMockDescriptorOutputParams = {
|
|
16
|
+
id?: MockOutputIdParams;
|
|
17
|
+
index?: number;
|
|
18
|
+
value?: bigint;
|
|
19
|
+
sequence?: number;
|
|
20
|
+
selectTapLeafScript?: Miniscript;
|
|
21
|
+
};
|
|
22
|
+
export declare function mockDerivedDescriptorWalletOutput(descriptor: Descriptor, outputParams?: BaseMockDescriptorOutputParams): DerivedDescriptorTransactionInput;
|
|
23
|
+
type MockInput = BaseMockDescriptorOutputParams & {
|
|
24
|
+
index: number;
|
|
25
|
+
descriptor: Descriptor;
|
|
26
|
+
selectTapLeafScript?: Miniscript;
|
|
27
|
+
};
|
|
28
|
+
type MockOutput = {
|
|
29
|
+
descriptor: Descriptor;
|
|
30
|
+
index: number;
|
|
31
|
+
value: bigint;
|
|
32
|
+
external?: boolean;
|
|
33
|
+
};
|
|
34
|
+
export declare function mockPsbt(inputs: MockInput[], outputs: MockOutput[], params?: Partial<PsbtParams>): Psbt;
|
|
35
|
+
export declare function mockPsbtDefault({ descriptorSelf, descriptorOther, params, }?: {
|
|
36
|
+
descriptorSelf?: Descriptor;
|
|
37
|
+
descriptorOther?: Descriptor;
|
|
38
|
+
params?: Partial<PsbtParams>;
|
|
39
|
+
}): Psbt;
|
|
40
|
+
export declare function mockPsbtDefaultWithDescriptorTemplate(t: DescriptorTemplate, params?: Partial<PsbtParams>): Psbt;
|
|
41
|
+
export {};
|