From: Alekos Filini Date: Tue, 21 Jul 2020 16:37:15 +0000 (+0200) Subject: [repl] Expose list_transactions() in the REPL X-Git-Tag: 0.1.0-beta.1~21 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.CommandStringError.html?a=commitdiff_plain;h=bcb66290b791459a17880a7fb444a3169614b2bf;p=bdk-cli [repl] Expose list_transactions() in the REPL --- diff --git a/src/cli.rs b/src/cli.rs index 8ea39ed..788aa69 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -57,6 +57,9 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { .subcommand( SubCommand::with_name("list_unspent").about("Lists the available spendable UTXOs"), ) + .subcommand( + SubCommand::with_name("list_transactions").about("Lists all the incoming and outgoing transactions of the wallet"), + ) .subcommand( SubCommand::with_name("get_balance").about("Returns the current wallet balance"), ) @@ -296,6 +299,23 @@ where res += &format!("{} value {} SAT\n", utxo.outpoint, utxo.txout.value); } + Ok(Some(res)) + } else if let Some(_sub_matches) = matches.subcommand_matches("list_transactions") { + let mut res = String::new(); + for crate::types::TransactionDetails { + txid, + sent, + received, + height, + .. + } in wallet.list_transactions(false)? + { + res += &format!( + "{} - sent {}, received {} - height: {:?}\n", + txid, sent, received, height + ); + } + Ok(Some(res)) } else if let Some(_sub_matches) = matches.subcommand_matches("get_balance") { Ok(Some(format!("{} SAT", wallet.get_balance()?)))