Skip to content

Commit 174ff05

Browse files
committed
feat(electrum): add custom authentication support via ConfigBuilder
1 parent a161ee2 commit 174ff05

2 files changed

Lines changed: 17 additions & 0 deletions

File tree

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -603,6 +603,20 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
603603
}
604604
}
605605

606+
/// Creates a new BDK Electrum client from a URL with custom configuration.
607+
/// can be used as a convenience method for creating an Electrum client with custom settings
608+
/// such as JWT authorization providers, timeouts, or proxy settings.
609+
impl BdkElectrumClient<electrum_client::Client> {
610+
/// [`electrum_client::ConfigBuilder`]: crate::electrum_client::ConfigBuilder
611+
pub fn from_config(
612+
url: &str,
613+
config: electrum_client::Config,
614+
) -> Result<Self, electrum_client::Error> {
615+
let client = electrum_client::Client::from_config(url, config)?;
616+
Ok(Self::new(client))
617+
}
618+
}
619+
606620
/// Return a [`CheckPoint`] of the latest tip, that connects with `prev_tip`. The latest blocks are
607621
/// fetched to construct checkpoint updates with the proper [`BlockHash`] in case of re-org.
608622
fn fetch_tip_and_latest_blocks(

crates/electrum/src/lib.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
//! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/examples/example_electrum
1717
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
1818
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse
19+
//! [`AuthProvider`]: electrum_client::config::AuthProvider
1920
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
2021
#![warn(missing_docs)]
2122

@@ -24,3 +25,5 @@ pub use bdk_electrum_client::*;
2425

2526
pub use bdk_core;
2627
pub use electrum_client;
28+
29+
pub use electrum_client::{Config, ConfigBuilder};

0 commit comments

Comments
 (0)