Skip to content

Commit 0772f19

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): move node parser to CLI package
Removes the dependency on num-bigint from the wasm-utxo crate by moving the node parser functionality to the CLI package. This simplifies the wasm-utxo crate and removes the conditional feature flags that were previously needed. Issue: BTC-0 Co-authored-by: llm-git <llm-git@ttll.de>
1 parent 870af7e commit 0772f19

17 files changed

Lines changed: 13 additions & 1702 deletions

File tree

packages/wasm-utxo/Cargo.lock

Lines changed: 0 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

packages/wasm-utxo/Cargo.toml

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,6 @@ crate-type = ["cdylib", "rlib"]
1313
[lints.clippy]
1414
all = "warn"
1515

16-
[features]
17-
default = []
18-
parse_node = ["dep:num-bigint", "dep:serde", "dep:serde_json", "dep:hex"]
19-
2016
[dependencies]
2117
wasm-bindgen = "0.2"
2218
js-sys = "0.3"
@@ -25,10 +21,6 @@ bech32 = "0.11"
2521
musig2 = { version = "0.3.1", default-features = false, features = ["k256"] }
2622
getrandom = { version = "0.2", features = ["js"] }
2723
pastey = "0.1"
28-
num-bigint = { version = "0.4", optional = true }
29-
serde = { version = "1.0", features = ["derive"], optional = true }
30-
serde_json = { version = "1.0", optional = true }
31-
hex = { version = "0.4", optional = true }
3224

3325
[dev-dependencies]
3426
base64 = "0.22.1"

packages/wasm-utxo/cli/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ name = "wasm-utxo-cli"
88
path = "src/main.rs"
99

1010
[dependencies]
11-
wasm-utxo = { path = "..", features = ["parse_node"] }
11+
wasm-utxo = { path = ".." }
1212
clap = { version = "4.5", features = ["derive"] }
1313
anyhow = "1.0"
1414
hex = "0.4"

packages/wasm-utxo/cli/src/format/fixtures.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#[cfg(test)]
22
use super::tree::{node_to_string_with_scheme, ColorScheme};
33
#[cfg(test)]
4-
use wasm_utxo::parse_node::Node;
4+
use crate::node::Node;
55
#[cfg(test)]
66
use std::env;
77
#[cfg(test)]

packages/wasm-utxo/cli/src/format/tests.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::format::fixtures::assert_or_update_fixture;
2+
use crate::node::{Node, Primitive};
23
use num_bigint::BigInt;
3-
use wasm_utxo::parse_node::{Node, Primitive};
44

55
#[test]
66
fn test_simple_tree() -> std::io::Result<()> {

packages/wasm-utxo/cli/src/format/tree.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
use wasm_utxo::parse_node::{Node, Primitive};
1+
use crate::node::{Node, Primitive};
22
use colored::*;
33
use ptree::print_tree;
44
#[cfg(test)]

packages/wasm-utxo/cli/src/main.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,11 @@ use clap::{Parser, Subcommand};
44
mod address;
55
mod format;
66
mod input;
7-
mod network;
7+
mod node;
8+
mod parse;
89
mod psbt;
910
mod tx;
1011

11-
pub use network::NetworkArg;
12-
13-
#[cfg(test)]
14-
mod parse_tests;
1512
#[cfg(test)]
1613
pub mod test_utils;
1714

packages/wasm-utxo/cli/src/parse_tests.rs

Lines changed: 0 additions & 55 deletions
This file was deleted.

packages/wasm-utxo/cli/src/psbt/parse.rs

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,20 @@ use std::path::PathBuf;
33

44
use crate::format::{render_tree_with_scheme, ColorScheme};
55
use crate::input::{decode_input, read_input_bytes};
6-
use wasm_utxo::parse_node::{parse_psbt_bytes_raw_with_network, parse_psbt_bytes_with_network};
7-
use wasm_utxo::Network;
6+
use crate::parse::{parse_psbt_bytes_internal, parse_psbt_bytes_raw};
87

9-
pub fn handle_parse_command(
10-
path: PathBuf,
11-
no_color: bool,
12-
raw: bool,
13-
network: Network,
14-
) -> Result<()> {
8+
pub fn handle_parse_command(path: PathBuf, no_color: bool, raw: bool) -> Result<()> {
159
// Read from file or stdin
1610
let raw_bytes = read_input_bytes(&path, "PSBT")?;
1711

1812
// Decode input (auto-detect hex, base64, or raw bytes)
1913
let bytes = decode_input(&raw_bytes)?;
2014

2115
let node = if raw {
22-
parse_psbt_bytes_raw_with_network(&bytes, network)
16+
parse_psbt_bytes_raw(&bytes)
2317
.map_err(|e| anyhow::anyhow!("Failed to parse PSBT (raw): {}", e))?
2418
} else {
25-
parse_psbt_bytes_with_network(&bytes, network)
19+
parse_psbt_bytes_internal(&bytes)
2620
.map_err(|e| anyhow::anyhow!("Failed to parse PSBT: {}", e))?
2721
};
2822

packages/wasm-utxo/cli/src/tx/parse.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,16 @@ use std::path::PathBuf;
33

44
use crate::format::{render_tree_with_scheme, ColorScheme};
55
use crate::input::{decode_input, read_input_bytes};
6-
use wasm_utxo::Network;
7-
use wasm_utxo::parse_node::parse_tx_bytes_with_network;
6+
use crate::parse::parse_tx_bytes_internal;
87

9-
pub fn handle_parse_command(path: PathBuf, no_color: bool, network: Network) -> Result<()> {
8+
pub fn handle_parse_command(path: PathBuf, no_color: bool) -> Result<()> {
109
// Read from file or stdin
1110
let raw_bytes = read_input_bytes(&path, "transaction")?;
1211

1312
// Decode input (auto-detect hex, base64, or raw bytes)
1413
let bytes = decode_input(&raw_bytes)?;
1514

16-
let node = parse_tx_bytes_with_network(&bytes, network)
15+
let node = parse_tx_bytes_internal(&bytes)
1716
.map_err(|e| anyhow::anyhow!("Failed to parse transaction: {}", e))?;
1817

1918
let color_scheme = if no_color {

0 commit comments

Comments
 (0)