[bdk_chain_redesign] Add ..in_chain methods

Add methods to `TxGraph` and `IndexedTxGraph` that gets in-best-chain
data (such as transactions, txouts, unspent txouts).
This commit is contained in:
志宇
2023-03-26 11:24:30 +08:00
parent 61a8606fbc
commit 43b648fee0
10 changed files with 236 additions and 64 deletions

View File

@@ -88,9 +88,11 @@ impl<K> Deref for KeychainTxOutIndex<K> {
}
}
impl<K: Clone + Ord + Debug> TxIndex for KeychainTxOutIndex<K> {
impl<K: Clone + Ord + Debug + 'static> TxIndex for KeychainTxOutIndex<K> {
type Additions = DerivationAdditions<K>;
type SpkIndex = (K, u32);
fn index_txout(&mut self, outpoint: OutPoint, txout: &TxOut) -> Self::Additions {
self.scan_txout(outpoint, txout)
}
@@ -102,6 +104,10 @@ impl<K: Clone + Ord + Debug> TxIndex for KeychainTxOutIndex<K> {
fn is_tx_relevant(&self, tx: &bitcoin::Transaction) -> bool {
self.is_relevant(tx)
}
fn relevant_txouts(&self) -> &BTreeMap<OutPoint, (Self::SpkIndex, TxOut)> {
self.inner.relevant_txouts()
}
}
impl<K: Clone + Ord + Debug> KeychainTxOutIndex<K> {