Skip to content

Commit 0b5dae7

Browse files
Fix txid comparison in mempool eviction logic by normalizing byte order
1 parent 3d35691 commit 0b5dae7

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

src/chain/bitcoind.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ use serde::Serialize;
3838

3939
use base64::prelude::BASE64_STANDARD;
4040
use base64::Engine;
41+
use bitcoin::hashes::Hash;
4142
use bitcoin::{BlockHash, FeeRate, Network, Transaction, Txid};
4243

4344
use std::collections::{HashMap, VecDeque};
@@ -1121,7 +1122,12 @@ impl BitcoindClient {
11211122
let mempool_entries_cache = mempool_entries_cache.lock().await;
11221123
let evicted_txids = unconfirmed_txids
11231124
.into_iter()
1124-
.filter(|txid| mempool_entries_cache.contains_key(txid))
1125+
.filter(|txid| {
1126+
let mut bytes = txid.to_byte_array();
1127+
bytes.reverse();
1128+
let normalized_txid = Txid::from_byte_array(bytes);
1129+
!mempool_entries_cache.contains_key(&normalized_txid)
1130+
})
11251131
.map(|txid| (txid, latest_mempool_timestamp))
11261132
.collect();
11271133
Ok(evicted_txids)

0 commit comments

Comments
 (0)