Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 <script.bs>
# using cargo run
$ cargo run -- <script.bs>
# concatenating multiple scripts
$ btcexec <unlockingscript.bs> <lockingscript.bs>
```

## WASM
Expand Down
10 changes: 7 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ use bitcoin_scriptexec::*;
struct Args {
/// filepath to script ASM file
#[arg(required = true)]
script_path: PathBuf,
script_path: Vec<PathBuf>,
/// Whether to print debug info
#[arg(long)]
debug: bool,
Expand All @@ -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());

Expand Down