Skip to content
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

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ Changelog info is also documented on the [GitHub releases](https://github.com/bi
page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.

## [Unreleased]
- Added the `validate_domain` option to Electrum arguments.

## [0.27.1]
- Added hardware signers through the use of HWI.
Expand Down
14 changes: 13 additions & 1 deletion src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,6 +320,10 @@ pub struct ElectrumOpts {
default_value = "10"
)]
pub stop_gap: usize,

/// Enable domain validation when connecting to Electrum servers [default: true].
#[clap(name = "VALIDATE_DOMAIN", long = "validate_domain")]
Copy link
Member

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.

Copy link
Contributor Author

@dspicher dspicher Jun 16, 2023

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.

pub validate_domain: Option<bool>,
}

/// Options to configure Esplora backend.
Expand Down Expand Up @@ -663,6 +667,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
Expand Down Expand Up @@ -707,6 +712,7 @@ mod test {
"--change_descriptor", "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)",
"--server","ssl://electrum.blockstream.info:50002",
"--stop_gap", "20",
"--validate_domain", "false",
"get_new_address"];

let cli_opts = CliOpts::from_iter(&cli_args);
Expand All @@ -723,7 +729,8 @@ mod test {
electrum_opts: ElectrumOpts {
timeout: Some(10),
server: "ssl://electrum.blockstream.info:50002".to_string(),
stop_gap: 20
stop_gap: 20,
validate_domain: Some(false),
},
proxy_opts: ProxyOpts{
proxy: Some("127.0.0.1:9150".to_string()),
Expand Down Expand Up @@ -927,6 +934,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
Expand Down Expand Up @@ -1006,6 +1014,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
Expand Down Expand Up @@ -1078,6 +1087,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
Expand Down Expand Up @@ -1149,6 +1159,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
#[cfg(feature = "esplora")]
esplora_opts: EsploraOpts {
Expand Down Expand Up @@ -1486,6 +1497,7 @@ mod test {
timeout: None,
server: "ssl://electrum.blockstream.info:60002".to_string(),
stop_gap: 10,
validate_domain: None,
},
},
};
Expand Down
2 changes: 1 addition & 1 deletion src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.unwrap_or(true),
})
};

Expand Down