From b88edca77fbdbf36508dbc9a11ecf6a53ed1eaf3 Mon Sep 17 00:00:00 2001 From: Michael Maurer Date: Wed, 20 Aug 2025 16:03:58 -0400 Subject: [PATCH] feat: support concatenation of scripts Signed-off-by: Michael Maurer --- README.md | 4 +++- src/main.rs | 10 +++++++--- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/README.md b/README.md index 56dbe7d..d0df72e 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,15 @@ $ cargo install --locked --path . ### Usage -The CLI currently takes only a single argument: the path to the ASM script file: +The CLI takes one or more arguments: the path(s) to the ASM script file(s): ``` # using the binary $ btcexec # using cargo run $ cargo run -- +# concatenating multiple scripts +$ btcexec ``` ## WASM diff --git a/src/main.rs b/src/main.rs index a8f1772..a93380f 100644 --- a/src/main.rs +++ b/src/main.rs @@ -15,7 +15,7 @@ use bitcoin_scriptexec::*; struct Args { /// filepath to script ASM file #[arg(required = true)] - script_path: PathBuf, + script_path: Vec, /// Whether to print debug info #[arg(long)] debug: bool, @@ -42,8 +42,12 @@ impl fmt::Display for FmtStack<'_> { fn inner_main() -> Result<(), String> { let args = Args::parse(); - let script_asm = std::fs::read_to_string(args.script_path).expect("error reading script file"); - let script = ScriptBuf::from_asm(&script_asm).expect("error parsing script"); + let mut script = String::new(); + for script_path in args.script_path { + let script_asm = std::fs::read_to_string(script_path).expect("error reading script file"); + script.push_str(&script_asm); + } + let script = ScriptBuf::from_asm(&script).expect("error parsing script"); println!("Script in hex: {}", script.as_bytes().to_lower_hex_string()); println!("Script size: {} bytes", script.as_bytes().len());