Skip to content

Commit 5bcc4f4

Browse files
committed
fix(electrum): fix stale anchor hash on reorg
1 parent 8d9df97 commit 5bcc4f4

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

crates/electrum/src/bdk_electrum_client.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -501,17 +501,16 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
501501
if let Some(anchor) = anchor_cache.get(&(txid, hash)) {
502502
results.push((txid, *anchor));
503503
} else {
504-
to_fetch.push((txid, height, hash));
504+
to_fetch.push((txid, height));
505505
}
506506
}
507507
}
508508

509509
// 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)?;
510+
let proofs = self.inner.batch_transaction_get_merkle(to_fetch.iter())?;
512511

513512
// Validate each proof, retrying once for each stale header.
514-
for ((txid, height, hash), proof) in to_fetch.into_iter().zip(proofs.into_iter()) {
513+
for ((txid, height), proof) in to_fetch.into_iter().zip(proofs.into_iter()) {
515514
let mut header = {
516515
let cache = self.block_header_cache.lock().unwrap();
517516
cache
@@ -536,6 +535,7 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
536535

537536
// Build and cache the anchor if merkle proof is valid.
538537
if valid {
538+
let hash = header.block_hash();
539539
let anchor = ConfirmationBlockTime {
540540
confirmation_time: header.time as u64,
541541
block_id: BlockId {

0 commit comments

Comments
 (0)