]> Untitled Git - bdk/commitdiff
Clarify `TxGraph::try_filter_chain_unspents` logic
author志宇 <hello@evanlinjin.me>
Thu, 11 May 2023 03:59:57 +0000 (11:59 +0800)
committer志宇 <hello@evanlinjin.me>
Thu, 11 May 2023 03:59:57 +0000 (11:59 +0800)
crates/chain/src/tx_graph.rs

index f0a095ace64ec6677d8da9f93a13981bab517148..b56fbf627fc92a6b44220cfe3d49e81c7dedebad 100644 (file)
@@ -865,7 +865,12 @@ impl<A: Anchor> TxGraph<A> {
         outpoints: impl IntoIterator<Item = (S, OutPoint)> + 'a,
     ) -> impl Iterator<Item = Result<(S, FullTxOut<ObservedAs<A>>), C::Error>> + 'a {
         self.try_filter_chain_txouts(chain, chain_tip, outpoints)
-            .filter(|r| !matches!(r, Ok((_, full_txo)) if full_txo.spent_by.is_some()))
+            .filter(|r| match r {
+                // keep unspents, drop spents
+                Ok((_, full_txo)) => full_txo.spent_by.is_none(),
+                // keep errors
+                Err(_) => true,
+            })
     }
 
     /// Get a filtered list of unspent outputs (UTXOs) from the given `outpoints` that are in