[repl] Expose list_transactions() in the REPL
This commit is contained in:
parent
4fcf7ac89e
commit
5683a83288
20
src/cli.rs
20
src/cli.rs
@ -57,6 +57,9 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> {
|
|||||||
.subcommand(
|
.subcommand(
|
||||||
SubCommand::with_name("list_unspent").about("Lists the available spendable UTXOs"),
|
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(
|
||||||
SubCommand::with_name("get_balance").about("Returns the current wallet balance"),
|
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);
|
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))
|
Ok(Some(res))
|
||||||
} else if let Some(_sub_matches) = matches.subcommand_matches("get_balance") {
|
} else if let Some(_sub_matches) = matches.subcommand_matches("get_balance") {
|
||||||
Ok(Some(format!("{} SAT", wallet.get_balance()?)))
|
Ok(Some(format!("{} SAT", wallet.get_balance()?)))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user