From 8a69f8083ec834b58fbd7ba294f2f19387f76c02 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Mon, 3 Apr 2023 11:25:54 +0530 Subject: [PATCH 1/3] Added validate_domain Electrum option --- src/commands.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/src/commands.rs b/src/commands.rs index c8d7c0b..13508ce 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -320,6 +320,16 @@ pub struct ElectrumOpts { default_value = "10" )] pub stop_gap: usize, + + /// Enable or disable domain validation when connecting to Electrum servers. + #[clap( + name = "VALIDATE_DOMAIN", + long = "validate_domain", + possible_values = &["true", "false"], + case_insensitive = true, + default_value = "true" + )] + pub validate_domain: bool, } /// Options to configure Esplora backend. From 2a274d0d073d73f1e1131ddc2fd4c8005dc476cd Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Tue, 4 Apr 2023 08:04:09 +0530 Subject: [PATCH 2/3] Fix the test Signed-off-by: Anmol Agrawal --- src/commands.rs | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/src/commands.rs b/src/commands.rs index 13508ce..d63c1c4 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -673,6 +673,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 { @@ -717,6 +718,7 @@ mod test { "--change_descriptor", "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)", "--server","ssl://electrum.blockstream.info:50002", "--stop_gap", "20", + "--validate_domain", "true", "get_new_address"]; let cli_opts = CliOpts::from_iter(&cli_args); @@ -733,7 +735,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()), @@ -937,6 +940,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 { @@ -1016,6 +1020,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 { @@ -1088,6 +1093,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 { @@ -1159,6 +1165,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 { @@ -1496,6 +1503,7 @@ mod test { timeout: None, server: "ssl://electrum.blockstream.info:60002".to_string(), stop_gap: 10, + validate_domain: true, }, }, }; From d9ef05f9078381a2f1fd49853bb5857b28b4de68 Mon Sep 17 00:00:00 2001 From: Anmol Agrawal Date: Sun, 9 Apr 2023 15:13:00 +0530 Subject: [PATCH 3/3] lint fixed --- src/commands.rs | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/src/commands.rs b/src/commands.rs index d63c1c4..e57ef94 100644 --- a/src/commands.rs +++ b/src/commands.rs @@ -322,14 +322,8 @@ pub struct ElectrumOpts { pub stop_gap: usize, /// Enable or disable domain validation when connecting to Electrum servers. - #[clap( - name = "VALIDATE_DOMAIN", - long = "validate_domain", - possible_values = &["true", "false"], - case_insensitive = true, - default_value = "true" - )] - pub validate_domain: bool, + #[clap(name = "VALIDATE_DOMAIN", long = "validate_domain", takes_value(false))] + pub validate_domain: Option, } /// Options to configure Esplora backend. @@ -718,7 +712,7 @@ mod test { "--change_descriptor", "wpkh(tpubDEnoLuPdBep9bzw5LoGYpsxUQYheRQ9gcgrJhJEcdKFB9cWQRyYmkCyRoTqeD4tJYiVVgt6A3rN6rWn9RYhR9sBsGxji29LYWHuKKbdb1ev/1/*)", "--server","ssl://electrum.blockstream.info:50002", "--stop_gap", "20", - "--validate_domain", "true", + "--validate_domain" "get_new_address"]; let cli_opts = CliOpts::from_iter(&cli_args);