diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index c559801cc..a240a632a 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -435,6 +435,9 @@ ElDialog { enabled: invoice.canSave onClicked: { app.stack.push(Qt.resolvedUrl('Invoices.qml')) + if (invoice.amount.isEmpty) { + invoice.amount = amountMax.checked ? MAX : Config.unitsToSats(amountBtc.text) + } invoice.save_invoice() dialog.close() } @@ -446,8 +449,18 @@ ElDialog { icon.source: '../../icons/confirmed.png' enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay onClicked: { - if (invoice_key == '') // save invoice if not retrieved from key + if (invoice.amount.isEmpty) { + invoice.amount = amountMax.checked ? MAX : Config.unitsToSats(amountBtc.text) + if (invoice_key != '') { + // delete the existing invoice because this affects get_id() + invoice.wallet.delete_invoice(invoice_key) + invoice_key = '' + } + } + if (invoice_key == '') { + // save invoice if new or modified invoice.save_invoice() + } dialog.close() doPay() // only signal here } diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index 7188eda36..b60da544e 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -313,8 +313,6 @@ class QEInvoiceParser(QEInvoice): self.set_lnprops() - self.canSave = True - self.determine_can_pay() self.invoiceChanged.emit() @@ -339,6 +337,7 @@ class QEInvoiceParser(QEInvoice): def determine_can_pay(self): self.canPay = False + self.canSave = False self.userinfo = '' if not self.amountOverride.isEmpty: @@ -346,6 +345,8 @@ class QEInvoiceParser(QEInvoice): else: amount = self.amount + self.canSave = True + if amount.isEmpty: # unspecified amount return @@ -652,6 +653,8 @@ class QEUserEnteredPayment(QEInvoice): self.validationError.emit('recipient', _('Invalid Bitcoin address')) return + self.canSave = True + if self._amount.isEmpty: self.validationError.emit('amount', _('Invalid amount')) return @@ -659,7 +662,6 @@ class QEUserEnteredPayment(QEInvoice): if self._amount.isMax: self.canPay = True else: - self.canSave = True if self.get_max_spendable_onchain() >= self._amount.satsInt: self.canPay = True