diff --git a/electrum/gui/qml/components/InvoiceDialog.qml b/electrum/gui/qml/components/InvoiceDialog.qml index 639e92aaf..910688c16 100644 --- a/electrum/gui/qml/components/InvoiceDialog.qml +++ b/electrum/gui/qml/components/InvoiceDialog.qml @@ -14,6 +14,7 @@ ElDialog { property string invoice_key signal doPay + signal invoiceAmountChanged title: qsTr('Invoice') standardButtons: invoice_key != '' ? Dialog.Close : Dialog.Cancel @@ -121,6 +122,29 @@ ElDialog { } } + Label { + visible: invoice.invoiceType == Invoice.LightningInvoice + text: qsTr('Payment hash') + color: Material.accentColor + } + + TextHighlightPane { + visible: invoice.invoiceType == Invoice.LightningInvoice + + Layout.columnSpan: 2 + Layout.fillWidth: true + + padding: 0 + leftPadding: constants.paddingMedium + + Label { + width: parent.width + text: 'payment_hash' in invoice.lnprops ? invoice.lnprops.payment_hash : '' + font.family: FixedFont + wrapMode: Text.Wrap + } + } + Label { text: qsTr('Description') visible: invoice.message @@ -278,6 +302,7 @@ ElDialog { onClicked: { amountContainer.editmode = false invoice.amount = amountMax.checked ? MAX : Config.unitsToSats(amountBtc.text) + invoiceAmountChanged() } } ToolButton { @@ -308,7 +333,7 @@ ElDialog { Layout.fillWidth: true text: qsTr('Pay') icon.source: '../../icons/confirmed.png' - enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay + enabled: invoice.invoiceType != Invoice.Invalid && invoice.canPay && !amountContainer.editmode onClicked: { if (invoice_key == '') // save invoice if not retrieved from key invoice.save_invoice() diff --git a/electrum/gui/qml/components/Invoices.qml b/electrum/gui/qml/components/Invoices.qml index fd8777a80..7879c8c28 100644 --- a/electrum/gui/qml/components/Invoices.qml +++ b/electrum/gui/qml/components/Invoices.qml @@ -42,7 +42,12 @@ Pane { id: delegateModel model: Daemon.currentWallet.invoiceModel delegate: InvoiceDelegate { - onClicked: app.stack.getRoot().openInvoice(model.key) + onClicked: { + var dialog = app.stack.getRoot().openInvoice(model.key) + dialog.invoiceAmountChanged.connect(function () { + Daemon.currentWallet.invoiceModel.init_model() + }) + } } } diff --git a/electrum/gui/qml/components/LightningPaymentProgressDialog.qml b/electrum/gui/qml/components/LightningPaymentProgressDialog.qml index aa4303c95..c2bac7c1d 100644 --- a/electrum/gui/qml/components/LightningPaymentProgressDialog.qml +++ b/electrum/gui/qml/components/LightningPaymentProgressDialog.qml @@ -70,6 +70,7 @@ ElDialog { ColumnLayout { id: content anchors.centerIn: parent + width: parent.width Item { Layout.alignment: Qt.AlignHCenter @@ -92,15 +93,18 @@ ElDialog { Label { id: helpText + Layout.alignment: Qt.AlignHCenter text: qsTr('Paying...') font.pixelSize: constants.fontSizeXXLarge - Layout.alignment: Qt.AlignHCenter } Label { id: errorText - font.pixelSize: constants.fontSizeLarge + Layout.preferredWidth: parent.width Layout.alignment: Qt.AlignHCenter + horizontalAlignment: Text.AlignHCenter + wrapMode: Text.Wrap + font.pixelSize: constants.fontSizeLarge } } diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index 9de060a9b..019abe890 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -16,6 +16,7 @@ from electrum.transaction import PartialTxOutput from electrum.util import (parse_URI, InvalidBitcoinURI, InvoiceError, maybe_extract_lightning_payment_identifier) from electrum.lnurl import decode_lnurl, request_lnurl, callback_lnurl +from electrum.bitcoin import COIN from .qetypes import QEAmount from .qewallet import QEWallet @@ -226,6 +227,7 @@ class QEInvoiceParser(QEInvoice): self._logger.debug(str(lnaddr.get_routing_info('t'))) return { 'pubkey': lnaddr.pubkey.serialize().hex(), + 'payment_hash': lnaddr.paymenthash.hex(), 't': '', #lnaddr.get_routing_info('t')[0][0].hex(), 'r': '' #lnaddr.get_routing_info('r')[0][0][0].hex() } @@ -277,7 +279,11 @@ class QEInvoiceParser(QEInvoice): if self.invoiceType == QEInvoice.Type.LightningInvoice: if self.status in [PR_UNPAID, PR_FAILED]: if self.get_max_spendable_lightning() >= self.amount.satsInt: - self.canPay = True + lnaddr = self._effectiveInvoice._lnaddr + if self.amount.satsInt < lnaddr.amount * COIN: + self.userinfo = _('Cannot pay less than the amount specified in the invoice') + else: + self.canPay = True else: self.userinfo = _('Insufficient balance') else: