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:
@@ -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
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user