@bitgo/wasm-utxo 1.43.0 → 1.44.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.
@@ -10,6 +10,79 @@ export const wasmrootwalletkeys_bitgo_key: (a: number) => number;
10
10
  export const wasmrootwalletkeys_new: (a: number, b: number, c: number, d: number) => void;
11
11
  export const wasmrootwalletkeys_user_key: (a: number) => number;
12
12
  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;
13
+ export const __wbg_addressnamespace_free: (a: number, b: number) => void;
14
+ export const __wbg_wasmecpair_free: (a: number, b: number) => void;
15
+ export const __wbg_wrappsbt_free: (a: number, b: number) => void;
16
+ export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
17
+ export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
18
+ export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
19
+ export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
20
+ export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
21
+ export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
22
+ export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
23
+ export const wasmecpair_private_key: (a: number) => number;
24
+ export const wasmecpair_public_key: (a: number) => number;
25
+ export const wasmecpair_to_wif: (a: number, b: number) => void;
26
+ export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
27
+ export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
28
+ export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
29
+ export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
30
+ export const wrappsbt_clone: (a: number) => number;
31
+ export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
32
+ export const wrappsbt_extractTransaction: (a: number, b: number) => void;
33
+ export const wrappsbt_finalize: (a: number, b: number) => void;
34
+ export const wrappsbt_getInputs: (a: number, b: number) => void;
35
+ export const wrappsbt_getOutputs: (a: number, b: number) => void;
36
+ export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
37
+ export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
38
+ export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
39
+ export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
40
+ export const wrappsbt_inputCount: (a: number) => number;
41
+ export const wrappsbt_lockTime: (a: number) => number;
42
+ export const wrappsbt_new: (a: number, b: number) => number;
43
+ export const wrappsbt_outputCount: (a: number) => number;
44
+ export const wrappsbt_serialize: (a: number, b: number) => void;
45
+ export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
46
+ export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
47
+ export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
48
+ export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
49
+ export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
50
+ export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
51
+ export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
52
+ export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
53
+ export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
54
+ export const wrappsbt_version: (a: number) => number;
55
+ export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
56
+ export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
57
+ export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
58
+ export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
59
+ export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
60
+ export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
61
+ export const wasmdimensions_empty: () => number;
62
+ export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
63
+ export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number, d: number) => void;
64
+ export const wasmdimensions_from_output_script_length: (a: number) => number;
65
+ export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
66
+ export const wasmdimensions_from_psbt: (a: number, b: number) => void;
67
+ export const wasmdimensions_get_input_vsize: (a: number, b: number, c: number) => number;
68
+ export const wasmdimensions_get_input_weight: (a: number, b: number, c: number) => number;
69
+ export const wasmdimensions_get_output_vsize: (a: number) => number;
70
+ export const wasmdimensions_get_output_weight: (a: number) => number;
71
+ export const wasmdimensions_get_vsize: (a: number, b: number, c: number) => number;
72
+ export const wasmdimensions_get_weight: (a: number, b: number, c: number) => number;
73
+ export const wasmdimensions_has_segwit: (a: number) => number;
74
+ export const wasmdimensions_plus: (a: number, b: number) => number;
75
+ export const wasmdimensions_times: (a: number, b: number) => number;
76
+ export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
77
+ export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
78
+ export const wasmtransaction_create: () => number;
79
+ export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
80
+ export const wasmtransaction_get_txid: (a: number, b: number) => void;
81
+ export const wasmtransaction_get_vsize: (a: number) => number;
82
+ export const wasmtransaction_to_bytes: (a: number, b: number) => void;
83
+ export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
84
+ export const wasmzcashtransaction_get_txid: (a: number, b: number) => void;
85
+ export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
13
86
  export const __wbg_bip322namespace_free: (a: number, b: number) => void;
14
87
  export const __wbg_bitgopsbt_free: (a: number, b: number) => void;
15
88
  export const __wbg_fixedscriptwalletnamespace_free: (a: number, b: number) => void;
@@ -78,6 +151,8 @@ export const fixedscriptwalletnamespace_p2sh_p2pk_output_script: (a: number, b:
78
151
  export const fixedscriptwalletnamespace_supports_script_type: (a: number, b: number, c: number, d: number, e: number) => void;
79
152
  export const inscriptionsnamespace_create_inscription_reveal_data: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
80
153
  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;
154
+ export const isInspectEnabled: () => number;
155
+ export const parsePsbtRawToJson: (a: number, b: number, c: number, d: number, e: number) => void;
81
156
  export const wasmbip32_chain_code: (a: number) => number;
82
157
  export const wasmbip32_depth: (a: number) => number;
83
158
  export const wasmbip32_derive: (a: number, b: number, c: number) => void;
@@ -107,82 +182,11 @@ export const wasmreplayprotection_from_addresses: (a: number, b: number, c: numb
107
182
  export const wasmreplayprotection_from_output_scripts: (a: number, b: number) => number;
108
183
  export const wasmreplayprotection_from_public_keys: (a: number, b: number, c: number) => void;
109
184
  export const wasmbip32_from_bip32_properties: (a: number, b: number) => void;
185
+ export const parsePsbtToJson: (a: number, b: number, c: number, d: number, e: number) => void;
186
+ export const parseTxToJson: (a: number, b: number, c: number, d: number, e: number) => void;
110
187
  export const bitgopsbt_sign_wallet_input: (a: number, b: number, c: number, d: number) => void;
111
188
  export const bitgopsbt_sign_all_with_xpriv: (a: number, b: number, c: number) => void;
112
189
  export const bitgopsbt_sign_replay_protection_inputs: (a: number, b: number, c: number) => void;
113
- export const __wbg_utxolibcompatnamespace_free: (a: number, b: number) => void;
114
- export const __wbg_wasmdimensions_free: (a: number, b: number) => void;
115
- export const __wbg_wasmtransaction_free: (a: number, b: number) => void;
116
- export const __wbg_wasmzcashtransaction_free: (a: number, b: number) => void;
117
- export const utxolibcompatnamespace_from_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
118
- export const utxolibcompatnamespace_to_output_script: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
119
- export const wasmdimensions_empty: () => number;
120
- export const wasmdimensions_from_input: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
121
- export const wasmdimensions_from_input_script_type: (a: number, b: number, c: number, d: number) => void;
122
- export const wasmdimensions_from_output_script_length: (a: number) => number;
123
- export const wasmdimensions_from_output_script_type: (a: number, b: number, c: number) => void;
124
- export const wasmdimensions_from_psbt: (a: number, b: number) => void;
125
- export const wasmdimensions_get_input_vsize: (a: number, b: number, c: number) => number;
126
- export const wasmdimensions_get_input_weight: (a: number, b: number, c: number) => number;
127
- export const wasmdimensions_get_output_vsize: (a: number) => number;
128
- export const wasmdimensions_get_output_weight: (a: number) => number;
129
- export const wasmdimensions_get_vsize: (a: number, b: number, c: number) => number;
130
- export const wasmdimensions_get_weight: (a: number, b: number, c: number) => number;
131
- export const wasmdimensions_has_segwit: (a: number) => number;
132
- export const wasmdimensions_plus: (a: number, b: number) => number;
133
- export const wasmdimensions_times: (a: number, b: number) => number;
134
- export const wasmtransaction_add_input: (a: number, b: number, c: number, d: number, e: number, f: number) => void;
135
- export const wasmtransaction_add_output: (a: number, b: number, c: number, d: bigint) => number;
136
- export const wasmtransaction_create: () => number;
137
- export const wasmtransaction_from_bytes: (a: number, b: number, c: number) => void;
138
- export const wasmtransaction_get_txid: (a: number, b: number) => void;
139
- export const wasmtransaction_get_vsize: (a: number) => number;
140
- export const wasmtransaction_to_bytes: (a: number, b: number) => void;
141
- export const wasmzcashtransaction_from_bytes: (a: number, b: number, c: number) => void;
142
- export const wasmzcashtransaction_get_txid: (a: number, b: number) => void;
143
- export const wasmzcashtransaction_to_bytes: (a: number, b: number) => void;
144
- export const __wbg_addressnamespace_free: (a: number, b: number) => void;
145
- export const __wbg_wasmecpair_free: (a: number, b: number) => void;
146
- export const __wbg_wrappsbt_free: (a: number, b: number) => void;
147
- export const addressnamespace_from_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number, f: number, g: number) => void;
148
- export const addressnamespace_to_output_script_with_coin: (a: number, b: number, c: number, d: number, e: number) => void;
149
- export const wasmecpair_from_private_key: (a: number, b: number, c: number) => void;
150
- export const wasmecpair_from_public_key: (a: number, b: number, c: number) => void;
151
- export const wasmecpair_from_wif: (a: number, b: number, c: number) => void;
152
- export const wasmecpair_from_wif_mainnet: (a: number, b: number, c: number) => void;
153
- export const wasmecpair_from_wif_testnet: (a: number, b: number, c: number) => void;
154
- export const wasmecpair_private_key: (a: number) => number;
155
- export const wasmecpair_public_key: (a: number) => number;
156
- export const wasmecpair_to_wif: (a: number, b: number) => void;
157
- export const wasmecpair_to_wif_mainnet: (a: number, b: number) => void;
158
- export const wasmecpair_to_wif_testnet: (a: number, b: number) => void;
159
- export const wrappsbt_addInput: (a: number, b: number, c: number, d: number, e: number, f: bigint, g: number, h: number, i: number) => void;
160
- export const wrappsbt_addOutput: (a: number, b: number, c: number, d: bigint) => number;
161
- export const wrappsbt_clone: (a: number) => number;
162
- export const wrappsbt_deserialize: (a: number, b: number, c: number) => void;
163
- export const wrappsbt_extractTransaction: (a: number, b: number) => void;
164
- export const wrappsbt_finalize: (a: number, b: number) => void;
165
- export const wrappsbt_getInputs: (a: number, b: number) => void;
166
- export const wrappsbt_getOutputs: (a: number, b: number) => void;
167
- export const wrappsbt_getOutputsWithAddress: (a: number, b: number, c: number, d: number) => void;
168
- export const wrappsbt_getPartialSignatures: (a: number, b: number, c: number) => void;
169
- export const wrappsbt_getUnsignedTx: (a: number, b: number) => void;
170
- export const wrappsbt_hasPartialSignatures: (a: number, b: number, c: number) => void;
171
- export const wrappsbt_inputCount: (a: number) => number;
172
- export const wrappsbt_lockTime: (a: number) => number;
173
- export const wrappsbt_new: (a: number, b: number) => number;
174
- export const wrappsbt_outputCount: (a: number) => number;
175
- export const wrappsbt_serialize: (a: number, b: number) => void;
176
- export const wrappsbt_signAll: (a: number, b: number, c: number) => void;
177
- export const wrappsbt_signAllWithEcpair: (a: number, b: number, c: number) => void;
178
- export const wrappsbt_signWithPrv: (a: number, b: number, c: number, d: number) => void;
179
- export const wrappsbt_signWithXprv: (a: number, b: number, c: number, d: number) => void;
180
- export const wrappsbt_unsignedTxId: (a: number, b: number) => void;
181
- export const wrappsbt_updateInputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
182
- export const wrappsbt_updateOutputWithDescriptor: (a: number, b: number, c: number, d: number) => void;
183
- export const wrappsbt_validateSignatureAtInput: (a: number, b: number, c: number, d: number, e: number) => void;
184
- export const wrappsbt_verifySignatureWithKey: (a: number, b: number, c: number, d: number) => void;
185
- export const wrappsbt_version: (a: number) => number;
186
190
  export const __wbg_wrapdescriptor_free: (a: number, b: number) => void;
187
191
  export const __wbg_wrapminiscript_free: (a: number, b: number) => void;
188
192
  export const wrapdescriptor_atDerivationIndex: (a: number, b: number, c: number) => void;
@@ -0,0 +1,105 @@
1
+ /**
2
+ * Inspect - TypeScript bindings for PSBT and Transaction parsing
3
+ *
4
+ * Provides typed wrappers around the WASM inspect functions that return
5
+ * hierarchical node structures suitable for display as collapsible trees.
6
+ *
7
+ * Import via: `import { ... } from "@bitgo/wasm-utxo/inspect"`
8
+ */
9
+ import type { CoinName } from "../coinName.js";
10
+ /** Re-export CoinName for convenience */
11
+ export type { CoinName };
12
+ /** All supported networks in order of parsing priority */
13
+ export declare const allNetworks: CoinName[];
14
+ /**
15
+ * Primitive value types that can appear in a Node.
16
+ * Buffer values are hex-encoded strings, Integer is a decimal string for BigInt support.
17
+ */
18
+ export type PrimitiveType = "String" | "Buffer" | "Integer" | "U8" | "U16" | "U32" | "U64" | "I8" | "I16" | "I32" | "I64" | "Boolean" | "None";
19
+ /**
20
+ * A tagged union representing primitive values in the parse tree.
21
+ */
22
+ export interface Primitive {
23
+ type: PrimitiveType;
24
+ value?: string | number | boolean;
25
+ }
26
+ /**
27
+ * A node in the parse tree representing a PSBT or transaction element.
28
+ */
29
+ export interface Node {
30
+ label: string;
31
+ value: Primitive;
32
+ children: Node[];
33
+ }
34
+ /**
35
+ * Parse a PSBT and return a typed node tree.
36
+ *
37
+ * @param psbtBytes - The raw PSBT bytes
38
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
39
+ * @returns A Node tree representing the parsed PSBT structure
40
+ * @throws If the PSBT bytes are invalid or network is unknown
41
+ */
42
+ export declare function parsePsbtToNode(psbtBytes: Uint8Array, network: CoinName): Node;
43
+ /**
44
+ * Parse a transaction and return a typed node tree.
45
+ *
46
+ * @param txBytes - The raw transaction bytes
47
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
48
+ * @returns A Node tree representing the parsed transaction structure
49
+ * @throws If the transaction bytes are invalid or network is unknown
50
+ */
51
+ export declare function parseTxToNode(txBytes: Uint8Array, network: CoinName): Node;
52
+ /**
53
+ * Try to parse a PSBT with all networks and return the first one that succeeds.
54
+ *
55
+ * @param psbtBytes - The raw PSBT bytes
56
+ * @param networks - Optional list of networks to try (defaults to all networks)
57
+ * @returns An object with the parsed Node and detected network, or null if all fail
58
+ */
59
+ export declare function tryParsePsbt(psbtBytes: Uint8Array, networks?: CoinName[]): {
60
+ node: Node;
61
+ network: CoinName;
62
+ } | null;
63
+ /**
64
+ * Try to parse a transaction with all networks and return the first one that succeeds.
65
+ *
66
+ * @param txBytes - The raw transaction bytes
67
+ * @param networks - Optional list of networks to try (defaults to all networks)
68
+ * @returns An object with the parsed Node and detected network, or null if all fail
69
+ */
70
+ export declare function tryParseTx(txBytes: Uint8Array, networks?: CoinName[]): {
71
+ node: Node;
72
+ network: CoinName;
73
+ } | null;
74
+ /**
75
+ * Parse a PSBT at the raw byte level and return a typed node tree.
76
+ *
77
+ * Unlike `parsePsbtToNode`, this function exposes the raw key-value pair
78
+ * structure as defined in BIP-174, showing:
79
+ * - Raw key type IDs and their human-readable names
80
+ * - Proprietary keys with their structured format
81
+ * - Unknown/unrecognized keys that standard parsers might skip
82
+ *
83
+ * @param psbtBytes - The raw PSBT bytes
84
+ * @param network - The network coin name (e.g., "btc", "ltc", "zec")
85
+ * @returns A Node tree representing the raw PSBT key-value structure
86
+ * @throws If the PSBT bytes are invalid or network is unknown
87
+ */
88
+ export declare function parsePsbtRawToNode(psbtBytes: Uint8Array, network: CoinName): Node;
89
+ /**
90
+ * Try to parse a raw PSBT with all networks and return the first one that succeeds.
91
+ *
92
+ * @param psbtBytes - The raw PSBT bytes
93
+ * @param networks - Optional list of networks to try (defaults to all networks)
94
+ * @returns An object with the parsed Node and detected network, or null if all fail
95
+ */
96
+ export declare function tryParsePsbtRaw(psbtBytes: Uint8Array, networks?: CoinName[]): {
97
+ node: Node;
98
+ network: CoinName;
99
+ } | null;
100
+ /**
101
+ * Check if the inspect feature is enabled in the WASM build.
102
+ *
103
+ * @returns true if the feature is enabled, false otherwise
104
+ */
105
+ export declare function isInspectEnabled(): boolean;
@@ -0,0 +1,140 @@
1
+ /**
2
+ * Inspect - TypeScript bindings for PSBT and Transaction parsing
3
+ *
4
+ * Provides typed wrappers around the WASM inspect functions that return
5
+ * hierarchical node structures suitable for display as collapsible trees.
6
+ *
7
+ * Import via: `import { ... } from "@bitgo/wasm-utxo/inspect"`
8
+ */
9
+ import { parsePsbtToJson as wasmParsePsbtToJson, parseTxToJson as wasmParseTxToJson, parsePsbtRawToJson as wasmParsePsbtRawToJson, isInspectEnabled as wasmIsInspectEnabled, } from "../wasm/wasm_utxo.js";
10
+ /** All supported networks in order of parsing priority */
11
+ export const allNetworks = [
12
+ "btc",
13
+ "tbtc",
14
+ "tbtc4",
15
+ "tbtcsig",
16
+ "tbtcbgsig",
17
+ "ltc",
18
+ "tltc",
19
+ "bch",
20
+ "tbch",
21
+ "bcha",
22
+ "tbcha",
23
+ "btg",
24
+ "tbtg",
25
+ "bsv",
26
+ "tbsv",
27
+ "dash",
28
+ "tdash",
29
+ "doge",
30
+ "tdoge",
31
+ "zec",
32
+ "tzec",
33
+ ];
34
+ /**
35
+ * Parse a PSBT and return a typed node tree.
36
+ *
37
+ * @param psbtBytes - The raw PSBT bytes
38
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
39
+ * @returns A Node tree representing the parsed PSBT structure
40
+ * @throws If the PSBT bytes are invalid or network is unknown
41
+ */
42
+ export function parsePsbtToNode(psbtBytes, network) {
43
+ const json = wasmParsePsbtToJson(psbtBytes, network);
44
+ return JSON.parse(json);
45
+ }
46
+ /**
47
+ * Parse a transaction and return a typed node tree.
48
+ *
49
+ * @param txBytes - The raw transaction bytes
50
+ * @param network - The network coin name (e.g., "btc", "ltc", "bch")
51
+ * @returns A Node tree representing the parsed transaction structure
52
+ * @throws If the transaction bytes are invalid or network is unknown
53
+ */
54
+ export function parseTxToNode(txBytes, network) {
55
+ const json = wasmParseTxToJson(txBytes, network);
56
+ return JSON.parse(json);
57
+ }
58
+ /**
59
+ * Try to parse a PSBT with all networks and return the first one that succeeds.
60
+ *
61
+ * @param psbtBytes - The raw PSBT bytes
62
+ * @param networks - Optional list of networks to try (defaults to all networks)
63
+ * @returns An object with the parsed Node and detected network, or null if all fail
64
+ */
65
+ export function tryParsePsbt(psbtBytes, networks = allNetworks) {
66
+ for (const network of networks) {
67
+ try {
68
+ const node = parsePsbtToNode(psbtBytes, network);
69
+ return { node, network };
70
+ }
71
+ catch {
72
+ // Try next network
73
+ }
74
+ }
75
+ return null;
76
+ }
77
+ /**
78
+ * Try to parse a transaction with all networks and return the first one that succeeds.
79
+ *
80
+ * @param txBytes - The raw transaction bytes
81
+ * @param networks - Optional list of networks to try (defaults to all networks)
82
+ * @returns An object with the parsed Node and detected network, or null if all fail
83
+ */
84
+ export function tryParseTx(txBytes, networks = allNetworks) {
85
+ for (const network of networks) {
86
+ try {
87
+ const node = parseTxToNode(txBytes, network);
88
+ return { node, network };
89
+ }
90
+ catch {
91
+ // Try next network
92
+ }
93
+ }
94
+ return null;
95
+ }
96
+ /**
97
+ * Parse a PSBT at the raw byte level and return a typed node tree.
98
+ *
99
+ * Unlike `parsePsbtToNode`, this function exposes the raw key-value pair
100
+ * structure as defined in BIP-174, showing:
101
+ * - Raw key type IDs and their human-readable names
102
+ * - Proprietary keys with their structured format
103
+ * - Unknown/unrecognized keys that standard parsers might skip
104
+ *
105
+ * @param psbtBytes - The raw PSBT bytes
106
+ * @param network - The network coin name (e.g., "btc", "ltc", "zec")
107
+ * @returns A Node tree representing the raw PSBT key-value structure
108
+ * @throws If the PSBT bytes are invalid or network is unknown
109
+ */
110
+ export function parsePsbtRawToNode(psbtBytes, network) {
111
+ const json = wasmParsePsbtRawToJson(psbtBytes, network);
112
+ return JSON.parse(json);
113
+ }
114
+ /**
115
+ * Try to parse a raw PSBT with all networks and return the first one that succeeds.
116
+ *
117
+ * @param psbtBytes - The raw PSBT bytes
118
+ * @param networks - Optional list of networks to try (defaults to all networks)
119
+ * @returns An object with the parsed Node and detected network, or null if all fail
120
+ */
121
+ export function tryParsePsbtRaw(psbtBytes, networks = allNetworks) {
122
+ for (const network of networks) {
123
+ try {
124
+ const node = parsePsbtRawToNode(psbtBytes, network);
125
+ return { node, network };
126
+ }
127
+ catch {
128
+ // Try next network
129
+ }
130
+ }
131
+ return null;
132
+ }
133
+ /**
134
+ * Check if the inspect feature is enabled in the WASM build.
135
+ *
136
+ * @returns true if the feature is enabled, false otherwise
137
+ */
138
+ export function isInspectEnabled() {
139
+ return wasmIsInspectEnabled();
140
+ }
@@ -1534,3 +1534,74 @@ export class WrapPsbt {
1534
1534
  */
1535
1535
  version(): number;
1536
1536
  }
1537
+
1538
+ /**
1539
+ * Check if the inspect feature is enabled.
1540
+ *
1541
+ * # Returns
1542
+ * `true` if the feature is enabled, `false` otherwise
1543
+ */
1544
+ export function isInspectEnabled(): boolean;
1545
+
1546
+ /**
1547
+ * Parse a PSBT at the raw byte level and return a JSON representation.
1548
+ *
1549
+ * Unlike `parsePsbtToJson`, this function exposes the raw key-value pair
1550
+ * structure as defined in BIP-174, showing:
1551
+ * - Raw key type IDs and their human-readable names
1552
+ * - Proprietary keys with their structured format
1553
+ * - Unknown/unrecognized keys that standard parsers might skip
1554
+ *
1555
+ * # Arguments
1556
+ * * `psbt_bytes` - The raw PSBT bytes
1557
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "zec")
1558
+ *
1559
+ * # Returns
1560
+ * A JSON string representing the raw PSBT key-value structure
1561
+ *
1562
+ * # Errors
1563
+ * Returns an error if:
1564
+ * - The `inspect` feature is not enabled
1565
+ * - The PSBT bytes are invalid
1566
+ * - The network name is unknown
1567
+ */
1568
+ export function parsePsbtRawToJson(psbt_bytes: Uint8Array, coin_name: string): string;
1569
+
1570
+ /**
1571
+ * Parse a PSBT and return a JSON representation of its structure.
1572
+ *
1573
+ * This function parses the PSBT using the standard bitcoin crate parser
1574
+ * and returns a hierarchical node structure suitable for display.
1575
+ *
1576
+ * # Arguments
1577
+ * * `psbt_bytes` - The raw PSBT bytes
1578
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
1579
+ *
1580
+ * # Returns
1581
+ * A JSON string representing the parsed PSBT structure
1582
+ *
1583
+ * # Errors
1584
+ * Returns an error if:
1585
+ * - The `inspect` feature is not enabled
1586
+ * - The PSBT bytes are invalid
1587
+ * - The network name is unknown
1588
+ */
1589
+ export function parsePsbtToJson(psbt_bytes: Uint8Array, coin_name: string): string;
1590
+
1591
+ /**
1592
+ * Parse a transaction and return a JSON representation of its structure.
1593
+ *
1594
+ * # Arguments
1595
+ * * `tx_bytes` - The raw transaction bytes
1596
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
1597
+ *
1598
+ * # Returns
1599
+ * A JSON string representing the parsed transaction structure
1600
+ *
1601
+ * # Errors
1602
+ * Returns an error if:
1603
+ * - The `inspect` feature is not enabled
1604
+ * - The transaction bytes are invalid
1605
+ * - The network name is unknown
1606
+ */
1607
+ export function parseTxToJson(tx_bytes: Uint8Array, coin_name: string): string;
@@ -5,5 +5,5 @@ import { __wbg_set_wasm } from "./wasm_utxo_bg.js";
5
5
  __wbg_set_wasm(wasm);
6
6
 
7
7
  export {
8
- AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt
8
+ AddressNamespace, Bip322Namespace, BitGoPsbt, FixedScriptWalletNamespace, InscriptionsNamespace, MessageNamespace, UtxolibCompatNamespace, WasmBIP32, WasmDashTransaction, WasmDimensions, WasmECPair, WasmReplayProtection, WasmRootWalletKeys, WasmTransaction, WasmZcashTransaction, WrapDescriptor, WrapMiniscript, WrapPsbt, isInspectEnabled, parsePsbtRawToJson, parsePsbtToJson, parseTxToJson
9
9
  } from "./wasm_utxo_bg.js";
@@ -4757,6 +4757,171 @@ export class WrapPsbt {
4757
4757
  }
4758
4758
  }
4759
4759
  if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
4760
+
4761
+ /**
4762
+ * Check if the inspect feature is enabled.
4763
+ *
4764
+ * # Returns
4765
+ * `true` if the feature is enabled, `false` otherwise
4766
+ * @returns {boolean}
4767
+ */
4768
+ export function isInspectEnabled() {
4769
+ const ret = wasm.isInspectEnabled();
4770
+ return ret !== 0;
4771
+ }
4772
+
4773
+ /**
4774
+ * Parse a PSBT at the raw byte level and return a JSON representation.
4775
+ *
4776
+ * Unlike `parsePsbtToJson`, this function exposes the raw key-value pair
4777
+ * structure as defined in BIP-174, showing:
4778
+ * - Raw key type IDs and their human-readable names
4779
+ * - Proprietary keys with their structured format
4780
+ * - Unknown/unrecognized keys that standard parsers might skip
4781
+ *
4782
+ * # Arguments
4783
+ * * `psbt_bytes` - The raw PSBT bytes
4784
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "zec")
4785
+ *
4786
+ * # Returns
4787
+ * A JSON string representing the raw PSBT key-value structure
4788
+ *
4789
+ * # Errors
4790
+ * Returns an error if:
4791
+ * - The `inspect` feature is not enabled
4792
+ * - The PSBT bytes are invalid
4793
+ * - The network name is unknown
4794
+ * @param {Uint8Array} psbt_bytes
4795
+ * @param {string} coin_name
4796
+ * @returns {string}
4797
+ */
4798
+ export function parsePsbtRawToJson(psbt_bytes, coin_name) {
4799
+ let deferred4_0;
4800
+ let deferred4_1;
4801
+ try {
4802
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4803
+ const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
4804
+ const len0 = WASM_VECTOR_LEN;
4805
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4806
+ const len1 = WASM_VECTOR_LEN;
4807
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4808
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4809
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4810
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4811
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4812
+ var ptr3 = r0;
4813
+ var len3 = r1;
4814
+ if (r3) {
4815
+ ptr3 = 0; len3 = 0;
4816
+ throw takeObject(r2);
4817
+ }
4818
+ deferred4_0 = ptr3;
4819
+ deferred4_1 = len3;
4820
+ return getStringFromWasm0(ptr3, len3);
4821
+ } finally {
4822
+ wasm.__wbindgen_add_to_stack_pointer(16);
4823
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4824
+ }
4825
+ }
4826
+
4827
+ /**
4828
+ * Parse a PSBT and return a JSON representation of its structure.
4829
+ *
4830
+ * This function parses the PSBT using the standard bitcoin crate parser
4831
+ * and returns a hierarchical node structure suitable for display.
4832
+ *
4833
+ * # Arguments
4834
+ * * `psbt_bytes` - The raw PSBT bytes
4835
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
4836
+ *
4837
+ * # Returns
4838
+ * A JSON string representing the parsed PSBT structure
4839
+ *
4840
+ * # Errors
4841
+ * Returns an error if:
4842
+ * - The `inspect` feature is not enabled
4843
+ * - The PSBT bytes are invalid
4844
+ * - The network name is unknown
4845
+ * @param {Uint8Array} psbt_bytes
4846
+ * @param {string} coin_name
4847
+ * @returns {string}
4848
+ */
4849
+ export function parsePsbtToJson(psbt_bytes, coin_name) {
4850
+ let deferred4_0;
4851
+ let deferred4_1;
4852
+ try {
4853
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4854
+ const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
4855
+ const len0 = WASM_VECTOR_LEN;
4856
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4857
+ const len1 = WASM_VECTOR_LEN;
4858
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4859
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4860
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4861
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4862
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4863
+ var ptr3 = r0;
4864
+ var len3 = r1;
4865
+ if (r3) {
4866
+ ptr3 = 0; len3 = 0;
4867
+ throw takeObject(r2);
4868
+ }
4869
+ deferred4_0 = ptr3;
4870
+ deferred4_1 = len3;
4871
+ return getStringFromWasm0(ptr3, len3);
4872
+ } finally {
4873
+ wasm.__wbindgen_add_to_stack_pointer(16);
4874
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4875
+ }
4876
+ }
4877
+
4878
+ /**
4879
+ * Parse a transaction and return a JSON representation of its structure.
4880
+ *
4881
+ * # Arguments
4882
+ * * `tx_bytes` - The raw transaction bytes
4883
+ * * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
4884
+ *
4885
+ * # Returns
4886
+ * A JSON string representing the parsed transaction structure
4887
+ *
4888
+ * # Errors
4889
+ * Returns an error if:
4890
+ * - The `inspect` feature is not enabled
4891
+ * - The transaction bytes are invalid
4892
+ * - The network name is unknown
4893
+ * @param {Uint8Array} tx_bytes
4894
+ * @param {string} coin_name
4895
+ * @returns {string}
4896
+ */
4897
+ export function parseTxToJson(tx_bytes, coin_name) {
4898
+ let deferred4_0;
4899
+ let deferred4_1;
4900
+ try {
4901
+ const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
4902
+ const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_export);
4903
+ const len0 = WASM_VECTOR_LEN;
4904
+ const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
4905
+ const len1 = WASM_VECTOR_LEN;
4906
+ wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
4907
+ var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
4908
+ var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
4909
+ var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
4910
+ var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
4911
+ var ptr3 = r0;
4912
+ var len3 = r1;
4913
+ if (r3) {
4914
+ ptr3 = 0; len3 = 0;
4915
+ throw takeObject(r2);
4916
+ }
4917
+ deferred4_0 = ptr3;
4918
+ deferred4_1 = len3;
4919
+ return getStringFromWasm0(ptr3, len3);
4920
+ } finally {
4921
+ wasm.__wbindgen_add_to_stack_pointer(16);
4922
+ wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
4923
+ }
4924
+ }
4760
4925
  export function __wbg_Error_8c4e43fe74559d73(arg0, arg1) {
4761
4926
  const ret = Error(getStringFromWasm0(arg0, arg1));
4762
4927
  return addHeapObject(ret);
Binary file