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