Browse Source

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
master
SomberNight 3 years ago
parent
commit
312e50e9a9
No known key found for this signature in database
GPG Key ID: B33B5F232C6271E9
  1. 3
      electrum/gui/qml/components/WalletMainView.qml
  2. 8
      electrum/gui/qml/qeinvoice.py

3
electrum/gui/qml/components/WalletMainView.qml

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

8
electrum/gui/qml/qeinvoice.py

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

Loading…
Cancel
Save