What changed, and why it matters
This commit adds error handling around a list of notification callbacks in Electrum's Lightning network watcher. Previously, if one callback crashed with an error, all remaining callbacks were skipped. Now each callback is wrapped in a try/except so the loop continues and the crash is logged. This is a robustness improvement rather than a fix for an obvious attack path.
Treat as a routine robustness fix. Review whether any callback failure should additionally trigger alerts or safe-state transitions, but no urgent security response is indicated by the diff alone.
Security signals we found
Exception in callback loop could suppress remaining callbacks (denial-of-service-like behavior for downstream state updates)
No input validation or trust boundary change
No cryptographic or payment-flow logic modified
Change is defensive hardening with logging
Evidence from the diff
In electrum/lnwatcher.py, the loop that invokes registered LNWatcher callbacks now catches exceptions per-iteration instead of letting a single failing callback abort the entire batch. The change prevents one misbehaving callback from suppressing subsequent callbacks and from propagating an exception out of the watcher loop. It also logs the failing address for diagnostics.
Changed components
electrum/lnwatcher.pyLNWatcher callback dispatch loopInspect captured patch +4 / −1
diff --git a/electrum/lnwatcher.py b/electrum/lnwatcher.py
index 6a4842c..14ee275 100644
--- a/electrum/lnwatcher.py
+++ b/electrum/lnwatcher.py
@@ -56,7 +56,10 @@ class LNWatcher(Logger, EventListener):
self.logger.info("synchronizer not set yet")
return
for address, callback in list(self.callbacks.items()):
- await callback()
+ try:
+ await callback()
+ except Exception:
+ self.logger.exception(f"LNWatcher callback failed {address=}")
# send callback to GUI
util.trigger_callback('wallet_updated', self.lnworker.wallet)
Why this scored 23/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.