From: 志宇 Date: Thu, 11 May 2023 03:59:57 +0000 (+0800) Subject: Clarify `TxGraph::try_filter_chain_unspents` logic X-Git-Tag: v1.0.0-alpha.1~12^2~1 X-Git-Url: http://internal-gitweb-vhost/script/%22https:/struct.ScriptPath.html?a=commitdiff_plain;h=fb75aa94a9f47d53ce7246c14d739fc53dc38197;p=bdk Clarify `TxGraph::try_filter_chain_unspents` logic --- diff --git a/crates/chain/src/tx_graph.rs b/crates/chain/src/tx_graph.rs index f0a095ac..b56fbf62 100644 --- a/crates/chain/src/tx_graph.rs +++ b/crates/chain/src/tx_graph.rs @@ -865,7 +865,12 @@ impl TxGraph { outpoints: impl IntoIterator + 'a, ) -> impl Iterator>), 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