From: Alekos Filini Date: Tue, 21 Apr 2020 14:39:00 +0000 (+0200) Subject: [repl] Add broadcast command X-Git-Tag: 0.1.0-beta.1~35 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CommandStringError.html?a=commitdiff_plain;h=97b3dabce592f6f7ede9055eeec9a544c8fda773;p=bdk-cli [repl] Add broadcast command --- diff --git a/examples/repl.rs b/examples/repl.rs index b67b6e3..82c41f3 100644 --- a/examples/repl.rs +++ b/examples/repl.rs @@ -160,6 +160,18 @@ fn main() { .takes_value(true) .number_of_values(1) .required(true), + )) + .subcommand( + SubCommand::with_name("broadcast") + .about("Extracts the finalized transaction from a PSBT and broadcasts it to the network") + .arg( + Arg::with_name("psbt") + .long("psbt") + .value_name("BASE64_PSBT") + .help("Sets the PSBT to broadcast") + .takes_value(true) + .number_of_values(1) + .required(true), )); let mut repl_app = app.clone().setting(AppSettings::NoBinaryName); @@ -309,6 +321,12 @@ fn main() { if finalized { println!("Extracted: {}", serialize_hex(&psbt.extract_tx())); } + } else if let Some(sub_matches) = matches.subcommand_matches("broadcast") { + let psbt = base64::decode(sub_matches.value_of("psbt").unwrap()).unwrap(); + let psbt: PartiallySignedTransaction = deserialize(&psbt).unwrap(); + let (txid, _) = wallet.broadcast(psbt).unwrap(); + + println!("TXID: {}", txid); } };