lnurl: better handle unimplemented lnurl subtypes
fixes https://github.com/spesmilo/electrum/issues/7971
This commit is contained in:
@@ -237,9 +237,12 @@ class SendScreen(CScreen, Logger):
|
||||
def set_lnurl6(self, lnurl: str):
|
||||
url = decode_lnurl(lnurl)
|
||||
domain = urlparse(url).netloc
|
||||
# FIXME network request blocking GUI thread:
|
||||
lnurl_data = Network.run_from_another_thread(request_lnurl(url))
|
||||
if not lnurl_data:
|
||||
try:
|
||||
# FIXME network request blocking GUI thread:
|
||||
lnurl_data = Network.run_from_another_thread(request_lnurl(url))
|
||||
except LNURLError as e:
|
||||
self.app.show_error(f"LNURL request encountered error: {e}")
|
||||
self.do_clear()
|
||||
return
|
||||
self.lnurl_data = lnurl_data
|
||||
self.address = "invoice from lnurl"
|
||||
|
||||
@@ -66,11 +66,11 @@ async def _request_lnurl(url: str) -> dict:
|
||||
return response
|
||||
|
||||
|
||||
async def request_lnurl(url: str) -> Optional[LNURL6Data]:
|
||||
async def request_lnurl(url: str) -> LNURL6Data:
|
||||
lnurl_dict = await _request_lnurl(url)
|
||||
tag = lnurl_dict.get('tag')
|
||||
if tag != 'payRequest': # only LNURL6 is handled atm
|
||||
return None
|
||||
raise LNURLError(f"Unknown subtype of lnurl. tag={tag}")
|
||||
metadata = lnurl_dict.get('metadata')
|
||||
metadata_plaintext = ""
|
||||
for m in metadata:
|
||||
|
||||
Reference in New Issue
Block a user