Skip to content

Commit 7931dbd

Browse files
Added validate_domain in electrum option
1 parent a3fcf8a commit 7931dbd

File tree

3 files changed

+19
-7
lines changed

3 files changed

+19
-7
lines changed

src/commands.rs

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212
//! All optional args are defined in the structs below.
1313
//! All subcommands are defined in the below enums.
1414
15-
#![allow(clippy::large_enum_variant)]
15+
16+
#[allow(clippy::large_enum_variant)]
1617

1718
use bdk_wallet::bitcoin::{
1819
Address, Network, OutPoint, ScriptBuf,
@@ -186,6 +187,10 @@ pub struct WalletOpts {
186187
#[cfg(feature = "electrum")]
187188
#[arg(env = "ELECTRUM_BATCH_SIZE", short = 'b', long, default_value = "10")]
188189
pub batch_size: usize,
190+
///Electrum validate domain option.
191+
#[cfg(feature = "electrum")]
192+
#[arg(env="VALIDATE_DOMAIN",long = "validate-domain", action = clap::ArgAction::Set, default_value_t = true)]
193+
pub validate_domain: bool,
189194
/// Esplora parallel requests.
190195
#[cfg(feature = "esplora")]
191196
#[arg(
@@ -396,8 +401,11 @@ pub enum OnlineWalletSubCommand {
396401
stop_gap: usize,
397402
},
398403
/// Syncs with the chosen blockchain server.
399-
Sync,
400-
/// Broadcasts a transaction to the network. Takes either a raw transaction or a PSBT to extract.
404+
Sync {
405+
#[command(flatten)]
406+
wallet_opts: WalletOpts,
407+
},
408+
401409
Broadcast {
402410
/// Sets the PSBT to sign.
403411
#[arg(

src/handlers.rs

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
//! Command Handlers
1010
//!
1111
//! This module describes all the command handling logic used by bdk-cli.
12-
12+
use crate::debug;
1313
use crate::commands::OfflineWalletSubCommand::*;
1414
use crate::commands::*;
1515
use crate::error::BDKCliError as Error;
@@ -619,7 +619,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
619619
});
620620
match client {
621621
#[cfg(feature = "electrum")]
622-
Electrum { client, batch_size } => {
622+
Electrum { client, batch_size,validate_domain } => {
623623
// Populate the electrum client's transaction cache so it doesn't re-download transaction we
624624
// already have.
625625
client
@@ -694,15 +694,16 @@ pub(crate) async fn handle_online_wallet_subcommand(
694694
let pc = (100 * progress.consumed()) as f32 / progress.total() as f32;
695695
eprintln!("[ SCANNING {pc:03.0}% ] {item}");
696696
});
697+
697698
match client {
698699
#[cfg(feature = "electrum")]
699-
Electrum { client, batch_size } => {
700+
Electrum { client, batch_size, validate_domain } => {
700701
// Populate the electrum client's transaction cache so it doesn't re-download transaction we
701702
// already have.
702703
client
703704
.populate_tx_cache(wallet.tx_graph().full_txs().map(|tx_node| tx_node.tx));
704705

705-
let update = client.sync(request, batch_size, false)?;
706+
let update = client.sync(request, batch_size, validate_domain)?;
706707
wallet.apply_update(update)?;
707708
}
708709
#[cfg(feature = "esplora")]
@@ -788,6 +789,7 @@ pub(crate) async fn handle_online_wallet_subcommand(
788789
Electrum {
789790
client,
790791
batch_size: _,
792+
validate_domain,
791793
} => client
792794
.transaction_broadcast(&tx)
793795
.map_err(|e| Error::Generic(e.to_string()))?,

src/utils.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ pub(crate) enum BlockchainClient {
127127
Electrum {
128128
client: Box<bdk_electrum::BdkElectrumClient<bdk_electrum::electrum_client::Client>>,
129129
batch_size: usize,
130+
validate_domain: bool,
130131
},
131132
#[cfg(feature = "esplora")]
132133
Esplora {
@@ -164,6 +165,7 @@ pub(crate) fn new_blockchain_client(
164165
BlockchainClient::Electrum {
165166
client: Box::new(client),
166167
batch_size: wallet_opts.batch_size,
168+
validate_domain: wallet_opts.validate_domain,
167169
}
168170
}
169171
#[cfg(feature = "esplora")]

0 commit comments

Comments
 (0)