qml: sweep: handle network errors gracefully fixes #10108
What changed, and why it matters
This commit fixes a bug in Electrum's mobile-style QML user interface where sweeping private keys could crash or behave badly if the network request failed. The change now catches network errors and shows a friendly warning instead of letting the error propagate. It is a defensive UI fix, not a critical security vulnerability.
Treat as a routine bug-fix / hardening patch. No urgent security response required. Users on affected versions should update normally; no additional mitigation needed.
Security signals we found
UI crash/error handling improvement
Network error now caught and surfaced to user
No cryptographic, consensus, or wallet-seed changes
No privilege escalation or remote code execution path evident
Evidence from the diff
In electrum/gui/qml/qetxfinalizer.py, the QETxSweepFinalizer.sweep() method now imports NetworkException and catches it around the network.run_from_another_thread(sweep_preparations(…)) call. Previously, only UserFacingException was caught, so a NetworkException would bubble up uncaught. The patch sets self.warning to a translated ‘Network error’ message and returns early. This is a graceful-error-handling improvement, not a logic or cryptographic fix.
Changed components
electrum/gui/qml/qetxfinalizer.pyQML sweep private-key UI flowInspect captured patch +4 / −0
diff --git a/electrum/gui/qml/qetxfinalizer.py b/electrum/gui/qml/qetxfinalizer.py
index 1b378d6..24d7019 100644
--- a/electrum/gui/qml/qetxfinalizer.py
+++ b/electrum/gui/qml/qetxfinalizer.py
@@ -16,6 +16,7 @@ from electrum.wallet import CannotBumpFee, CannotDoubleSpendTx, CannotCPFP, Bump
from electrum import keystore
from electrum.plugin import run_hook
from electrum.fee_policy import FeePolicy, FeeMethod
+from electrum.network import NetworkException
from .qewallet import QEWallet
from .qetypes import QEAmount
@@ -1013,6 +1014,9 @@ class QETxSweepFinalizer(QETxFinalizer):
try:
self._txins = self._wallet.wallet.network.run_from_another_thread(sweep_preparations(privkeys, self._wallet.wallet.network))
self._logger.debug(f'txins {self._txins!r}')
+ except NetworkException as e:
+ self.warning = _('Network error') + ': ' + str(e)
+ return
except UserFacingException as e:
self.warning = str(e)
return
Why this scored 28/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.