Skip to content

Added validate_domain in electrum option#223

Open
Rahamath-unnisa wants to merge 1 commit intobitcoindevkit:masterfrom
Rahamath-unnisa:validate_domain-config
Open

Added validate_domain in electrum option#223
Rahamath-unnisa wants to merge 1 commit intobitcoindevkit:masterfrom
Rahamath-unnisa:validate_domain-config

Conversation

@Rahamath-unnisa
Copy link
Copy Markdown

@Rahamath-unnisa Rahamath-unnisa commented Oct 20, 2025

Description:
This PR adds the validate_domain option to the Electrum client in bdk-cli.
This resolves #134 .
Changes included:

Added --validate-domain flag in command.rs.

Updated Electrum client handling in handlers.rs and utils.rs to respect the flag.

Verified functionality locally using:

RUST_LOG=debug,rusqlite=info,rustls=info cargo run --features electrum -- wallet --client-type electrum --database-type sqlite --url ssl://electrum.blockstream.info:60002 --validate-domain true --ext-descriptor "wpkh(.../*)" sync

Motivation:
Allows users to enable or disable domain validation for Electrum servers, useful for self-hosted/custom servers while preserving security by default.

Checklist:

Tested locally with Electrum client

No unrelated changes included

@va-an
Copy link
Copy Markdown
Contributor

va-an commented Oct 21, 2025

@Rahamath-unnisa pls mention in PR description that this resolves #134.

src/commands.rs Outdated

#![allow(clippy::large_enum_variant)]

#[allow(clippy::large_enum_variant)]
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig this is not required.

src/handlers.rs Outdated
//!
//! This module describes all the command handling logic used by bdk-cli.

use crate::debug;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig this is not needed either.

},
/// Syncs with the chosen blockchain server.
Sync,
/// Broadcasts a transaction to the network. Takes either a raw transaction or a PSBT to extract.
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doc comment should not be removed.

src/handlers.rs Outdated
.populate_tx_cache(wallet.tx_graph().full_txs().map(|tx_node| tx_node.tx));

let update = client.sync(request, batch_size, false)?;
let update = client.sync(request, batch_size, validate_domain)?;
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ig this is not the right place to pass validate_domain looking at the defn here. I think we need to change how the client is built using this.

@Rahamath-unnisa
Copy link
Copy Markdown
Author

Hi @110CodingP,
I have made the requested cleanups in commands.rs and handlers.rs per your review comments
All changes are pushed to the validate_domain-config branch.
Please let me know if anything else is needed. Thanks!

Copy link
Copy Markdown
Collaborator

@tvpeter tvpeter left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @Rahamath-unnisa,
Thank you for the eagerness to contribute, but please understand the project fully before attempting to do so as it is easier to make progress that way.
Thank you.

Cargo.toml Outdated
shlex = { version = "1.3.0", optional = true }
tracing = "0.1.41"
tracing-subscriber = "0.3.20"
electrum-client = "0.24.0"
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bdk_electrum is built on this crate, so no need pulling it here.

src/commands.rs Outdated
#[cfg(feature = "electrum")]
#[arg(env = "ELECTRUM_BATCH_SIZE", short = 'b', long, default_value = "10")]
pub batch_size: usize,
///Electrum validate domain option.
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this comment is not needed

src/commands.rs Outdated
///Electrum validate domain option.
#[cfg(feature = "electrum")]
#[arg(env="VALIDATE_DOMAIN",long = "validate-domain", action = clap::ArgAction::Set, default_value_t = true)]
pub validate_domain: bool,
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a user do not need to specifically indicate whether the domain should be validated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sorry if I misunderstood but doesn't the issue want us to provide validate_domain as an option? Because otherwise config.validate_domain is true by default anyways.

Copy link
Copy Markdown
Contributor

@va-an va-an left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could you rebase and squash the commits into one, please?

@Rahamath-unnisa
Copy link
Copy Markdown
Author

Hi @tvpeter, @110CodingP, @va-an,

I’ve updated the PR based on your feedback:

  • Removed CLI option for validate_domain
  • Enabled validation internally
  • Cleaned up code and dependencies
  • Rebased and resolved conflicts

Please review again. Thanks!

Copy link
Copy Markdown
Contributor

@va-an va-an left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Make sure you've done the rebase correctly.
Also, I'll repeat my request to squash into a single commit.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What's the idea behind these changes?
Moreover, because of these changes, Cargo.toml has become invalid:

-> % just pre-push
error: failed to parse manifest at `/home/vaan/src/bitcoindevkit/bdk-cli-tmp/Cargo.toml`

Caused by:
  feature `_payjoin-dependencies` includes `payjoin` which is neither a dependency nor another feature
error: Recipe `pre-push` failed on line 29 with exit code 101

src/handlers.rs Outdated
Comment on lines +12 to +14
<<<<<<< HEAD
<<<<<<< HEAD
=======
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
<<<<<<< HEAD
<<<<<<< HEAD
=======

src/handlers.rs Outdated
Comment on lines +16 to +18
>>>>>>> 7931dbd (Added validate_domain in electrum option)
=======
>>>>>>> a2f5954 (Clean up commands.rs and handlers.rs per review comments)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>>>>>> 7931dbd (Added validate_domain in electrum option)
=======
>>>>>>> a2f5954 (Clean up commands.rs and handlers.rs per review comments)

src/utils.rs Outdated
use std::fmt::Display;
use std::path::{Path, PathBuf};
use std::str::FromStr;
>>>>>>> 80e132f (Added validate-domain option config in utils.rs and made changes required to that.)
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
>>>>>>> 80e132f (Added validate-domain option config in utils.rs and made changes required to that.)

Copy link
Copy Markdown
Contributor

@va-an va-an left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, please fill out the PR template provided in this repo - it includes checklists that help catch issues like, you know, the code not actually compiling.

@Rahamath-unnisa Rahamath-unnisa force-pushed the validate_domain-config branch from 1fc13e4 to 546948e Compare March 29, 2026 15:02
@Rahamath-unnisa
Copy link
Copy Markdown
Author

Hi @va-an,

Thanks for your feedback.

I’ve now:

  • Squashed all changes into a single commit
  • Fixed Cargo.toml by restoring upstream version
  • Removed leftover conflict markers and cleaned up code

Please review again. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

Add validate_domain Electrum option

4 participants