diff --git a/electrum/gui/qml/components/LnurlPayRequestDialog.qml b/electrum/gui/qml/components/LnurlPayRequestDialog.qml index 25ffc519d..01bda04ba 100644 --- a/electrum/gui/qml/components/LnurlPayRequestDialog.qml +++ b/electrum/gui/qml/components/LnurlPayRequestDialog.qml @@ -11,10 +11,9 @@ ElDialog { id: dialog title: qsTr('LNURL Payment request') + iconSource: '../../../icons/link.png' - // property var lnurlData property InvoiceParser invoiceParser - // property alias lnurlData: dialog.invoiceParser.lnurlData standardButtons: Dialog.Cancel @@ -26,24 +25,30 @@ ElDialog { GridLayout { columns: 2 - implicitWidth: parent.width + + width: parent.width Label { text: qsTr('Provider') + color: Material.accentColor } Label { text: invoiceParser.lnurlData['domain'] } Label { text: qsTr('Description') + color: Material.accentColor } Label { text: invoiceParser.lnurlData['metadata_plaintext'] + Layout.fillWidth: true + wrapMode: Text.Wrap } Label { text: invoiceParser.lnurlData['min_sendable_sat'] == invoiceParser.lnurlData['max_sendable_sat'] ? qsTr('Amount') : qsTr('Amount range') + color: Material.accentColor } Label { text: invoiceParser.lnurlData['min_sendable_sat'] == invoiceParser.lnurlData['max_sendable_sat'] @@ -53,12 +58,21 @@ ElDialog { : invoiceParser.lnurlData['min_sendable_sat'] + ' < amount < ' + invoiceParser.lnurlData['max_sendable_sat'] } + TextArea { + id: comment + Layout.columnSpan: 2 + Layout.preferredWidth: parent.width + Layout.minimumHeight: 80 + wrapMode: TextEdit.Wrap + placeholderText: qsTr('Enter an (optional) message for the receiver') + } + Button { Layout.columnSpan: 2 Layout.alignment: Qt.AlignHCenter text: qsTr('Proceed') onClicked: { - invoiceParser.lnurlGetInvoice(invoiceParser.lnurlData['min_sendable_sat']) + invoiceParser.lnurlGetInvoice(invoiceParser.lnurlData['min_sendable_sat'], comment.text) dialog.close() } } diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index a897497bf..71c1f4e6b 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -450,21 +450,27 @@ class QEInvoiceParser(QEInvoice): 'callback_url' : lnurldata.callback_url, 'min_sendable_sat': lnurldata.min_sendable_sat, 'max_sendable_sat': lnurldata.max_sendable_sat, - 'metadata_plaintext': lnurldata.metadata_plaintext + 'metadata_plaintext': lnurldata.metadata_plaintext, + 'comment_allowed': lnurldata.comment_allowed } self.setValidLNURLPayRequest() self.lnurlRetrieved.emit() @pyqtSlot('quint64') - def lnurlGetInvoice(self, amount): + @pyqtSlot('quint64', str) + def lnurlGetInvoice(self, amount, comment=None): assert self._lnurlData + if self._lnurlData['comment_allowed'] == 0: + comment = None + self._logger.debug(f'fetching callback url {self._lnurlData["callback_url"]}') def fetch_invoice_task(): try: - coro = callback_lnurl(self._lnurlData['callback_url'], { - 'amount': amount * 1000 # msats - }) + params = { 'amount': amount * 1000 } + if comment: + params['comment'] = comment + coro = callback_lnurl(self._lnurlData['callback_url'], params) fut = asyncio.run_coroutine_threadsafe(coro, self._wallet.wallet.network.asyncio_loop) self.on_lnurl_invoice(fut.result()) except Exception as e: