diff --git a/src/bitcoin/mod.rs b/src/bitcoin/mod.rs index 60388c1e..6c41c40c 100644 --- a/src/bitcoin/mod.rs +++ b/src/bitcoin/mod.rs @@ -116,6 +116,11 @@ pub trait BitcoinInterface: Send { /// Get the details of unconfirmed transactions spending these outpoints, if any. fn mempool_spenders(&self, outpoints: &[bitcoin::OutPoint]) -> Vec; + + /// Get mempool data for the given transaction. + /// + /// Returns `None` if the transaction is not in the mempool. + fn mempool_entry(&self, txid: &bitcoin::Txid) -> Option; } impl BitcoinInterface for d::BitcoinD { @@ -366,6 +371,10 @@ impl BitcoinInterface for d::BitcoinD { .filter_map(|txid| self.mempool_entry(&txid)) .collect() } + + fn mempool_entry(&self, txid: &bitcoin::Txid) -> Option { + self.mempool_entry(txid) + } } // FIXME: do we need to repeat the entire trait implemenation? Isn't there a nicer way? @@ -456,6 +465,10 @@ impl BitcoinInterface for sync::Arc> fn mempool_spenders(&self, outpoints: &[bitcoin::OutPoint]) -> Vec { self.lock().unwrap().mempool_spenders(outpoints) } + + fn mempool_entry(&self, txid: &bitcoin::Txid) -> Option { + self.lock().unwrap().mempool_entry(txid) + } } // FIXME: We could avoid this type (and all the conversions entailing allocations) if bitcoind diff --git a/src/testutils.rs b/src/testutils.rs index 9034aaec..8359b75d 100644 --- a/src/testutils.rs +++ b/src/testutils.rs @@ -123,6 +123,10 @@ impl BitcoinInterface for DummyBitcoind { fn mempool_spenders(&self, _: &[bitcoin::OutPoint]) -> Vec { Vec::new() } + + fn mempool_entry(&self, _: &bitcoin::Txid) -> Option { + None + } } struct DummyDbState {