From: Riccardo Casatta Date: Fri, 30 Oct 2020 13:43:36 +0000 (+0100) Subject: [repl] add max_addresses param in sync X-Git-Tag: v0.1.0~37 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/-sqlite-db-configuration/struct.EncoderStringWriter.html?a=commitdiff_plain;h=cbb677333cdebe41fe73b8e42ca1840b7e5405ef;p=bdk-cli [repl] add max_addresses param in sync --- diff --git a/src/cli.rs b/src/cli.rs index ad49284..26556d4 100644 --- a/src/cli.rs +++ b/src/cli.rs @@ -78,7 +78,13 @@ pub fn make_cli_subcommands<'a, 'b>() -> App<'a, 'b> { .subcommand( SubCommand::with_name("get_new_address").about("Generates a new external address"), ) - .subcommand(SubCommand::with_name("sync").about("Syncs with the chosen Electrum server")) + .subcommand(SubCommand::with_name("sync").about("Syncs with the chosen Electrum server").arg( + Arg::with_name("max_addresses") + .required(false) + .takes_value(true) + .long("max_addresses") + .help("max addresses to consider"), + )) .subcommand( SubCommand::with_name("list_unspent").about("Lists the available spendable UTXOs"), ) @@ -370,8 +376,11 @@ where Ok(json!({ "address": wallet.get_new_address()? })) - } else if let Some(_sub_matches) = matches.subcommand_matches("sync") { - maybe_await!(wallet.sync(log_progress(), None))?; + } else if let Some(sub_matches) = matches.subcommand_matches("sync") { + let max_addresses: Option = sub_matches + .value_of("max_addresses") + .and_then(|m| m.parse().ok()); + maybe_await!(wallet.sync(log_progress(), max_addresses))?; Ok(json!({})) } else if let Some(_sub_matches) = matches.subcommand_matches("list_unspent") { Ok(serde_json::to_value(&wallet.list_unspent()?)?)