Merge bitcoindevkit/bdk#805: electrum: add validate_domain to ElectrumBlockchainConfig

2451c00268a8b518212c59132c263bc186d1b0f9 electrum: add validate_domain to ElectrumBlockchainConfig (Igor Cota)

Pull request description:

  ### Description

  The purpose of the PR is to be able to configure both `stop_gap` **and** `validate_domain`. Perhaps there are nicer ways.

  #### All Submissions:

  * [x] I've signed all my commits
  * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md)
  * [x] I ran `cargo fmt` and `cargo clippy` before committing

  #### Bugfixes:

  * [x] This pull request breaks the existing API
  * [x] I'm linking the issue being fixed by this PR

  Issue in https://github.com/bitcoindevkit/bdk/issues/804

ACKs for top commit:
  notmandatory:
    ACK 2451c00268a8b518212c59132c263bc186d1b0f9

Tree-SHA512: e10e3a027c202c8e680e5181f2a98c9ca30fa7773660cc47bef93f557cdc94c09e46b154b0edee65e498a49bc997cc9172eb3782dc4310d5775c0763d8c2ca4a
This commit is contained in:
Steve Myers 2022-12-23 16:27:45 -08:00
commit 8d4cc3920a
No known key found for this signature in database
GPG Key ID: 8105A46B22C2D051
2 changed files with 7 additions and 1 deletions

View File

@ -178,7 +178,8 @@ impl_from!(boxed rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]
/// "type" : "electrum", /// "type" : "electrum",
/// "url" : "ssl://electrum.blockstream.info:50002", /// "url" : "ssl://electrum.blockstream.info:50002",
/// "retry": 2, /// "retry": 2,
/// "stop_gap": 20 /// "stop_gap": 20,
/// "validate_domain": true
/// }"#, /// }"#,
/// ) /// )
/// .unwrap(); /// .unwrap();
@ -190,6 +191,7 @@ impl_from!(boxed rpc::RpcBlockchain, AnyBlockchain, Rpc, #[cfg(feature = "rpc")]
/// socks5: None, /// socks5: None,
/// timeout: None, /// timeout: None,
/// stop_gap: 20, /// stop_gap: 20,
/// validate_domain: true,
/// }) /// })
/// ); /// );
/// # } /// # }

View File

@ -312,6 +312,8 @@ pub struct ElectrumBlockchainConfig {
pub timeout: Option<u8>, pub timeout: Option<u8>,
/// Stop searching addresses for transactions after finding an unused gap of this length /// Stop searching addresses for transactions after finding an unused gap of this length
pub stop_gap: usize, pub stop_gap: usize,
/// Validate the domain when using SSL
pub validate_domain: bool,
} }
impl ConfigurableBlockchain for ElectrumBlockchain { impl ConfigurableBlockchain for ElectrumBlockchain {
@ -323,6 +325,7 @@ impl ConfigurableBlockchain for ElectrumBlockchain {
.retry(config.retry) .retry(config.retry)
.timeout(config.timeout)? .timeout(config.timeout)?
.socks5(socks5)? .socks5(socks5)?
.validate_domain(config.validate_domain)
.build(); .build();
Ok(ElectrumBlockchain { Ok(ElectrumBlockchain {
@ -417,6 +420,7 @@ mod test {
retry: 0, retry: 0,
timeout: None, timeout: None,
stop_gap: stop_gap, stop_gap: stop_gap,
validate_domain: true,
}) })
} }
} }