1
0

qml: send screen: bip21: fallback to onchain addr if no LN channels

given a bip21 uri that has both onchain addr and bolt11,
if we have LN enabled but no LN channels, auto-fallback to paying onchain

we will have to clean up and unify this logic between GUIs. becoming spaghetti :/
rumour has it, Thomas has a branch? :P
This commit is contained in:
SomberNight
2023-04-25 22:23:24 +00:00
parent 5b122e723f
commit 312e50e9a9
2 changed files with 9 additions and 2 deletions

View File

@@ -232,6 +232,9 @@ Item {
onValidationWarning: {
if (code == 'no_channels') {
var dialog = app.messageDialog.createObject(app, { text: message })
dialog.closed.connect(function() {
restartSendDialog()
})
dialog.open()
// TODO: ask user to open a channel, if funds allow
// and maybe store invoice if expiry allows

View File

@@ -554,10 +554,14 @@ class QEInvoiceParser(QEInvoice):
self._logger.debug('flow with LN but not LN enabled AND having bip21 uri')
self._validateRecipient_bip21_onchain(bip21)
else:
self.setValidLightningInvoice(lninvoice)
if not self._wallet.wallet.lnworker.channels:
self.validationWarning.emit('no_channels',_('Detected valid Lightning invoice, but there are no open channels'))
if bip21 and 'address' in bip21:
self._logger.debug('flow where invoice has both LN and onchain, we have LN enabled but no channels')
self._validateRecipient_bip21_onchain(bip21)
else:
self.validationWarning.emit('no_channels',_('Detected valid Lightning invoice, but there are no open channels'))
else:
self.setValidLightningInvoice(lninvoice)
self.validationSuccess.emit()
else:
self._logger.debug('flow without LN but having bip21 uri')