Skip to content

Commit b663940

Browse files
committed
chore(bdk-electrum): use new batch_transaction_get_merkle API
- removes the now unused `serde_json` dependency from `bdk_electrum`. - update `batch_fetch_anchors` to use `batch_transaction_get_merkle` method instead of manually creating the batch call.
1 parent a48c97a commit b663940

File tree

2 files changed

+5
-17
lines changed

2 files changed

+5
-17
lines changed

crates/electrum/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@ workspace = true
1414

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

2019
[dev-dependencies]
2120
bdk_testenv = { path = "../testenv" }

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 4 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,23 +506,12 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
506506
}
507507
}
508508

509-
// Batch all get_merkle calls.
510-
let mut batch = electrum_client::Batch::default();
511-
for &(txid, height, _) in &to_fetch {
512-
batch.raw(
513-
"blockchain.transaction.get_merkle".into(),
514-
vec![
515-
electrum_client::Param::String(format!("{txid:x}")),
516-
electrum_client::Param::Usize(height),
517-
],
518-
);
519-
}
520-
let resps = self.inner.batch_call(&batch)?;
509+
// Fetch merkle proofs.
510+
let txids_and_heights = to_fetch.iter().map(|&(txid, height, _)| (txid, height));
511+
let proofs = self.inner.batch_transaction_get_merkle(txids_and_heights)?;
521512

522513
// Validate each proof, retrying once for each stale header.
523-
for ((txid, height, hash), resp) in to_fetch.into_iter().zip(resps.into_iter()) {
524-
let proof: electrum_client::GetMerkleRes = serde_json::from_value(resp)?;
525-
514+
for ((txid, height, hash), proof) in to_fetch.into_iter().zip(proofs.into_iter()) {
526515
let mut header = {
527516
let cache = self.block_header_cache.lock().unwrap();
528517
cache

0 commit comments

Comments
 (0)