diff --git a/Cargo.toml b/Cargo.toml index d5767f3..f31d3be 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -21,17 +21,16 @@ serde_json = "1.0" thiserror = "2.0.11" tokio = { version = "1", features = ["full"] } cli-table = "0.5.0" - +bdk_electrum = { version = "0.23.0", optional = true } # Optional dependencies bdk_bitcoind_rpc = { version = "0.21.0", features = ["std"], optional = true } -bdk_electrum = { version = "0.23.0", optional = true } + bdk_esplora = { version = "0.22.1", features = ["async-https", "tokio"], optional = true } bdk_kyoto = { version = "0.15.1", optional = true } bdk_redb = { version = "0.1.0", optional = true } shlex = { version = "1.3.0", optional = true } tracing = "0.1.41" tracing-subscriber = "0.3.20" - [features] default = ["repl", "sqlite"] diff --git a/src/commands.rs b/src/commands.rs index 62a6a2d..545b0e0 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -13,7 +13,6 @@ //! All subcommands are defined in the below enums. #![allow(clippy::large_enum_variant)] - use bdk_wallet::bitcoin::{ Address, Network, OutPoint, ScriptBuf, bip32::{DerivationPath, Xpriv}, @@ -396,8 +395,11 @@ pub enum OnlineWalletSubCommand { stop_gap: usize, }, /// Syncs with the chosen blockchain server. - Sync, - /// Broadcasts a transaction to the network. Takes either a raw transaction or a PSBT to extract. + Sync { + #[command(flatten)] + wallet_opts: WalletOpts, + }, + Broadcast { /// Sets the PSBT to sign. #[arg( diff --git a/src/handlers.rs b/src/handlers.rs index 941c550..b6e401b 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -9,7 +9,6 @@ //! Command Handlers //! //! This module describes all the command handling logic used by bdk-cli. - use crate::commands::OfflineWalletSubCommand::*; use crate::commands::*; use crate::error::BDKCliError as Error; @@ -686,7 +685,7 @@ pub(crate) async fn handle_online_wallet_subcommand( } Ok(serde_json::to_string_pretty(&json!({}))?) } - Sync => { + sync => { #[cfg(any(feature = "electrum", feature = "esplora"))] let request = wallet .start_sync_with_revealed_spks() @@ -694,6 +693,7 @@ pub(crate) async fn handle_online_wallet_subcommand( let pc = (100 * progress.consumed()) as f32 / progress.total() as f32; eprintln!("[ SCANNING {pc:03.0}% ] {item}"); }); + match client { #[cfg(feature = "electrum")] Electrum { client, batch_size } => { diff --git a/src/utils.rs b/src/utils.rs index cb81074..a2961ed 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -9,19 +9,18 @@ //! Utility Tools //! //! This module includes all the utility tools used by the App. -use crate::error::BDKCliError as Error; -use std::fmt::Display; -use std::str::FromStr; - -use std::path::{Path, PathBuf}; - use crate::commands::WalletOpts; +use crate::error::BDKCliError as Error; +use bdk_electrum::electrum_client::ConfigBuilder; #[cfg(feature = "cbf")] use bdk_kyoto::{ BuilderExt, Info, LightClient, Receiver, ScanType::Sync, UnboundedReceiver, Warning, builder::Builder, }; use bdk_wallet::bitcoin::{Address, Network, OutPoint, ScriptBuf}; +use std::fmt::Display; +use std::path::{Path, PathBuf}; +use std::str::FromStr; #[cfg(any( feature = "electrum", @@ -159,7 +158,8 @@ pub(crate) fn new_blockchain_client( let client = match wallet_opts.client_type { #[cfg(feature = "electrum")] ClientType::Electrum => { - let client = bdk_electrum::electrum_client::Client::new(url) + let config = ConfigBuilder::new().build(); + let client = bdk_electrum::electrum_client::Client::from_config(url, config) .map(bdk_electrum::BdkElectrumClient::new)?; BlockchainClient::Electrum { client: Box::new(client),