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:
@@ -102,12 +102,4 @@ ElDialog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
|
||||||
target: invoiceParser
|
|
||||||
function onLnurlError(code, message) {
|
|
||||||
var dialog = app.messageDialog.createObject(app, { text: message })
|
|
||||||
dialog.open()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -235,9 +235,14 @@ Item {
|
|||||||
onInvoiceCreateError: console.log(code + ' ' + message)
|
onInvoiceCreateError: console.log(code + ' ' + message)
|
||||||
|
|
||||||
onLnurlRetrieved: {
|
onLnurlRetrieved: {
|
||||||
|
closeSendDialog()
|
||||||
var dialog = lnurlPayDialog.createObject(app, { invoiceParser: invoiceParser })
|
var dialog = lnurlPayDialog.createObject(app, { invoiceParser: invoiceParser })
|
||||||
dialog.open()
|
dialog.open()
|
||||||
}
|
}
|
||||||
|
onLnurlError: {
|
||||||
|
var dialog = app.messageDialog.createObject(app, { text: message })
|
||||||
|
dialog.open()
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Connections {
|
Connections {
|
||||||
|
|||||||
@@ -620,16 +620,21 @@ class QEInvoiceParser(QEInvoice, QtEventListener):
|
|||||||
params['comment'] = comment
|
params['comment'] = comment
|
||||||
coro = callback_lnurl(self._lnurlData['callback_url'], params)
|
coro = callback_lnurl(self._lnurlData['callback_url'], params)
|
||||||
fut = asyncio.run_coroutine_threadsafe(coro, self._wallet.wallet.network.asyncio_loop)
|
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:
|
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()
|
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('on_lnurl_invoice')
|
||||||
self._logger.debug(f'{repr(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']
|
invoice = invoice['pr']
|
||||||
self.recipient = invoice
|
self.recipient = invoice
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user