@bitgo/wasm-utxo 2.1.0 → 3.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.
Files changed (33) hide show
  1. package/dist/cjs/js/bip322/index.d.ts +5 -0
  2. package/dist/cjs/js/bip322/index.js +8 -0
  3. package/dist/cjs/js/coinName.d.ts +3 -0
  4. package/dist/cjs/js/coinName.js +49 -0
  5. package/dist/cjs/js/descriptorWallet/Psbt.d.ts +49 -0
  6. package/dist/cjs/js/descriptorWallet/Psbt.js +126 -0
  7. package/dist/cjs/js/descriptorWallet/index.d.ts +1 -0
  8. package/dist/cjs/js/descriptorWallet/index.js +4 -0
  9. package/dist/cjs/js/index.d.ts +1 -31
  10. package/dist/cjs/js/index.js +2 -2
  11. package/dist/cjs/js/testutils/AcidTest.d.ts +3 -3
  12. package/dist/cjs/js/testutils/AcidTest.js +79 -80
  13. package/dist/cjs/js/wasm/wasm_utxo.d.ts +32 -110
  14. package/dist/cjs/js/wasm/wasm_utxo.js +83 -97
  15. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
  16. package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +75 -74
  17. package/dist/esm/js/bip322/index.d.ts +5 -0
  18. package/dist/esm/js/bip322/index.js +7 -0
  19. package/dist/esm/js/coinName.d.ts +3 -0
  20. package/dist/esm/js/coinName.js +48 -0
  21. package/dist/esm/js/descriptorWallet/Psbt.d.ts +49 -0
  22. package/dist/esm/js/descriptorWallet/Psbt.js +122 -0
  23. package/dist/esm/js/descriptorWallet/index.d.ts +1 -0
  24. package/dist/esm/js/descriptorWallet/index.js +2 -0
  25. package/dist/esm/js/index.d.ts +1 -31
  26. package/dist/esm/js/index.js +1 -1
  27. package/dist/esm/js/testutils/AcidTest.d.ts +3 -3
  28. package/dist/esm/js/testutils/AcidTest.js +80 -81
  29. package/dist/esm/js/wasm/wasm_utxo.d.ts +32 -110
  30. package/dist/esm/js/wasm/wasm_utxo_bg.js +83 -97
  31. package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
  32. package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +75 -74
  33. package/package.json +1 -1
@@ -1,79 +1,6 @@
1
1
  /* tslint:disable */
2
2
  /* eslint-disable */
3
3
  export const memory: WebAssembly.Memory;
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;
17
- export const __wbg_addressnamespace_free: (a: number, b: number) => void;
18
- export const __wbg_messagenamespace_free: (a: number, b: number) => void;
19
- export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
20
- export const __wbg_wasmecpair_free: (a: number, b: number) => void;
21
- export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
22
- export const __wbg_wrappsbt_free: (a: number, b: number) => void;
23
- export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
24
- export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
25
- export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
26
- export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
27
- export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
28
- export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
29
- export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
30
- export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
31
- export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
32
- export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
33
- export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
34
- export const wasmecpair_private_key: (a: number) => number;
35
- export const wasmecpair_public_key: (a: number) => number;
36
- export const wasmecpair_to_wif: (a: number, b: number) => void;
37
- export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
38
- export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
39
- export const wrapminiscript_encode: (a: number, b: number) => void;
40
- export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
41
- export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
42
- export const wrapminiscript_node: (a: number, b: number) => void;
43
- export const wrapminiscript_toAsmString: (a: number, b: number) => void;
44
- export const wrapminiscript_toString: (a: number, b: number) => void;
45
- export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
46
- export const wrappsbt_addInputAtIndex: (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_addOutput: (a: number, b: number, c: number, d: bigint) => number;
48
- export const wrappsbt_addOutputAtIndex: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
49
- export const wrappsbt_clone: (a: number) => number;
50
- export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
51
- export const wrappsbt_extractTransaction: (a: number, b: number) => void;
52
- export const wrappsbt_finalize: (a: number, b: number) => void;
53
- export const wrappsbt_getGlobalXpubs: (a: number) => number;
54
- export const wrappsbt_getInputs: (a: number, b: number) => void;
55
- export const wrappsbt_getOutputs: (a: number, b: number) => void;
56
- export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
57
- export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
58
- export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
59
- export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
60
- export const wrappsbt_inputCount: (a: number) => number;
61
- export const wrappsbt_lockTime: (a: number) => number;
62
- export const wrappsbt_new: (a: number, b: number) => number;
63
- export const wrappsbt_outputCount: (a: number) => number;
64
- export const wrappsbt_removeInput: (a: number, b: number, c: number) => void;
65
- export const wrappsbt_removeOutput: (a: number, b: number, c: number) => void;
66
- export const wrappsbt_serialize: (a: number, b: number) => void;
67
- export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
68
- export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
69
- export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
70
- export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
71
- export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
72
- export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
73
- export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
74
- export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
75
- export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
76
- export const wrappsbt_version: (a: number) => number;
77
4
  export const __wbg_wasmdashtransaction_free: (a: number, b: number) => void;
78
5
  export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
79
6
  export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
@@ -107,9 +34,11 @@ export const wrapdescriptor_toString: (a: number, b: number) => void;
107
34
  export const __wbg_bip322namespace_free: (a: number, b: number) => void;
108
35
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
109
36
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
37
+ export const __wbg_messagenamespace_free: (a: number, b: number) => void;
110
38
  export const __wbg_wasmbip32_free: (a: number, b: number) => void;
111
39
  export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
112
40
  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;
41
+ export const bip322namespace_get_bip322_message: (a: number, b: number, c: number) => void;
113
42
  export const bip322namespace_verify_bip322_psbt_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number) => void;
114
43
  export const bip322namespace_verify_bip322_psbt_input_with_pubkeys: (a: number, b: number, c: number, d: number, e: number, f: number, g: number, h: number, i: number, j: number, k: number, l: number) => void;
115
44
  export const bip322namespace_verify_bip322_tx_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) => void;
@@ -178,6 +107,8 @@ export const fixedscriptwalletnamespace_output_script_with_network_str: (a: numb
178
107
  export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b: number, c: number) => void;
179
108
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
180
109
  export const fixedscriptwalletnamespace_to_wallet_keys: (a: number, b: number, c: number, d: number, e: number) => void;
110
+ export const messagenamespace_sign_message: (a: number, b: number, c: number, d: number) => void;
111
+ export const messagenamespace_verify_message: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
181
112
  export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
182
113
  export const wasmbip32_chain_code: (a: number) => number;
183
114
  export const wasmbip32_depth: (a: number) => number;
@@ -217,12 +148,82 @@ export const wasmdimensions_has_segwit: (a: number) => number;
217
148
  export const wasmdimensions_plus: (a: number, b: number) => number;
218
149
  export const wasmdimensions_times: (a: number, b: number) => number;
219
150
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
151
+ export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
220
152
  export const isInspectEnabled: () => number;
221
153
  export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
222
154
  export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
223
155
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
224
156
  export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
225
- export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
157
+ export const __wbg_addressnamespace_free: (a: number, b: number) => void;
158
+ export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
159
+ export const __wbg_wasmecpair_free: (a: number, b: number) => void;
160
+ export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
161
+ export const __wbg_wrappsbt_free: (a: number, b: number) => void;
162
+ export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
163
+ export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
164
+ export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
165
+ export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
166
+ export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
167
+ export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
168
+ export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
169
+ export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
170
+ export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
171
+ export const wasmecpair_private_key: (a: number) => number;
172
+ export const wasmecpair_public_key: (a: number) => number;
173
+ export const wasmecpair_to_wif: (a: number, b: number) => void;
174
+ export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
175
+ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
176
+ export const wrapminiscript_encode: (a: number, b: number) => void;
177
+ export const wrapminiscript_fromBitcoinScript: (a: number, b: number, c: number, d: number, e: number) => void;
178
+ export const wrapminiscript_fromString: (a: number, b: number, c: number, d: number, e: number) => void;
179
+ export const wrapminiscript_node: (a: number, b: number) => void;
180
+ export const wrapminiscript_toAsmString: (a: number, b: number) => void;
181
+ export const wrapminiscript_toString: (a: number, b: number) => void;
182
+ export const wrappsbt_add_input: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
183
+ 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;
184
+ export const wrappsbt_add_output: (a: number, b: number, c: number, d: bigint) => number;
185
+ export const wrappsbt_add_output_at_index: (a: number, b: number, c: number, d: number, e: number, f: bigint) => void;
186
+ export const wrappsbt_clone: (a: number) => number;
187
+ export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
188
+ export const wrappsbt_extract_transaction: (a: number, b: number) => void;
189
+ export const wrappsbt_finalize_mut: (a: number, b: number) => void;
190
+ export const wrappsbt_get_global_xpubs: (a: number) => number;
191
+ export const wrappsbt_get_inputs: (a: number, b: number) => void;
192
+ export const wrappsbt_get_outputs: (a: number, b: number) => void;
193
+ export const wrappsbt_get_outputs_with_address: (a: number, b: number, c: number, d: number) => void;
194
+ export const wrappsbt_get_partial_signatures: (a: number, b: number, c: number) => void;
195
+ export const wrappsbt_get_unsigned_tx: (a: number, b: number) => void;
196
+ export const wrappsbt_has_partial_signatures: (a: number, b: number, c: number) => void;
197
+ export const wrappsbt_input_count: (a: number) => number;
198
+ export const wrappsbt_lock_time: (a: number) => number;
199
+ export const wrappsbt_new: (a: number, b: number) => number;
200
+ export const wrappsbt_output_count: (a: number) => number;
201
+ export const wrappsbt_remove_input: (a: number, b: number, c: number) => void;
202
+ export const wrappsbt_remove_output: (a: number, b: number, c: number) => void;
203
+ export const wrappsbt_serialize: (a: number, b: number) => void;
204
+ export const wrappsbt_sign_all: (a: number, b: number, c: number) => void;
205
+ export const wrappsbt_sign_all_with_ecpair: (a: number, b: number, c: number) => void;
206
+ export const wrappsbt_sign_with_prv: (a: number, b: number, c: number, d: number) => void;
207
+ export const wrappsbt_sign_with_xprv: (a: number, b: number, c: number, d: number) => void;
208
+ export const wrappsbt_unsigned_tx_id: (a: number, b: number) => void;
209
+ export const wrappsbt_update_input_with_descriptor: (a: number, b: number, c: number, d: number) => void;
210
+ export const wrappsbt_update_output_with_descriptor: (a: number, b: number, c: number, d: number) => void;
211
+ export const wrappsbt_validate_signature_at_input: (a: number, b: number, c: number, d: number, e: number) => void;
212
+ export const wrappsbt_verify_signature_with_key: (a: number, b: number, c: number, d: number) => void;
213
+ export const wrappsbt_version: (a: number) => number;
214
+ export const __wbg_inscriptionsnamespace_free: (a: number, b: number) => void;
215
+ export const __wbg_wasmreplayprotection_free: (a: number, b: number) => void;
216
+ export const __wbg_wasmrootwalletkeys_free: (a: number, b: number) => void;
217
+ export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
218
+ 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;
219
+ export const wasmreplayprotection_from_addresses: (a: number, b: number, c: number, d: number, e: number) => void;
220
+ export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
221
+ export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
222
+ export const wasmrootwalletkeys_backup_key: (a: number) => number;
223
+ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
224
+ export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
225
+ export const wasmrootwalletkeys_user_key: (a: number) => number;
226
+ 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;
226
227
  export const rustsecp256k1_v0_10_0_context_create: (a: number) => number;
227
228
  export const rustsecp256k1_v0_10_0_context_destroy: (a: number) => void;
228
229
  export const rustsecp256k1_v0_10_0_default_error_callback_fn: (a: number, b: number) => void;
@@ -106,6 +106,11 @@ export type VerifyBip322TxInputParams = VerifyBip322InputParams & {
106
106
  * ```
107
107
  */
108
108
  export declare function addBip322Input(psbt: BitGoPsbt, params: AddBip322InputParams): number;
109
+ /**
110
+ * Get the BIP322 message stored at a PSBT input index.
111
+ * Returns null if no message is stored.
112
+ */
113
+ export declare function getBip322Message(psbt: BitGoPsbt, inputIndex: number): string | null;
109
114
  /**
110
115
  * Verify a single input of a BIP-0322 transaction proof
111
116
  *
@@ -68,6 +68,13 @@ export function addBip322Input(psbt, params) {
68
68
  const keys = RootWalletKeys.from(params.rootWalletKeys);
69
69
  return Bip322Namespace.add_bip322_input(psbt.wasm, params.message, params.scriptId.chain, params.scriptId.index, keys.wasm, params.signPath?.signer, params.signPath?.cosigner, params.tag);
70
70
  }
71
+ /**
72
+ * Get the BIP322 message stored at a PSBT input index.
73
+ * Returns null if no message is stored.
74
+ */
75
+ export function getBip322Message(psbt, inputIndex) {
76
+ return Bip322Namespace.get_bip322_message(psbt.wasm, inputIndex) ?? null;
77
+ }
71
78
  /**
72
79
  * Verify a single input of a BIP-0322 transaction proof
73
80
  *
@@ -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;
@@ -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
+ }
@@ -40,4 +40,5 @@ export * from "./DescriptorOutput.js";
40
40
  export * from "./address.js";
41
41
  export * from "./VirtualSize.js";
42
42
  export * from "./psbt/index.js";
43
+ export { Psbt, type SignPsbtResult } from "./Psbt.js";
43
44
  export * from "./parse/PatternMatcher.js";
@@ -42,5 +42,7 @@ export * from "./address.js";
42
42
  export * from "./VirtualSize.js";
43
43
  // PSBT utilities
44
44
  export * from "./psbt/index.js";
45
+ // PSBT wrapper
46
+ export { Psbt } from "./Psbt.js";
45
47
  // Pattern matching
46
48
  export * from "./parse/PatternMatcher.js";
@@ -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,36 +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
- getGlobalXpubs(): WasmBIP32[];
78
- getPartialSignatures(inputIndex: number): Array<{
79
- pubkey: Uint8Array;
80
- signature: Uint8Array;
81
- }>;
82
- hasPartialSignatures(inputIndex: number): boolean;
83
- validateSignatureAtInput(inputIndex: number, pubkey: Uint8Array): boolean;
84
- verifySignatureWithKey(inputIndex: number, key: WasmBIP32): boolean;
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;
90
- unsignedTxId(): string;
91
- lockTime(): number;
92
- version(): number;
93
- }
94
64
  }
95
65
  export { WrapDescriptor as Descriptor } from "./wasm/wasm_utxo.js";
96
66
  export { WrapMiniscript as Miniscript } from "./wasm/wasm_utxo.js";
97
- export { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
67
+ export { Psbt } from "./descriptorWallet/Psbt.js";
98
68
  export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
99
69
  export { hasPsbtMagic, type IPsbt, type IPsbtWithAddress } from "./psbt.js";
@@ -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 { WrapPsbt as Psbt } from "./wasm/wasm_utxo.js";
24
+ export { Psbt } from "./descriptorWallet/Psbt.js";
25
25
  export { DashTransaction, Transaction, ZcashTransaction } from "./transaction.js";
26
26
  export { hasPsbtMagic } from "./psbt.js";
@@ -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 network: CoinName;
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(network: CoinName, signStage: SignStage, txFormat: TxFormat, rootWalletKeys: RootWalletKeys, otherWalletKeys: RootWalletKeys, inputs: Input[], outputs: Output[], xprvTriple: Triple<BIP32>);
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(network: CoinName, signStage: SignStage, txFormat: TxFormat, suiteConfig?: SuiteConfig): AcidTest;
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
  */