1
0

pi: allow emaillike pi with 'lightning:' prefix

Lightning addresses with 'lightning:' do occur in the wild and make
sense (how else would e.g. the smartphone know to open a lightning
wallet instead of the e-mail client). So we should allow this.
This commit is contained in:
f321x
2025-12-22 10:04:24 +01:00
parent 2cd1de4f21
commit dd1d98e37c
2 changed files with 7 additions and 2 deletions

View File

@@ -293,9 +293,9 @@ class PaymentIdentifier(Logger):
self._type = PaymentIdentifierType.EMAILLIKE
self.emaillike = contact['address']
self.set_state(PaymentIdentifierState.NEED_RESOLVE)
elif re.match(RE_EMAIL, text):
elif re.match(RE_EMAIL, (maybe_emaillike := remove_uri_prefix(text, prefix=LIGHTNING_URI_SCHEME))):
self._type = PaymentIdentifierType.EMAILLIKE
self.emaillike = text
self.emaillike = maybe_emaillike
self.set_state(PaymentIdentifierState.NEED_RESOLVE)
elif re.match(RE_DOMAIN, text):
self._type = PaymentIdentifierType.DOMAINLIKE

View File

@@ -378,6 +378,11 @@ class TestPaymentIdentifier(ElectrumTestCase):
'lnbcuser@some.domain',
'lnurluser@some.domain',
'bc1quser@some.domain',
'lightning:user@some.domain',
'lightning:user@some.weird.but.valid.domain',
'lightning:lnbcuser@some.domain',
'lightning:lnurluser@some.domain',
'lightning:bc1quser@some.domain',
)
for pi_str in email_pi_strings:
pi = PaymentIdentifier(None, pi_str)