1
0

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

the bolt11 invoice we get from the service
This commit is contained in:
Sander van Grieken
2023-03-31 13:21:11 +02:00
parent e476e60247
commit b8aa87ded8
3 changed files with 13 additions and 11 deletions

View File

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

View File

@@ -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 {

View File

@@ -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