From 95729a08efc68a905f54ec7733f37eeb2af7025e Mon Sep 17 00:00:00 2001 From: f321x Date: Thu, 16 Oct 2025 11:50:31 +0200 Subject: [PATCH] lnpeer: report htlc_switch exceptions to crash reporter It seems useful to report exceptions happening in the htlc_switch to the crash reporter as it shouldn't raise exceptions in theory and this could help catch subtle bugs. --- electrum/lnpeer.py | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/electrum/lnpeer.py b/electrum/lnpeer.py index 377dd375f..f09ef97a2 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):