@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.
- package/README.md +30 -0
- package/dist/cjs/js/inspect/index.d.ts +105 -0
- package/dist/cjs/js/inspect/index.js +150 -0
- package/dist/cjs/js/wasm/wasm_utxo.d.ts +71 -0
- package/dist/cjs/js/wasm/wasm_utxo.js +169 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/cjs/js/wasm/wasm_utxo_bg.wasm.d.ts +77 -73
- package/dist/esm/js/inspect/index.d.ts +105 -0
- package/dist/esm/js/inspect/index.js +140 -0
- package/dist/esm/js/wasm/wasm_utxo.d.ts +71 -0
- package/dist/esm/js/wasm/wasm_utxo.js +1 -1
- package/dist/esm/js/wasm/wasm_utxo_bg.js +165 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm +0 -0
- package/dist/esm/js/wasm/wasm_utxo_bg.wasm.d.ts +77 -73
- package/package.json +18 -1
package/README.md
CHANGED
|
@@ -31,6 +31,36 @@ Zcash support includes:
|
|
|
31
31
|
- **Height-Based API**: Preferred `createEmpty()` method automatically selects correct consensus rules
|
|
32
32
|
- **Parity Testing**: Validated against `zebra-chain` for accuracy across all network upgrades
|
|
33
33
|
|
|
34
|
+
## Inspect Feature
|
|
35
|
+
|
|
36
|
+
The `inspect` feature adds PSBT and transaction parsing into hierarchical node trees,
|
|
37
|
+
useful for building tree-view UIs and CLI formatters.
|
|
38
|
+
|
|
39
|
+
It is behind a Cargo feature flag because it pulls in extra dependencies (`serde`, `serde_json`,
|
|
40
|
+
`num-bigint`, `hex`) that are not needed for core wallet operations.
|
|
41
|
+
|
|
42
|
+
### Rust
|
|
43
|
+
|
|
44
|
+
```rust
|
|
45
|
+
// Cargo.toml
|
|
46
|
+
wasm-utxo = { path = ".", features = ["inspect"] }
|
|
47
|
+
|
|
48
|
+
// Usage
|
|
49
|
+
use wasm_utxo::inspect::{parse_psbt_bytes_with_network, parse_tx_bytes_with_network, Node};
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### TypeScript
|
|
53
|
+
|
|
54
|
+
Available as a separate import path, not included in the main `@bitgo/wasm-utxo` entry:
|
|
55
|
+
|
|
56
|
+
```typescript
|
|
57
|
+
import { parsePsbtToNode, parseTxToNode, isInspectEnabled } from "@bitgo/wasm-utxo/inspect";
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
The published npm package includes stub implementations that return `isInspectEnabled() === false`
|
|
61
|
+
and throw runtime errors from the parse functions. To get a working build, compile the WASM with
|
|
62
|
+
`--features inspect` (see [`packages/webui/scripts/build-wasm.sh`](../webui/scripts/build-wasm.sh)).
|
|
63
|
+
|
|
34
64
|
## Building
|
|
35
65
|
|
|
36
66
|
### Mac
|
|
@@ -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,150 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Inspect - TypeScript bindings for PSBT and Transaction parsing
|
|
4
|
+
*
|
|
5
|
+
* Provides typed wrappers around the WASM inspect functions that return
|
|
6
|
+
* hierarchical node structures suitable for display as collapsible trees.
|
|
7
|
+
*
|
|
8
|
+
* Import via: `import { ... } from "@bitgo/wasm-utxo/inspect"`
|
|
9
|
+
*/
|
|
10
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
11
|
+
exports.allNetworks = void 0;
|
|
12
|
+
exports.parsePsbtToNode = parsePsbtToNode;
|
|
13
|
+
exports.parseTxToNode = parseTxToNode;
|
|
14
|
+
exports.tryParsePsbt = tryParsePsbt;
|
|
15
|
+
exports.tryParseTx = tryParseTx;
|
|
16
|
+
exports.parsePsbtRawToNode = parsePsbtRawToNode;
|
|
17
|
+
exports.tryParsePsbtRaw = tryParsePsbtRaw;
|
|
18
|
+
exports.isInspectEnabled = isInspectEnabled;
|
|
19
|
+
const wasm_utxo_js_1 = require("../wasm/wasm_utxo.js");
|
|
20
|
+
/** All supported networks in order of parsing priority */
|
|
21
|
+
exports.allNetworks = [
|
|
22
|
+
"btc",
|
|
23
|
+
"tbtc",
|
|
24
|
+
"tbtc4",
|
|
25
|
+
"tbtcsig",
|
|
26
|
+
"tbtcbgsig",
|
|
27
|
+
"ltc",
|
|
28
|
+
"tltc",
|
|
29
|
+
"bch",
|
|
30
|
+
"tbch",
|
|
31
|
+
"bcha",
|
|
32
|
+
"tbcha",
|
|
33
|
+
"btg",
|
|
34
|
+
"tbtg",
|
|
35
|
+
"bsv",
|
|
36
|
+
"tbsv",
|
|
37
|
+
"dash",
|
|
38
|
+
"tdash",
|
|
39
|
+
"doge",
|
|
40
|
+
"tdoge",
|
|
41
|
+
"zec",
|
|
42
|
+
"tzec",
|
|
43
|
+
];
|
|
44
|
+
/**
|
|
45
|
+
* Parse a PSBT and return a typed node tree.
|
|
46
|
+
*
|
|
47
|
+
* @param psbtBytes - The raw PSBT bytes
|
|
48
|
+
* @param network - The network coin name (e.g., "btc", "ltc", "bch")
|
|
49
|
+
* @returns A Node tree representing the parsed PSBT structure
|
|
50
|
+
* @throws If the PSBT bytes are invalid or network is unknown
|
|
51
|
+
*/
|
|
52
|
+
function parsePsbtToNode(psbtBytes, network) {
|
|
53
|
+
const json = (0, wasm_utxo_js_1.parsePsbtToJson)(psbtBytes, network);
|
|
54
|
+
return JSON.parse(json);
|
|
55
|
+
}
|
|
56
|
+
/**
|
|
57
|
+
* Parse a transaction and return a typed node tree.
|
|
58
|
+
*
|
|
59
|
+
* @param txBytes - The raw transaction bytes
|
|
60
|
+
* @param network - The network coin name (e.g., "btc", "ltc", "bch")
|
|
61
|
+
* @returns A Node tree representing the parsed transaction structure
|
|
62
|
+
* @throws If the transaction bytes are invalid or network is unknown
|
|
63
|
+
*/
|
|
64
|
+
function parseTxToNode(txBytes, network) {
|
|
65
|
+
const json = (0, wasm_utxo_js_1.parseTxToJson)(txBytes, network);
|
|
66
|
+
return JSON.parse(json);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Try to parse a PSBT with all networks and return the first one that succeeds.
|
|
70
|
+
*
|
|
71
|
+
* @param psbtBytes - The raw PSBT bytes
|
|
72
|
+
* @param networks - Optional list of networks to try (defaults to all networks)
|
|
73
|
+
* @returns An object with the parsed Node and detected network, or null if all fail
|
|
74
|
+
*/
|
|
75
|
+
function tryParsePsbt(psbtBytes, networks = exports.allNetworks) {
|
|
76
|
+
for (const network of networks) {
|
|
77
|
+
try {
|
|
78
|
+
const node = parsePsbtToNode(psbtBytes, network);
|
|
79
|
+
return { node, network };
|
|
80
|
+
}
|
|
81
|
+
catch {
|
|
82
|
+
// Try next network
|
|
83
|
+
}
|
|
84
|
+
}
|
|
85
|
+
return null;
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Try to parse a transaction with all networks and return the first one that succeeds.
|
|
89
|
+
*
|
|
90
|
+
* @param txBytes - The raw transaction bytes
|
|
91
|
+
* @param networks - Optional list of networks to try (defaults to all networks)
|
|
92
|
+
* @returns An object with the parsed Node and detected network, or null if all fail
|
|
93
|
+
*/
|
|
94
|
+
function tryParseTx(txBytes, networks = exports.allNetworks) {
|
|
95
|
+
for (const network of networks) {
|
|
96
|
+
try {
|
|
97
|
+
const node = parseTxToNode(txBytes, network);
|
|
98
|
+
return { node, network };
|
|
99
|
+
}
|
|
100
|
+
catch {
|
|
101
|
+
// Try next network
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
return null;
|
|
105
|
+
}
|
|
106
|
+
/**
|
|
107
|
+
* Parse a PSBT at the raw byte level and return a typed node tree.
|
|
108
|
+
*
|
|
109
|
+
* Unlike `parsePsbtToNode`, this function exposes the raw key-value pair
|
|
110
|
+
* structure as defined in BIP-174, showing:
|
|
111
|
+
* - Raw key type IDs and their human-readable names
|
|
112
|
+
* - Proprietary keys with their structured format
|
|
113
|
+
* - Unknown/unrecognized keys that standard parsers might skip
|
|
114
|
+
*
|
|
115
|
+
* @param psbtBytes - The raw PSBT bytes
|
|
116
|
+
* @param network - The network coin name (e.g., "btc", "ltc", "zec")
|
|
117
|
+
* @returns A Node tree representing the raw PSBT key-value structure
|
|
118
|
+
* @throws If the PSBT bytes are invalid or network is unknown
|
|
119
|
+
*/
|
|
120
|
+
function parsePsbtRawToNode(psbtBytes, network) {
|
|
121
|
+
const json = (0, wasm_utxo_js_1.parsePsbtRawToJson)(psbtBytes, network);
|
|
122
|
+
return JSON.parse(json);
|
|
123
|
+
}
|
|
124
|
+
/**
|
|
125
|
+
* Try to parse a raw PSBT with all networks and return the first one that succeeds.
|
|
126
|
+
*
|
|
127
|
+
* @param psbtBytes - The raw PSBT bytes
|
|
128
|
+
* @param networks - Optional list of networks to try (defaults to all networks)
|
|
129
|
+
* @returns An object with the parsed Node and detected network, or null if all fail
|
|
130
|
+
*/
|
|
131
|
+
function tryParsePsbtRaw(psbtBytes, networks = exports.allNetworks) {
|
|
132
|
+
for (const network of networks) {
|
|
133
|
+
try {
|
|
134
|
+
const node = parsePsbtRawToNode(psbtBytes, network);
|
|
135
|
+
return { node, network };
|
|
136
|
+
}
|
|
137
|
+
catch {
|
|
138
|
+
// Try next network
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
return null;
|
|
142
|
+
}
|
|
143
|
+
/**
|
|
144
|
+
* Check if the inspect feature is enabled in the WASM build.
|
|
145
|
+
*
|
|
146
|
+
* @returns true if the feature is enabled, false otherwise
|
|
147
|
+
*/
|
|
148
|
+
function isInspectEnabled() {
|
|
149
|
+
return (0, wasm_utxo_js_1.isInspectEnabled)();
|
|
150
|
+
}
|
|
@@ -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;
|
|
@@ -4778,6 +4778,175 @@ class WrapPsbt {
|
|
|
4778
4778
|
if (Symbol.dispose) WrapPsbt.prototype[Symbol.dispose] = WrapPsbt.prototype.free;
|
|
4779
4779
|
exports.WrapPsbt = WrapPsbt;
|
|
4780
4780
|
|
|
4781
|
+
/**
|
|
4782
|
+
* Check if the inspect feature is enabled.
|
|
4783
|
+
*
|
|
4784
|
+
* # Returns
|
|
4785
|
+
* `true` if the feature is enabled, `false` otherwise
|
|
4786
|
+
* @returns {boolean}
|
|
4787
|
+
*/
|
|
4788
|
+
function isInspectEnabled() {
|
|
4789
|
+
const ret = wasm.isInspectEnabled();
|
|
4790
|
+
return ret !== 0;
|
|
4791
|
+
}
|
|
4792
|
+
exports.isInspectEnabled = isInspectEnabled;
|
|
4793
|
+
|
|
4794
|
+
/**
|
|
4795
|
+
* Parse a PSBT at the raw byte level and return a JSON representation.
|
|
4796
|
+
*
|
|
4797
|
+
* Unlike `parsePsbtToJson`, this function exposes the raw key-value pair
|
|
4798
|
+
* structure as defined in BIP-174, showing:
|
|
4799
|
+
* - Raw key type IDs and their human-readable names
|
|
4800
|
+
* - Proprietary keys with their structured format
|
|
4801
|
+
* - Unknown/unrecognized keys that standard parsers might skip
|
|
4802
|
+
*
|
|
4803
|
+
* # Arguments
|
|
4804
|
+
* * `psbt_bytes` - The raw PSBT bytes
|
|
4805
|
+
* * `coin_name` - The network coin name (e.g., "btc", "ltc", "zec")
|
|
4806
|
+
*
|
|
4807
|
+
* # Returns
|
|
4808
|
+
* A JSON string representing the raw PSBT key-value structure
|
|
4809
|
+
*
|
|
4810
|
+
* # Errors
|
|
4811
|
+
* Returns an error if:
|
|
4812
|
+
* - The `inspect` feature is not enabled
|
|
4813
|
+
* - The PSBT bytes are invalid
|
|
4814
|
+
* - The network name is unknown
|
|
4815
|
+
* @param {Uint8Array} psbt_bytes
|
|
4816
|
+
* @param {string} coin_name
|
|
4817
|
+
* @returns {string}
|
|
4818
|
+
*/
|
|
4819
|
+
function parsePsbtRawToJson(psbt_bytes, coin_name) {
|
|
4820
|
+
let deferred4_0;
|
|
4821
|
+
let deferred4_1;
|
|
4822
|
+
try {
|
|
4823
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4824
|
+
const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
|
|
4825
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4826
|
+
const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
4827
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4828
|
+
wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
|
|
4829
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
4830
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
4831
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
4832
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
4833
|
+
var ptr3 = r0;
|
|
4834
|
+
var len3 = r1;
|
|
4835
|
+
if (r3) {
|
|
4836
|
+
ptr3 = 0; len3 = 0;
|
|
4837
|
+
throw takeObject(r2);
|
|
4838
|
+
}
|
|
4839
|
+
deferred4_0 = ptr3;
|
|
4840
|
+
deferred4_1 = len3;
|
|
4841
|
+
return getStringFromWasm0(ptr3, len3);
|
|
4842
|
+
} finally {
|
|
4843
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4844
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
4845
|
+
}
|
|
4846
|
+
}
|
|
4847
|
+
exports.parsePsbtRawToJson = parsePsbtRawToJson;
|
|
4848
|
+
|
|
4849
|
+
/**
|
|
4850
|
+
* Parse a PSBT and return a JSON representation of its structure.
|
|
4851
|
+
*
|
|
4852
|
+
* This function parses the PSBT using the standard bitcoin crate parser
|
|
4853
|
+
* and returns a hierarchical node structure suitable for display.
|
|
4854
|
+
*
|
|
4855
|
+
* # Arguments
|
|
4856
|
+
* * `psbt_bytes` - The raw PSBT bytes
|
|
4857
|
+
* * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
|
|
4858
|
+
*
|
|
4859
|
+
* # Returns
|
|
4860
|
+
* A JSON string representing the parsed PSBT structure
|
|
4861
|
+
*
|
|
4862
|
+
* # Errors
|
|
4863
|
+
* Returns an error if:
|
|
4864
|
+
* - The `inspect` feature is not enabled
|
|
4865
|
+
* - The PSBT bytes are invalid
|
|
4866
|
+
* - The network name is unknown
|
|
4867
|
+
* @param {Uint8Array} psbt_bytes
|
|
4868
|
+
* @param {string} coin_name
|
|
4869
|
+
* @returns {string}
|
|
4870
|
+
*/
|
|
4871
|
+
function parsePsbtToJson(psbt_bytes, coin_name) {
|
|
4872
|
+
let deferred4_0;
|
|
4873
|
+
let deferred4_1;
|
|
4874
|
+
try {
|
|
4875
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4876
|
+
const ptr0 = passArray8ToWasm0(psbt_bytes, wasm.__wbindgen_export);
|
|
4877
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4878
|
+
const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
4879
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4880
|
+
wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
|
|
4881
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
4882
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
4883
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
4884
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
4885
|
+
var ptr3 = r0;
|
|
4886
|
+
var len3 = r1;
|
|
4887
|
+
if (r3) {
|
|
4888
|
+
ptr3 = 0; len3 = 0;
|
|
4889
|
+
throw takeObject(r2);
|
|
4890
|
+
}
|
|
4891
|
+
deferred4_0 = ptr3;
|
|
4892
|
+
deferred4_1 = len3;
|
|
4893
|
+
return getStringFromWasm0(ptr3, len3);
|
|
4894
|
+
} finally {
|
|
4895
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4896
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
4897
|
+
}
|
|
4898
|
+
}
|
|
4899
|
+
exports.parsePsbtToJson = parsePsbtToJson;
|
|
4900
|
+
|
|
4901
|
+
/**
|
|
4902
|
+
* Parse a transaction and return a JSON representation of its structure.
|
|
4903
|
+
*
|
|
4904
|
+
* # Arguments
|
|
4905
|
+
* * `tx_bytes` - The raw transaction bytes
|
|
4906
|
+
* * `coin_name` - The network coin name (e.g., "btc", "ltc", "bch")
|
|
4907
|
+
*
|
|
4908
|
+
* # Returns
|
|
4909
|
+
* A JSON string representing the parsed transaction structure
|
|
4910
|
+
*
|
|
4911
|
+
* # Errors
|
|
4912
|
+
* Returns an error if:
|
|
4913
|
+
* - The `inspect` feature is not enabled
|
|
4914
|
+
* - The transaction bytes are invalid
|
|
4915
|
+
* - The network name is unknown
|
|
4916
|
+
* @param {Uint8Array} tx_bytes
|
|
4917
|
+
* @param {string} coin_name
|
|
4918
|
+
* @returns {string}
|
|
4919
|
+
*/
|
|
4920
|
+
function parseTxToJson(tx_bytes, coin_name) {
|
|
4921
|
+
let deferred4_0;
|
|
4922
|
+
let deferred4_1;
|
|
4923
|
+
try {
|
|
4924
|
+
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16);
|
|
4925
|
+
const ptr0 = passArray8ToWasm0(tx_bytes, wasm.__wbindgen_export);
|
|
4926
|
+
const len0 = WASM_VECTOR_LEN;
|
|
4927
|
+
const ptr1 = passStringToWasm0(coin_name, wasm.__wbindgen_export, wasm.__wbindgen_export2);
|
|
4928
|
+
const len1 = WASM_VECTOR_LEN;
|
|
4929
|
+
wasm.parsePsbtRawToJson(retptr, ptr0, len0, ptr1, len1);
|
|
4930
|
+
var r0 = getDataViewMemory0().getInt32(retptr + 4 * 0, true);
|
|
4931
|
+
var r1 = getDataViewMemory0().getInt32(retptr + 4 * 1, true);
|
|
4932
|
+
var r2 = getDataViewMemory0().getInt32(retptr + 4 * 2, true);
|
|
4933
|
+
var r3 = getDataViewMemory0().getInt32(retptr + 4 * 3, true);
|
|
4934
|
+
var ptr3 = r0;
|
|
4935
|
+
var len3 = r1;
|
|
4936
|
+
if (r3) {
|
|
4937
|
+
ptr3 = 0; len3 = 0;
|
|
4938
|
+
throw takeObject(r2);
|
|
4939
|
+
}
|
|
4940
|
+
deferred4_0 = ptr3;
|
|
4941
|
+
deferred4_1 = len3;
|
|
4942
|
+
return getStringFromWasm0(ptr3, len3);
|
|
4943
|
+
} finally {
|
|
4944
|
+
wasm.__wbindgen_add_to_stack_pointer(16);
|
|
4945
|
+
wasm.__wbindgen_export4(deferred4_0, deferred4_1, 1);
|
|
4946
|
+
}
|
|
4947
|
+
}
|
|
4948
|
+
exports.parseTxToJson = parseTxToJson;
|
|
4949
|
+
|
|
4781
4950
|
function __wbg_get_imports() {
|
|
4782
4951
|
const import0 = {
|
|
4783
4952
|
__proto__: null,
|
|
Binary file
|