Skip to content

Commit

Permalink
Updated electrum config to support socks5 & validate_domain
Browse files Browse the repository at this point in the history
  • Loading branch information
i5hi committed Sep 20, 2024
1 parent 7c2b74c commit bf7c435
Showing 1 changed file with 11 additions and 3 deletions.
14 changes: 11 additions & 3 deletions lwk_wollet/src/clients/electrum_client.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use crate::store::Height;
use crate::Error;
use electrum_client::ScriptStatus;
use electrum_client::{Client, ConfigBuilder, ElectrumApi, GetHistoryRes};
use electrum_client::{ScriptStatus, Socks5Config};
use elements::encode::deserialize as elements_deserialize;
use elements::encode::serialize as elements_serialize;
use elements::Address;
Expand Down Expand Up @@ -98,7 +98,13 @@ impl ElectrumUrl {
}
ElectrumUrl::Plaintext(url) => (format!("tcp://{}", url), builder),
};
let builder = builder.timeout(options.timeout);
let socks5_config = options.socks5.as_ref().map(Socks5Config::new);

let builder = builder
.timeout(options.timeout)
.socks5(socks5_config)
.validate_domain(options.validate_domain);

Ok(Client::from_config(&url, builder.build())?)
}
}
Expand All @@ -113,7 +119,9 @@ impl Debug for ElectrumClient {

#[derive(Default)]
pub struct ElectrumOptions {
timeout: Option<u8>,
pub timeout: Option<u8>,
pub socks5: Option<String>,
pub validate_domain: bool,
}

impl ElectrumClient {
Expand Down

0 comments on commit bf7c435

Please sign in to comment.