Skip to content

Commit 470464d

Browse files
committed
add validate domain option to electrum
This has been added to bdk in bitcoindevkit/bdk@8d4cc39
1 parent eef97ad commit 470464d

File tree

3 files changed

+15
-2
lines changed

3 files changed

+15
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Changelog info is also documented on the [GitHub releases](https://github.com/bi
44
page. See [DEVELOPMENT_CYCLE.md](DEVELOPMENT_CYCLE.md) for more details.
55

66
## [Unreleased]
7+
- Added the `validate_domain` option to Electrum arguments.
78

89
## [0.27.1]
910
- Added hardware signers through the use of HWI.

src/commands.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,10 @@ pub struct ElectrumOpts {
320320
default_value = "10"
321321
)]
322322
pub stop_gap: usize,
323+
324+
/// Enable domain validation when connecting to Electrum servers [default: true].
325+
#[clap(name = "VALIDATE_DOMAIN", long = "validate_domain")]
326+
pub validate_domain: Option<bool>,
323327
}
324328

325329
/// Options to configure Esplora backend.
@@ -663,6 +667,7 @@ mod test {
663667
timeout: None,
664668
server: "ssl://electrum.blockstream.info:60002".to_string(),
665669
stop_gap: 10,
670+
validate_domain: None,
666671
},
667672
#[cfg(feature = "esplora")]
668673
esplora_opts: EsploraOpts {
@@ -707,6 +712,7 @@ mod test {
707712
"--change_descriptor", "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)",
708713
"--server","ssl://electrum.blockstream.info:50002",
709714
"--stop_gap", "20",
715+
"--validate_domain", "false",
710716
"get_new_address"];
711717

712718
let cli_opts = CliOpts::from_iter(&cli_args);
@@ -723,7 +729,8 @@ mod test {
723729
electrum_opts: ElectrumOpts {
724730
timeout: Some(10),
725731
server: "ssl://electrum.blockstream.info:50002".to_string(),
726-
stop_gap: 20
732+
stop_gap: 20,
733+
validate_domain: Some(false),
727734
},
728735
proxy_opts: ProxyOpts{
729736
proxy: Some("127.0.0.1:9150".to_string()),
@@ -927,6 +934,7 @@ mod test {
927934
timeout: None,
928935
server: "ssl://electrum.blockstream.info:60002".to_string(),
929936
stop_gap: 10,
937+
validate_domain: None,
930938
},
931939
#[cfg(feature = "esplora")]
932940
esplora_opts: EsploraOpts {
@@ -1006,6 +1014,7 @@ mod test {
10061014
timeout: None,
10071015
server: "ssl://electrum.blockstream.info:60002".to_string(),
10081016
stop_gap: 10,
1017+
validate_domain: None,
10091018
},
10101019
#[cfg(feature = "esplora")]
10111020
esplora_opts: EsploraOpts {
@@ -1078,6 +1087,7 @@ mod test {
10781087
timeout: None,
10791088
server: "ssl://electrum.blockstream.info:60002".to_string(),
10801089
stop_gap: 10,
1090+
validate_domain: None,
10811091
},
10821092
#[cfg(feature = "esplora")]
10831093
esplora_opts: EsploraOpts {
@@ -1149,6 +1159,7 @@ mod test {
11491159
timeout: None,
11501160
server: "ssl://electrum.blockstream.info:60002".to_string(),
11511161
stop_gap: 10,
1162+
validate_domain: None,
11521163
},
11531164
#[cfg(feature = "esplora")]
11541165
esplora_opts: EsploraOpts {
@@ -1486,6 +1497,7 @@ mod test {
14861497
timeout: None,
14871498
server: "ssl://electrum.blockstream.info:60002".to_string(),
14881499
stop_gap: 10,
1500+
validate_domain: None,
14891501
},
14901502
},
14911503
};

src/utils.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -400,7 +400,7 @@ pub(crate) fn new_blockchain(
400400
retry: wallet_opts.proxy_opts.retries,
401401
timeout: wallet_opts.electrum_opts.timeout,
402402
stop_gap: wallet_opts.electrum_opts.stop_gap,
403-
validate_domain: true,
403+
validate_domain: wallet_opts.electrum_opts.validate_domain.unwrap_or(true),
404404
})
405405
};
406406

0 commit comments

Comments
 (0)