-
Notifications
You must be signed in to change notification settings - Fork 65
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
add validate domain option to electrum #155
base: master
Are you sure you want to change the base?
Conversation
985ff9f
to
c6c44e1
Compare
Take a look at the utils.rs file and on line 403 you need to use this new param you're adding. |
@@ -320,6 +320,10 @@ pub struct ElectrumOpts { | |||
default_value = "10" | |||
)] | |||
pub stop_gap: usize, | |||
|
|||
/// Enable domain validation when connecting to Electrum servers. | |||
#[clap(name = "VALIDATE_DOMAIN", long = "validate_domain")] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the utils.rs
the default for this value is true, as you have it here the user will be required to set the value to true
or false
. It's better if you set the clap default_value
to true then the user only needs to do something if they want it to be false.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done. Also added a v
short option.
Ah yeah, makes sense. Fixed. |
719c23b
to
976373d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ACK 976373d
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I tested this and realized the approach won't work since clap treats bool
as a "flag" with no way to set to false
if the default is true
. See comments for how to fix.
src/commands.rs
Outdated
@@ -320,6 +320,14 @@ pub struct ElectrumOpts { | |||
default_value = "10" | |||
)] | |||
pub stop_gap: usize, | |||
|
|||
/// Enable domain validation when connecting to Electrum servers. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to make it an Option and set the default in the code, see below.
/// Enable domain validation when connecting to Electrum servers. | |
/// Enable domain validation when connecting to Electrum servers [default: true] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/commands.rs
Outdated
#[clap( | ||
name = "VALIDATE_DOMAIN", | ||
long = "validate_domain", | ||
default_value = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Remove default.
default_value = "true" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/commands.rs
Outdated
long = "validate_domain", | ||
default_value = "true" | ||
)] | ||
pub validate_domain: bool, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Change type to Option:
pub validate_domain: bool, | |
pub validate_domain: Option<bool>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
src/utils.rs
Outdated
@@ -400,7 +400,7 @@ pub(crate) fn new_blockchain( | |||
retry: wallet_opts.proxy_opts.retries, | |||
timeout: wallet_opts.electrum_opts.timeout, | |||
stop_gap: wallet_opts.electrum_opts.stop_gap, | |||
validate_domain: true, | |||
validate_domain: wallet_opts.electrum_opts.validate_domain, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Default to true here:
validate_domain: wallet_opts.electrum_opts.validate_domain, | |
validate_domain: wallet_opts.electrum_opts.validate_domain.unwrap_or(true), |
You'll also need to fix the corresponding tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
976373d
to
470464d
Compare
This has been added to bdk in bitcoindevkit/bdk@8d4cc39
470464d
to
230fb1f
Compare
Description
Added the
validate_domain
option to Electrum arguments.Since #151 seems dormant, I took another stab at this.
Fixes #134.
Changelog notice
Added the
validate_domain
option to Electrum arguments.Checklists
All Submissions:
cargo fmt
andcargo clippy
before committingNew Features:
CHANGELOG.md