]> Untitled Git - bdk/commitdiff
fix(electrum): propagate transport errors when syncing outpoints
authorchaitika <chaitikab@gmail.com>
Sat, 26 Sep 2026 15:17:00 +0000 (20:47 +0530)
committerchaitika <chaitikab@gmail.com>
Sat, 26 Sep 2026 15:19:57 +0000 (20:49 +0530)
`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`.

crates/electrum/src/bdk_electrum_client.rs

index a7c943150a6ac0b1e51ff564aec656c1d9afbb4c..ba1f104307027a4ca70d41593a7498639472c1ca 100644 (file)
@@ -360,10 +360,13 @@ impl<E: ElectrumApi> BdkElectrumClient<E> {
         // 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));
             }
         }