Skip to content
Closed
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
16 changes: 7 additions & 9 deletions src/handlers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,9 +355,9 @@ pub(crate) async fn handle_online_wallet_subcommand(
let mut once = HashSet::<KeychainKind>::new();
move |k, spk_i, _| {
if once.insert(k) {
print!("\nScanning keychain [{:?}]", k);
print!("\nScanning keychain [{k:?}]");
}
print!(" {:<3}", spk_i);
print!(" {spk_i:<3}");
stdout.flush().expect("must flush");
}
});
Expand Down Expand Up @@ -432,7 +432,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
.start_sync_with_revealed_spks()
.inspect(|item, progress| {
let pc = (100 * progress.consumed()) as f32 / progress.total() as f32;
eprintln!("[ SCANNING {:03.0}% ] {}", pc, item);
eprintln!("[ SCANNING {pc:03.0}% ] {item}");
});
match client {
#[cfg(feature = "electrum")]
Expand Down Expand Up @@ -558,7 +558,7 @@ pub(crate) async fn handle_online_wallet_subcommand(

let subscriber = tracing_subscriber::FmtSubscriber::new();
tracing::subscriber::set_global_default(subscriber)
.map_err(|e| Error::Generic(format!("SetGlobalDefault error: {}", e)))?;
.map_err(|e| Error::Generic(format!("SetGlobalDefault error: {e}")))?;

tokio::task::spawn(async move { node.run().await });
tokio::task::spawn(async move {
Expand All @@ -578,7 +578,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
let txid = tx.compute_txid();
requester
.broadcast_random(tx.clone())
.map_err(|e| Error::Generic(format!("{}", e)))?;
.map_err(|e| Error::Generic(format!("{e}")))?;
tokio::time::timeout(tokio::time::Duration::from_secs(30), async move {
while let Some(info) = info_subscriber.recv().await {
match info {
Expand Down Expand Up @@ -619,8 +619,7 @@ pub(crate) fn is_final(psbt: &Psbt) -> Result<(), Error> {
let psbt_inputs = psbt.inputs.len();
if unsigned_tx_inputs != psbt_inputs {
return Err(Error::Generic(format!(
"Malformed PSBT, {} unsigned tx inputs and {} psbt inputs.",
unsigned_tx_inputs, psbt_inputs
"Malformed PSBT, {unsigned_tx_inputs} unsigned tx inputs and {psbt_inputs} psbt inputs."
)));
}
let sig_count = psbt.inputs.iter().fold(0, |count, input| {
Expand Down Expand Up @@ -747,7 +746,6 @@ pub(crate) async fn handle_command(cli_opts: CliOpts) -> Result<String, Error> {
wallet_opts,
subcommand: WalletSubCommand::OnlineWalletSubCommand(online_subcommand),
} => {
let network = cli_opts.network;
let home_dir = prepare_home_dir(cli_opts.datadir)?;
let wallet_name = &wallet_opts.wallet;
let database_path = prepare_wallet_db_dir(wallet_name, &home_dir)?;
Expand Down Expand Up @@ -948,7 +946,7 @@ async fn respond(
};
if let Some(value) = response {
let value = serde_json::to_string_pretty(&value).map_err(|e| e.to_string())?;
writeln!(std::io::stdout(), "{}", value).map_err(|e| e.to_string())?;
writeln!(std::io::stdout(), "{value}").map_err(|e| e.to_string())?;
std::io::stdout().flush().map_err(|e| e.to_string())?;
Ok(false)
} else {
Expand Down
6 changes: 3 additions & 3 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ async fn main() {
let cli_opts: CliOpts = CliOpts::parse();

let network = &cli_opts.network;
debug!("network: {:?}", network);
debug!("network: {network:?}");
if network == &Network::Bitcoin {
warn!("This is experimental software and not currently recommended for use on Bitcoin mainnet, proceed with caution.")
}

match handle_command(cli_opts).await {
Ok(result) => println!("{}", result),
Ok(result) => println!("{result}"),
Err(e) => {
error!("{}", e);
error!("{e}");
std::process::exit(1);
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -337,7 +337,7 @@ pub async fn sync_kyoto_client(wallet: &mut Wallet, client: Box<LightClient>) ->

let subscriber = tracing_subscriber::FmtSubscriber::new();
tracing::subscriber::set_global_default(subscriber)
.map_err(|e| Error::Generic(format!("SetGlobalDefault error: {}", e)))?;
.map_err(|e| Error::Generic(format!("SetGlobalDefault error: {e}")))?;

tokio::task::spawn(async move { node.run().await });
tokio::task::spawn(async move {
Expand All @@ -354,7 +354,7 @@ pub async fn sync_kyoto_client(wallet: &mut Wallet, client: Box<LightClient>) ->
tracing::info!("Received update: applying to wallet");
wallet
.apply_update(update)
.map_err(|e| Error::Generic(format!("Failed to apply update: {}", e)))?;
.map_err(|e| Error::Generic(format!("Failed to apply update: {e}")))?;

tracing::info!(
"Chain tip: {}, Transactions: {}, Balance: {}",
Expand Down
6 changes: 3 additions & 3 deletions tests/integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -127,19 +127,19 @@ mod test {
node_datadir,
};

println!("BDK-CLI Config : {:#?}", bdk_cli);
println!("BDK-CLI Config : {bdk_cli:#?}");
let bdk_master_key = bdk_cli.key_exec(&["generate"])?;
let bdk_xprv = get_value(&bdk_master_key, "xprv")?;

let bdk_recv_desc =
bdk_cli.key_exec(&["derive", "--path", "m/84h/1h/0h/0", "--xprv", &bdk_xprv])?;
let bdk_recv_desc = get_value(&bdk_recv_desc, "xprv")?;
let bdk_recv_desc = format!("wpkh({})", bdk_recv_desc);
let bdk_recv_desc = format!("wpkh({bdk_recv_desc})");

let bdk_chng_desc =
bdk_cli.key_exec(&["derive", "--path", "m/84h/1h/0h/1", "--xprv", &bdk_xprv])?;
let bdk_chng_desc = get_value(&bdk_chng_desc, "xprv")?;
let bdk_chng_desc = format!("wpkh({})", bdk_chng_desc);
let bdk_chng_desc = format!("wpkh({bdk_chng_desc})");

bdk_cli.recv_desc = Some(bdk_recv_desc);
bdk_cli.chang_desc = Some(bdk_chng_desc);
Expand Down
Loading