wallet: fix AttributeError when getting help text
What changed, and why it matters
This is a simple bug fix for a crash in the Electrum Bitcoin wallet. When a user without Lightning support clicked on a receive request, the wallet tried to check Lightning receive capacity on a missing component and crashed with an AttributeError. The patch adds a safety check so the code skips the Lightning check when no Lightning worker exists. There is no security vulnerability here—just a UI crash being fixed.
No security action needed. Treat as a normal stability bug fix. Users on affected versions can avoid the crash by not selecting receive requests in wallets without Lightning, or upgrade to the patched version.
Security signals we found
None - this is a null-pointer/AttributeError crash fix, not a security issue
Evidence from the diff
In wallet.py’s get_help_texts_for_receive_request(), the code unconditionally called self.lnworker.num_sats_can_receive(). For wallets where self.lnworker is None, this raised AttributeError: ‘NoneType’ object has no attribute ‘num_sats_can_receive’. The fix guards the call with a conditional: num_sats_can_receive = self.lnworker.num_sats_can_receive() if self.lnworker else 0. This prevents the crash and allows the receive request help text to be generated normally. The change is defensive and local.
Changed components
electrum/wallet.pyAbstract_Wallet.get_help_texts_for_receive_request()QT receive tab / request list UIInspect captured patch +2 / −2
diff --git a/electrum/wallet.py b/electrum/wallet.py
index e997e9b..70648ec 100644
--- a/electrum/wallet.py
+++ b/electrum/wallet.py
@@ -3443,8 +3443,8 @@ class Abstract_Wallet(ABC, Logger, EventListener):
self.lnworker and len([chan for chan in self.lnworker.channels.values() if chan.is_open()]) > 0
)
lightning_online = self.lnworker and self.lnworker.num_peers() > 0
- can_receive = self.lnworker.num_sats_can_receive()
- can_receive_lightning = self.lnworker and can_receive > 0 and amount_sat <= can_receive
+ num_sats_can_receive = self.lnworker.num_sats_can_receive() if self.lnworker else 0
+ can_receive_lightning = self.lnworker and num_sats_can_receive > 0 and amount_sat <= num_sats_can_receive
try:
zeroconf_nodeid = extract_nodeid(self.config.ZEROCONF_TRUSTED_NODE)[0]
except Exception:
Why this scored 21/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.