Skip to content

Commit f87a224

Browse files
committed
feat: add proxy to electrum
1 parent 2febf69 commit f87a224

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

bdk-ffi/src/bdk.udl

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -986,6 +986,10 @@ interface ElectrumClient {
986986
[Throws=ElectrumError]
987987
constructor(string url);
988988

989+
/// Set the proxy of the builder
990+
[Name=new_with_proxy, Throws=ElectrumError]
991+
constructor(string url, string proxy);
992+
989993
/// Full scan the keychain scripts specified with the blockchain (via an Electrum client) and
990994
/// returns updates for bdk_chain data structures.
991995
///

bdk-ffi/src/electrum.rs

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,18 @@ impl ElectrumClient {
3232
Ok(Self(client))
3333
}
3434

35+
pub fn new_with_proxy(url: String, proxy: String) -> Result<Self, ElectrumError> {
36+
let config = bdk_electrum::electrum_client::ConfigBuilder::new()
37+
.socks5(Some(bdk_electrum::electrum_client::Socks5Config::new(
38+
proxy.as_str(),
39+
)))
40+
.build();
41+
let inner_client =
42+
bdk_electrum::electrum_client::Client::from_config(url.as_str(), config)?;
43+
let client = BdkBdkElectrumClient::new(inner_client);
44+
Ok(Self(client))
45+
}
46+
3547
pub fn full_scan(
3648
&self,
3749
request: Arc<FullScanRequest>,

0 commit comments

Comments
 (0)