1
0

qt: fix enable/disable max button for openalias and restrict openalias to address only

This commit is contained in:
Sander van Grieken
2023-06-26 13:25:09 +02:00
parent eed016bd7e
commit 3a1e5244b8
2 changed files with 8 additions and 3 deletions

View File

@@ -207,7 +207,8 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
def spend_max(self): def spend_max(self):
assert self.payto_e.payment_identifier is not None assert self.payto_e.payment_identifier is not None
assert self.payto_e.payment_identifier.type in [PaymentIdentifierType.SPK, PaymentIdentifierType.MULTILINE] assert self.payto_e.payment_identifier.type in [PaymentIdentifierType.SPK, PaymentIdentifierType.MULTILINE,
PaymentIdentifierType.OPENALIAS]
if run_hook('abort_send', self): if run_hook('abort_send', self):
return return
outputs = self.payto_e.payment_identifier.get_onchain_outputs('!') outputs = self.payto_e.payment_identifier.get_onchain_outputs('!')
@@ -379,7 +380,10 @@ class SendTab(QWidget, MessageBoxMixin, Logger):
lock_recipient = pi.type != PaymentIdentifierType.SPK \ lock_recipient = pi.type != PaymentIdentifierType.SPK \
and not (pi.type == PaymentIdentifierType.EMAILLIKE and pi.state in [PaymentIdentifierState.NOT_FOUND,PaymentIdentifierState.NEED_RESOLVE]) and not (pi.type == PaymentIdentifierType.EMAILLIKE and pi.state in [PaymentIdentifierState.NOT_FOUND,PaymentIdentifierState.NEED_RESOLVE])
lock_amount = pi.is_amount_locked() lock_amount = pi.is_amount_locked()
lock_max = lock_amount or pi.type in [PaymentIdentifierType.BOLT11, PaymentIdentifierType.LNURLP, PaymentIdentifierType.LNADDR] lock_max = lock_amount \
or pi.type in [PaymentIdentifierType.BOLT11, PaymentIdentifierType.LNURLP,
PaymentIdentifierType.LNADDR, PaymentIdentifierType.EMAILLIKE]
self.lock_fields(lock_recipient=lock_recipient, self.lock_fields(lock_recipient=lock_recipient,
lock_amount=lock_amount, lock_amount=lock_amount,
lock_max=lock_max, lock_max=lock_max,

View File

@@ -401,7 +401,8 @@ class PaymentIdentifier(Logger):
'WARNING: the alias "{}" could not be validated via an additional ' 'WARNING: the alias "{}" could not be validated via an additional '
'security check, DNSSEC, and thus may not be correct.').format(self.emaillike) 'security check, DNSSEC, and thus may not be correct.').format(self.emaillike)
try: try:
scriptpubkey = self.parse_output(address) assert bitcoin.is_address(address)
scriptpubkey = bytes.fromhex(bitcoin.address_to_script(address))
self._type = PaymentIdentifierType.OPENALIAS self._type = PaymentIdentifierType.OPENALIAS
self.spk = scriptpubkey self.spk = scriptpubkey
self.set_state(PaymentIdentifierState.AVAILABLE) self.set_state(PaymentIdentifierState.AVAILABLE)