qt: SettingsDialog: guard self.network access
What changed, and why it matters
This commit fixes a simple crash bug in Electrum's settings window. When the user toggled a Lightning network option while running offline (no network connection), the program tried to use a non-existent network object and crashed with an error. The fix adds a safety check to skip network calls when there is no network connection.
No urgent security action needed. Apply the patch as a routine stability fix. Users can avoid the crash by not toggling the trampoline setting in offline mode until updated.
Security signals we found
Crash/DoS-quality bug in GUI settings dialog
Null-pointer-like AttributeError on unguarded object access
No evidence of code execution, privilege escalation, or data exposure
Evidence from the diff
In electrum/gui/qt/settings_dialog.py, the on_trampoline_checked callback now checks if self.network: before calling self.network.start_gossip() or self.network.run_from_another_thread(…). Previously, in offline mode self.network is None, causing an AttributeError and an unhandled exception caught by the crash reporter. The patch is a defensive null-guard with no functional change when a network object exists.
Changed components
electrum/gui/qt/settings_dialog.pySettingsDialog.on_trampoline_checked trampoline checkbox handlerInspect captured patch +6 / −5
diff --git a/electrum/gui/qt/settings_dialog.py b/electrum/gui/qt/settings_dialog.py
index 1655e17..e06781f 100644
--- a/electrum/gui/qt/settings_dialog.py
+++ b/electrum/gui/qt/settings_dialog.py
@@ -127,11 +127,12 @@ class SettingsDialog(QDialog, QtEventListener):
trampoline_cb.setCheckState(Qt.CheckState.Checked)
return
self.config.LIGHTNING_USE_GOSSIP = not use_trampoline
- if not use_trampoline:
- self.network.start_gossip()
- else:
- self.network.run_from_another_thread(
- self.network.stop_gossip())
+ if self.network:
+ if not use_trampoline:
+ self.network.start_gossip()
+ else:
+ self.network.run_from_another_thread(
+ self.network.stop_gossip())
util.trigger_callback('ln_gossip_sync_progress')
# FIXME: update all wallet windows
util.trigger_callback('channels_updated', self.wallet)
Why this scored 19/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.