qml: InvoiceDialog: fix onCompleted operator precendence bug
What changed, and why it matters
This is a tiny UI bug fix in Electrum's mobile/QML wallet interface. The original code accidentally checked the wrong condition when opening an invoice dialog, due to operator precedence: `!invoice.status == Invoice.Expired` was interpreted as `(!invoice.status) == Invoice.Expired` rather than `!(invoice.status == Invoice.Expired)`. The fix rewrites it to the intended meaning. The effect is at most a minor user-interface glitch when viewing certain invoices, not a security vulnerability.
No security action required. Treat as a normal UI bug fix. If reviewing, verify the intended behavior is that empty-amount, non-expired invoices open in edit mode.
Security signals we found
Operator-precedence bug in UI condition
No involvement of cryptography, network, or transaction authorization
Behavioral change limited to dialog initialization/edit-mode state
Evidence from the diff
The patch corrects a QML/JavaScript operator-precedence bug in InvoiceDialog.qml. In JS/QML, ! binds tighter than ==, so !invoice.status == Invoice.Expired is parsed as (!invoice.status) == Invoice.Expired. Because ! of a non-zero enum yields false, and false == Invoice.Expired is generally false, the branch condition was effectively wrong. The fix changes it to invoice.status != Invoice.Expired, which is the intended logic. This only affects whether the amount field enters edit mode automatically when an invoice with no amount is opened. It does not alter transaction signing, payment logic, cryptographic validation, or network behavior.
Changed components
electrum/gui/qml/components/InvoiceDialog.qmlInspect captured patch +1 / −1
diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml
index f2b15b8..49d6ce7 100644
--- a/electrum/gui/qml/components/InvoiceDialog.qml
+++ b/electrum/gui/qml/components/InvoiceDialog.qml
@@ -505,7 +505,7 @@ ElDialog {
}
Component.onCompleted: {
- if (invoice.amount.isEmpty && !invoice.status == Invoice.Expired) {
+ if (invoice.amount.isEmpty && invoice.status != Invoice.Expired) {
amountContainer.editmode = true
} else if (invoice.amount.isMax) {
amountMax.checked = true
Why this scored 18/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.