Browse Source

qml: handle phase-2 lnurl errors from within WalletMainView, add sanity check on

the bolt11 invoice we get from the service
master
Sander van Grieken 3 years ago
parent
commit
b8aa87ded8
  1. 8
      electrum/gui/qml/components/LnurlPayRequestDialog.qml
  2. 5
      electrum/gui/qml/components/WalletMainView.qml
  3. 11
      electrum/gui/qml/qeinvoice.py

8
electrum/gui/qml/components/LnurlPayRequestDialog.qml

@ -102,12 +102,4 @@ ElDialog {
}
}
Connections {
target: invoiceParser
function onLnurlError(code, message) {
var dialog = app.messageDialog.createObject(app, { text: message })
dialog.open()
}
}
}

5
electrum/gui/qml/components/WalletMainView.qml

@ -235,9 +235,14 @@ Item {
onInvoiceCreateError: console.log(code + ' ' + message)
onLnurlRetrieved: {
closeSendDialog()
var dialog = lnurlPayDialog.createObject(app, { invoiceParser: invoiceParser })
dialog.open()
}
onLnurlError: {
var dialog = app.messageDialog.createObject(app, { text: message })
dialog.open()
}
}
Connections {

11
electrum/gui/qml/qeinvoice.py

@ -620,16 +620,21 @@ class QEInvoiceParser(QEInvoice, QtEventListener):
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())
self.on_lnurl_invoice(amount, fut.result())
except Exception as e:
self.lnurlError.emit('lnurl', repr(e))
self._logger.error(repr(e))
self.lnurlError.emit('lnurl', str(e))
threading.Thread(target=fetch_invoice_task).start()
def on_lnurl_invoice(self, invoice):
def on_lnurl_invoice(self, orig_amount, invoice):
self._logger.debug('on_lnurl_invoice')
self._logger.debug(f'{repr(invoice)}')
# assure no shenanigans with the bolt11 invoice we get back
lninvoice = Invoice.from_bech32(invoice)
assert orig_amount * 1000 == lninvoice.amount_msat
invoice = invoice['pr']
self.recipient = invoice

Loading…
Cancel
Save