Skip to content
Open
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
85 changes: 80 additions & 5 deletions bdk-ffi/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion bdk-ffi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ path = "uniffi-bindgen.rs"
[dependencies]
bdk_wallet = { version = "=3.0.0", features = ["all-keys", "keys-bip39", "rusqlite"] }
bdk_esplora = { version = "0.22.1", default-features = false, features = ["std", "blocking", "blocking-https-rustls"] }
bdk_electrum = { version = "0.23.2", default-features = false, features = ["use-rustls-ring"] }
bdk_electrum = { version = "0.24.0", default-features = false, features = ["use-rustls-ring"] }
bdk_kyoto = { version = "0.17.0" }

uniffi = { version = "=0.30.0", features = ["cli"]}
Expand Down
15 changes: 13 additions & 2 deletions bdk-ffi/src/electrum.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ use bdk_wallet::bitcoin::hex::{Case, DisplayHex};
use std::collections::BTreeMap;
use std::convert::TryFrom;
use std::sync::Arc;
use std::time::Duration;

/// Wrapper around an electrum_client::ElectrumApi which includes an internal in-memory transaction
/// cache to avoid re-fetching already downloaded transactions.
Expand All @@ -29,15 +30,25 @@ pub struct ElectrumClient(BdkBdkElectrumClient<bdk_electrum::electrum_client::Cl
impl ElectrumClient {
/// Creates a new bdk client from a electrum_client::ElectrumApi
/// Optional: Set the proxy of the builder
/// Optional: Set the timeout (in seconds) of the builder
/// Optional: Set the retry attempts number of the builder
/// Optional: Set whether the server's TLS certificate is validated.
#[uniffi::constructor(default(socks5 = None, validate_domain = true))]
#[uniffi::constructor(default(socks5 = None, timeout = None, retry = None, validate_domain = true))]
pub fn new(
url: String,
socks5: Option<String>,
timeout: Option<u8>,
retry: Option<u8>,
validate_domain: bool,
) -> Result<Self, ElectrumError> {
let mut config = bdk_electrum::electrum_client::ConfigBuilder::new();
config = config.validate_domain(validate_domain);
if let Some(timeout) = timeout {
config = config.timeout(Some(Duration::from_secs(timeout.into())));
}
if let Some(retry) = retry {
config = config.retry(retry);
}
if let Some(socks5) = socks5 {
config = config.socks5(Some(bdk_electrum::electrum_client::Socks5Config::new(
socks5.as_str(),
Expand Down Expand Up @@ -169,7 +180,7 @@ impl ElectrumClient {
pub fn estimate_fee(&self, number: u64) -> Result<f64, ElectrumError> {
self.0
.inner
.estimate_fee(number as usize)
.estimate_fee(number as usize, None)
.map_err(ElectrumError::from)
}

Expand Down
Loading