Skip to content

Commit 5e2615f

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 5e2615f

File tree

2 files changed

+10
-17
lines changed

2 files changed

+10
-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: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -506,23 +506,17 @@ 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: Vec<(Txid, usize)> = to_fetch
511+
.iter()
512+
.map(|element| (element.0, element.1))
513+
.collect();
514+
let proofs = self
515+
.inner
516+
.batch_transaction_get_merkle(&txids_and_heights)?;
521517

522518
// 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-
519+
for ((txid, height, hash), proof) in to_fetch.into_iter().zip(proofs.into_iter()) {
526520
let mut header = {
527521
let cache = self.block_header_cache.lock().unwrap();
528522
cache

0 commit comments

Comments
 (0)