1
0

add initial lnurl-pay

This commit is contained in:
Sander van Grieken
2022-09-28 18:05:45 +02:00
parent 2778a1bc20
commit 8437e13666
4 changed files with 168 additions and 9 deletions

View File

@@ -52,12 +52,15 @@ async def _request_lnurl(url: str) -> dict:
"""Requests payment data from a lnurl."""
try:
response = await Network.async_send_http_on_proxy("get", url, timeout=10)
response = json.loads(response)
except asyncio.TimeoutError as e:
raise LNURLError("Server did not reply in time.") from e
except aiohttp.client_exceptions.ClientError as e:
raise LNURLError(f"Client error: {e}") from e
except json.JSONDecodeError:
raise LNURLError(f"Invalid response from server")
# TODO: handling of specific client errors
response = json.loads(response)
if "metadata" in response:
response["metadata"] = json.loads(response["metadata"])
status = response.get("status")