Skip to content

Commit 85f472c

Browse files
OttoAllmendingerllm-git
andcommitted
feat(wasm-utxo): add raw PSBT parser showing key-value structure
Implement a new parser module for examining low-level PSBT structure with raw key-value pairs as defined in BIP-174. This exposes internal details like proprietary keys, raw type IDs, and byte structure that standard parsers might hide. Also add test utilities for loading PSBT fixtures across different networks and signature states. Issue: BTC-2652 Co-authored-by: llm-git <[email protected]>
1 parent 5783475 commit 85f472c

File tree

8 files changed

+1395
-3
lines changed

8 files changed

+1395
-3
lines changed

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,12 @@ mod address;
55
mod format;
66
mod node;
77
mod parse_node;
8+
mod parse_node_raw;
89
mod psbt;
910

11+
#[cfg(test)]
12+
pub mod test_utils;
13+
1014
#[derive(Parser)]
1115
#[command(name = "wasm-utxo-cli")]
1216
#[command(about = "CLI tool for Bitcoin UTXO operations", long_about = None)]

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

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -317,3 +317,26 @@ pub fn parse_tx_bytes_internal(bytes: &[u8]) -> Result<Node, String> {
317317
.map(|tx| tx_to_node(&tx, Network::Bitcoin))
318318
.map_err(|e| e.to_string())
319319
}
320+
321+
#[cfg(test)]
322+
mod tests {
323+
use super::*;
324+
325+
#[test]
326+
fn test_parse_psbt_bitcoin_fullsigned() -> Result<(), Box<dyn std::error::Error>> {
327+
use crate::format::fixtures::assert_tree_matches_fixture;
328+
use crate::test_utils::{load_psbt_bytes, SignatureState, TxFormat};
329+
use wasm_utxo::Network as WasmNetwork;
330+
331+
let psbt_bytes = load_psbt_bytes(
332+
WasmNetwork::Bitcoin,
333+
SignatureState::Fullsigned,
334+
TxFormat::Psbt,
335+
)?;
336+
337+
let node = parse_psbt_bytes_internal(&psbt_bytes)?;
338+
339+
assert_tree_matches_fixture(&node, "psbt_bitcoin_fullsigned")?;
340+
Ok(())
341+
}
342+
}

0 commit comments

Comments
 (0)