diff --git a/electrum/gui/qml/qeinvoice.py b/electrum/gui/qml/qeinvoice.py index dc0225c7e..fbd31db76 100644 --- a/electrum/gui/qml/qeinvoice.py +++ b/electrum/gui/qml/qeinvoice.py @@ -442,7 +442,6 @@ class QEInvoiceParser(QEInvoice): def clear(self): self.recipient = '' self.setInvoiceType(QEInvoice.Type.Invalid) - self._bip21 = None self._lnurlData = None self.canSave = False self.canPay = False @@ -497,15 +496,15 @@ class QEInvoiceParser(QEInvoice): maybe_lightning_invoice = recipient try: - self._bip21 = parse_URI(recipient, lambda pr: self._bip70PrResolvedSignal.emit(pr)) - if self._bip21: - if 'r' in self._bip21 or ('name' in self._bip21 and 'sig' in self._bip21): # TODO set flag in util? + bip21 = parse_URI(recipient, lambda pr: self._bip70PrResolvedSignal.emit(pr)) + if bip21: + if 'r' in bip21 or ('name' in bip21 and 'sig' in bip21): # TODO set flag in util? # let callback handle state return if ':' not in recipient: # address only # create bare invoice - outputs = [PartialTxOutput.from_address_and_value(self._bip21['address'], 0)] + outputs = [PartialTxOutput.from_address_and_value(bip21['address'], 0)] invoice = self.create_onchain_invoice(outputs, None, None, None) self._logger.debug(repr(invoice)) self.setValidOnchainInvoice(invoice) @@ -513,10 +512,10 @@ class QEInvoiceParser(QEInvoice): return else: # fallback lightning invoice? - if 'lightning' in self._bip21: - maybe_lightning_invoice = self._bip21['lightning'] + if 'lightning' in bip21: + maybe_lightning_invoice = bip21['lightning'] except InvalidBitcoinURI as e: - self._bip21 = None + bip21 = None lninvoice = None maybe_lightning_invoice = maybe_extract_lightning_payment_identifier(maybe_lightning_invoice) @@ -538,14 +537,14 @@ class QEInvoiceParser(QEInvoice): return self._logger.exception(repr(e)) - if not lninvoice and not self._bip21: + if not lninvoice and not bip21: self.validationError.emit('unknown',_('Unknown invoice')) self.clear() return if lninvoice: if not self._wallet.wallet.has_lightning(): - if not self._bip21: + if not bip21: if lninvoice.get_address(): self.setValidLightningInvoice(lninvoice) self.validationSuccess.emit() @@ -553,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.')) else: self._logger.debug('flow with LN but not LN enabled AND having bip21 uri') - self.setValidOnchainInvoice(self._bip21['address']) + self.setValidOnchainInvoice(bip21['address']) else: self.setValidLightningInvoice(lninvoice) if not self._wallet.wallet.lnworker.channels: @@ -562,14 +561,14 @@ class QEInvoiceParser(QEInvoice): self.validationSuccess.emit() else: self._logger.debug('flow without LN but having bip21 uri') - if 'amount' not in self._bip21: + if 'amount' not in bip21: amount = 0 else: - amount = self._bip21['amount'] - outputs = [PartialTxOutput.from_address_and_value(self._bip21['address'], amount)] + amount = bip21['amount'] + outputs = [PartialTxOutput.from_address_and_value(bip21['address'], amount)] self._logger.debug(outputs) - message = self._bip21['message'] if 'message' in self._bip21 else '' - invoice = self.create_onchain_invoice(outputs, message, None, self._bip21) + message = bip21['message'] if 'message' in bip21 else '' + invoice = self.create_onchain_invoice(outputs, message, None, bip21) self._logger.debug(repr(invoice)) self.setValidOnchainInvoice(invoice) self.validationSuccess.emit()