Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,20 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
}
}

/// Creates a new BDK Electrum client from a URL with custom configuration.
/// can be used as a convenience method for creating an Electrum client with custom settings
/// such as JWT authorization providers, timeouts, or proxy settings.
impl BdkElectrumClient<electrum_client::Client> {
/// [`electrum_client::ConfigBuilder`]: crate::electrum_client::ConfigBuilder
pub fn from_config(
url: &str,
config: electrum_client::Config,
) -> Result<Self, electrum_client::Error> {
let client = electrum_client::Client::from_config(url, config)?;
Ok(Self::new(client))
}
}

/// Return a [`CheckPoint`] of the latest tip, that connects with `prev_tip`. The latest blocks are
/// fetched to construct checkpoint updates with the proper [`BlockHash`] in case of re-org.
fn fetch_tip_and_latest_blocks(
Expand Down
3 changes: 3 additions & 0 deletions crates/electrum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
//! [`example_electrum`]: https://github.com/bitcoindevkit/bdk/tree/master/examples/example_electrum
//! [`SyncResponse`]: bdk_core::spk_client::SyncResponse
//! [`FullScanResponse`]: bdk_core::spk_client::FullScanResponse
//! [`AuthProvider`]: electrum_client::config::AuthProvider
#![cfg_attr(coverage_nightly, feature(coverage_attribute))]
#![warn(missing_docs)]

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

pub use bdk_core;
pub use electrum_client;

pub use electrum_client::{Config, ConfigBuilder};