1818from electrum .lnurl import LNURL6Data
1919from electrum .bitcoin import COIN , address_to_script
2020from electrum .paymentrequest import PaymentRequest
21- from electrum .payment_identifier import PaymentIdentifier , PaymentIdentifierState , PaymentIdentifierType
21+ from electrum .payment_identifier import (
22+ PaymentIdentifier , PaymentIdentifierState , PaymentIdentifierType , invoice_from_payment_identifier
23+ )
2224from electrum .network import Network
2325from electrum .bolt12 import decode_invoice
2426
@@ -485,6 +487,7 @@ def fromResolvedPaymentIdentifier(self, resolved_pi: PaymentIdentifier) -> None:
485487 self .amountOverride = QEAmount ()
486488 if resolved_pi :
487489 assert not resolved_pi .need_resolve ()
490+ self .clear ()
488491 self .validateRecipient (resolved_pi )
489492
490493 @pyqtProperty ('QVariantMap' , notify = lnurlRetrieved )
@@ -510,6 +513,7 @@ def busy(self):
510513 @pyqtSlot ()
511514 def clear (self ):
512515 self .setInvoiceType (QEInvoice .Type .Invalid )
516+ self ._key = None
513517 self ._lnurlData = None
514518 self ._offerData = None
515519 self .canSave = False
@@ -614,8 +618,8 @@ def _update_from_payment_identifier(self):
614618 self .setValidOnchainInvoice (invoice )
615619 self .validationSuccess .emit ()
616620 return
617- elif self ._pi .type == PaymentIdentifierType .BOLT11 :
618- lninvoice = self ._pi . bolt11
621+ elif self ._pi .type in [ PaymentIdentifierType .BOLT11 , PaymentIdentifierType . BOLT12_OFFER ] :
622+ lninvoice = invoice_from_payment_identifier ( self ._pi , self . _wallet . wallet )
619623 if not self ._wallet .wallet .has_lightning () and not lninvoice .get_address ():
620624 self .validationError .emit ('no_lightning' ,
621625 _ ('Detected valid Lightning invoice, but Lightning not enabled for wallet and no fallback address found.' ))
0 commit comments