qml: don't compute notification balance delta for large tx batches
What changed, and why it matters
This commit is a performance fix, not a security patch. It stops the Electrum mobile/QML wallet from calculating the total balance change when more than 20 new transactions arrive at once, because that calculation could freeze the user interface for several seconds. The change simply shows a generic message like '25 new transactions' instead of a detailed balance delta.
No security action required; treat as a routine performance/usability improvement.
Security signals we found
No security-relevant signal present in the diff or commit message
Performance/DoS mitigation against accidental UI freezing from large transaction batches
Evidence from the diff
In electrum/wallet.py, get_user_notifications_for_new_txns() now returns a plain count message when len(txns) > 20, bypassing the per-tx debit/credit summation that previously ran for any batch of 3 or more transactions. The old threshold (>=3) remains for the detailed delta calculation. This avoids a synchronous, UI-blocking computation during wallet synchronization.
Changed components
electrum/wallet.pyQML/mobile notification generationInspect captured patch +5 / −2
diff --git a/electrum/wallet.py b/electrum/wallet.py
index ea55b69..c5252e1 100644
--- a/electrum/wallet.py
+++ b/electrum/wallet.py
@@ -3715,8 +3715,11 @@ class Abstract_Wallet(ABC, Logger, EventListener):
def get_user_notifications_for_new_txns(self, txns: Sequence[Transaction]) -> Sequence[str]:
notifications = []
- # Combine the transactions if there are at least three
- if len(txns) >= 3:
+ if len(txns) > 20:
+ # skip the delta calculation if there are many txs, otherwise it may block the UI for seconds
+ notifications.append(_('{} new transactions').format(len(txns)))
+ elif len(txns) >= 3:
+ # Combine the transactions if there are at least three
total_amount = 0
total_debit = 0
total_credit = 0
Why this scored 20/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.