`populate_with_outpoints` discarded every error returned by `fetch_tx`,
so a connection, TLS or timeout failure made `sync` report success
without any data for the requested outpoint. A spend of that outpoint
was then missed and the UTXO kept being treated as unspent.
Skip the outpoint only on `Error::Protocol` and propagate all other
errors, matching `populate_with_txids`.
// Collect valid outpoints with their corresponding `spk` and `tx`.
let mut ops_spks_txs = Vec::new();
for op in outpoints {
- if let Ok(tx) = self.fetch_tx(op.txid) {
- if let Some(txout) = tx.output.get(op.vout as usize) {
- ops_spks_txs.push((op, txout.script_pubkey.clone(), tx));
- }
+ let tx = match self.fetch_tx(op.txid) {
+ Ok(tx) => tx,
+ Err(electrum_client::Error::Protocol(_)) => continue,
+ Err(e) => return Err(e),
+ };
+ if let Some(txout) = tx.output.get(op.vout as usize) {
+ ops_spks_txs.push((op, txout.script_pubkey.clone(), tx));
}
}