Skip to content
Merged
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
3 changes: 1 addition & 2 deletions crates/electrum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ workspace = true

[dependencies]
bdk_core = { path = "../core", version = "0.6.0" }
electrum-client = { version = "0.23.1", features = [ "proxy" ], default-features = false }
serde_json = "1.0"
electrum-client = { version = "0.24.0", features = [ "proxy" ], default-features = false }

[dev-dependencies]
bdk_testenv = { path = "../testenv" }
Expand Down
19 changes: 4 additions & 15 deletions crates/electrum/src/bdk_electrum_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -506,23 +506,12 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
}
}

// Batch all get_merkle calls.
let mut batch = electrum_client::Batch::default();
for &(txid, height, _) in &to_fetch {
batch.raw(
"blockchain.transaction.get_merkle".into(),
vec![
electrum_client::Param::String(format!("{txid:x}")),
electrum_client::Param::Usize(height),
],
);
}
let resps = self.inner.batch_call(&batch)?;
// Fetch merkle proofs.
let txids_and_heights = to_fetch.iter().map(|&(txid, height, _)| (txid, height));
let proofs = self.inner.batch_transaction_get_merkle(txids_and_heights)?;

// Validate each proof, retrying once for each stale header.
for ((txid, height, hash), resp) in to_fetch.into_iter().zip(resps.into_iter()) {
let proof: electrum_client::GetMerkleRes = serde_json::from_value(resp)?;

for ((txid, height, hash), proof) in to_fetch.into_iter().zip(proofs.into_iter()) {
let mut header = {
let cache = self.block_header_cache.lock().unwrap();
cache
Expand Down
Loading