Skip to content

Commit a09f12a

Browse files
committed
Merge #1989: chore(bdk-electrum): use new batch_transaction_get_merkle API
b663940 chore(bdk-electrum): use new `batch_transaction_get_merkle` API (Leonardo Lima) Pull request description: fixes #1987 depends on bitcoindevkit/rust-electrum-client#170 ### Description - update `batch_fetch_anchors` to use `batch_transaction_get_merkle` method instead of manually creating the batch call. ### Changelog notice ```md ### Changes - Use new `batch_transaction_get_merkle` method instead of batch raw calls ``` ### Checklists #### All Submissions: * [x] I've signed all my commits * [x] I followed the [contribution guidelines](https://github.com/bitcoindevkit/bdk/blob/master/CONTRIBUTING.md) * [x] I ran `cargo +nightly fmt` and `cargo clippy` before committing ACKs for top commit: ValuedMammal: ACK b663940 LagginTimes: ACK b663940 Tree-SHA512: 8c08bcaf99bb65098015995eae67c710fbe2f8e76d47796aebbfba1c5a1c78174023be3cb21299e4c820d156110742c9e85819c253dcf9bc3e1fa1621ca35378
2 parents dcf8860 + b663940 commit a09f12a

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)