Skip to content

Commit 1a50684

Browse files
authored
Merge pull request #4341 from tnull/2026-01-electrum-improvements
`ElectrumSyncClient`: Skip unconfirmed `get_history` entries
2 parents 16973b2 + cc1eb16 commit 1a50684

File tree

1 file changed

+13
-1
lines changed

1 file changed

+13
-1
lines changed

lightning-transaction-sync/src/electrum.rs

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -336,17 +336,29 @@ where
336336
script_history.iter().filter(|h| h.tx_hash == **txid);
337337
if let Some(history) = filtered_history.next() {
338338
let prob_conf_height = history.height as u32;
339+
if prob_conf_height <= 0 {
340+
// Skip if it's a an unconfirmed entry.
341+
continue;
342+
}
339343
let confirmed_tx = self.get_confirmed_tx(tx, prob_conf_height)?;
340344
confirmed_txs.push(confirmed_tx);
341345
}
342-
debug_assert!(filtered_history.next().is_none());
346+
if filtered_history.next().is_some() {
347+
log_error!(
348+
self.logger,
349+
"Failed due to server returning multiple history entries for Tx {}.",
350+
txid
351+
);
352+
return Err(InternalError::Failed);
353+
}
343354
}
344355

345356
for (watched_output, script_history) in
346357
sync_state.watched_outputs.values().zip(output_results)
347358
{
348359
for possible_output_spend in script_history {
349360
if possible_output_spend.height <= 0 {
361+
// Skip if it's a an unconfirmed entry.
350362
continue;
351363
}
352364

0 commit comments

Comments
 (0)