From 976373d257b52ba8fba8e5f24088d666816a9947 Mon Sep 17 00:00:00 2001 From: Dominik Spicher Date: Fri, 9 Jun 2023 10:12:26 +0200 Subject: [PATCH] add validate domain option to electrum This has been added to bdk in https://github.com/bitcoindevkit/bdk/commit/8d4cc3920ab4177fd0f3916155671b1067285eda --- CHANGELOG.md | 1 + src/commands.rs | 17 ++++++++++++++++- src/utils.rs | 2 +- 3 files changed, 18 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 15627f0..a83eb86 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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. diff --git a/src/commands.rs b/src/commands.rs index c8d7c0b..ac9f466 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -320,6 +320,14 @@ 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", + default_value = "true" + )] + pub validate_domain: bool, } /// Options to configure Esplora backend. @@ -663,6 +671,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { @@ -723,7 +732,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: true, }, proxy_opts: ProxyOpts{ proxy: Some("127.0.0.1:9150".to_string()), @@ -927,6 +937,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { @@ -1006,6 +1017,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { @@ -1078,6 +1090,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { @@ -1149,6 +1162,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, #[cfg(feature = "esplora")] esplora_opts: EsploraOpts { @@ -1486,6 +1500,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, }, }; diff --git a/src/utils.rs b/src/utils.rs index e29fed5..c53997b 100644 --- a/src/utils.rs +++ b/src/utils.rs @@ -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, }) };