Skip to content

Commit b8ec03a

Browse files
committed
qml: reset _key in QEInvoice on clear(), validate bolt12 recipients
1 parent 40f7592 commit b8ec03a

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

electrum/gui/qml/qeinvoice.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,9 @@
1818
from electrum.lnurl import LNURL6Data
1919
from electrum.bitcoin import COIN, address_to_script
2020
from 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+
)
2224
from electrum.network import Network
2325
from 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

Comments
 (0)