1
0

qml: fix send "flow with LN but not LN enabled AND having bip21 uri"

closes https://github.com/spesmilo/electrum/issues/8334
This commit is contained in:
SomberNight
2023-04-23 16:42:08 +00:00
parent 7907eb1f86
commit a8623f63bb

View File

@@ -1,5 +1,5 @@
import threading import threading
from typing import TYPE_CHECKING, Optional from typing import TYPE_CHECKING, Optional, Dict, Any
import asyncio import asyncio
from urllib.parse import urlparse from urllib.parse import urlparse
@@ -552,7 +552,7 @@ class QEInvoiceParser(QEInvoice):
self.validationError.emit('no_lightning',_('Detected valid Lightning invoice, but Lightning not enabled for wallet and no fallback address found.')) self.validationError.emit('no_lightning',_('Detected valid Lightning invoice, but Lightning not enabled for wallet and no fallback address found.'))
else: else:
self._logger.debug('flow with LN but not LN enabled AND having bip21 uri') self._logger.debug('flow with LN but not LN enabled AND having bip21 uri')
self.setValidOnchainInvoice(bip21['address']) self._validateRecipient_bip21_onchain(bip21)
else: else:
self.setValidLightningInvoice(lninvoice) self.setValidLightningInvoice(lninvoice)
if not self._wallet.wallet.lnworker.channels: if not self._wallet.wallet.lnworker.channels:
@@ -561,17 +561,20 @@ class QEInvoiceParser(QEInvoice):
self.validationSuccess.emit() self.validationSuccess.emit()
else: else:
self._logger.debug('flow without LN but having bip21 uri') self._logger.debug('flow without LN but having bip21 uri')
if 'amount' not in bip21: self._validateRecipient_bip21_onchain(bip21)
amount = 0
else: def _validateRecipient_bip21_onchain(self, bip21: Dict[str, Any]) -> None:
amount = bip21['amount'] if 'amount' not in bip21:
outputs = [PartialTxOutput.from_address_and_value(bip21['address'], amount)] amount = 0
self._logger.debug(outputs) else:
message = bip21['message'] if 'message' in bip21 else '' amount = bip21['amount']
invoice = self.create_onchain_invoice(outputs, message, None, bip21) outputs = [PartialTxOutput.from_address_and_value(bip21['address'], amount)]
self._logger.debug(repr(invoice)) self._logger.debug(outputs)
self.setValidOnchainInvoice(invoice) message = bip21['message'] if 'message' in bip21 else ''
self.validationSuccess.emit() invoice = self.create_onchain_invoice(outputs, message, None, bip21)
self._logger.debug(repr(invoice))
self.setValidOnchainInvoice(invoice)
self.validationSuccess.emit()
def resolve_lnurl(self, lnurl): def resolve_lnurl(self, lnurl):
self._logger.debug('resolve_lnurl') self._logger.debug('resolve_lnurl')