lnpeer: report htlc_switch exceptions to crash reporter
What changed, and why it matters
This commit adds automatic crash reporting for a specific internal Lightning payment-routing function. When that function hits an unexpected error, the app now sends a redacted copy of the error to Electrum's crash reporter before re-raising it. It is a diagnostic/logging improvement, not a fix for a known security flaw, and it does not change how errors are handled.
No immediate action required. Review the crash reporter's privacy policy and data handling to ensure redacted tracebacks are stored and transmitted securely. Treat this as a diagnostic improvement rather than a security patch.
Security signals we found
Adds telemetry/crash reporting to a sensitive Lightning Network code path
Explicitly redacts exception message to avoid leaking payment hashes or onion data
Does not alter exception handling or fix a specific vulnerability
Could increase sensitivity of crash reporter data (tracebacks from payment processing)
Evidence from the diff
The change wraps self._run_htlc_switch_iteration() in a try/except inside the htlc_switch loop. On exception, it constructs a new exception of the same type with message ‘redacted’ (to avoid leaking onion/payment-hash data), preserves the traceback, submits it via util.send_exception_to_crash_reporter(), and then re-raises the original exception. The original exception still propagates, so behavior is unchanged except for the added telemetry.
Changed components
electrum/lnpeer.pyPeer.htlc_switchPeer._run_htlc_switch_iterationLightning Network payment forwardingInspect captured patch +9 / −1
diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py
index 377dd37..f09ef97 100644
--- a/electrum/lnpeer.py
+++ b/electrum/lnpeer.py
@@ -2788,7 +2788,15 @@ class Peer(Logger, EventListener):
await group.spawn(self.downstream_htlc_resolved_event.wait())
self._htlc_switch_iterstart_event.set()
self._htlc_switch_iterstart_event.clear()
- self._run_htlc_switch_iteration()
+ try:
+ self._run_htlc_switch_iteration()
+ except Exception as e:
+ # this is code with many asserts and dense logic so it seems useful to allow the user
+ # report to exceptions that otherwise might go unnoticed for some time
+ reported_exc = type(e)("redacted") # text could contain onions, payment hashes etc.
+ reported_exc.__traceback__ = e.__traceback__
+ util.send_exception_to_crash_reporter(reported_exc)
+ raise e
@util.profiler(min_threshold=0.02)
def _run_htlc_switch_iteration(self):
Why this scored 18/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.