fix: lnurl_encoding error was not handled (#56)
This commit is contained in:
parent
6b11dec0cc
commit
b42fee99e5
6 changed files with 1047 additions and 750 deletions
28
helpers.py
Normal file
28
helpers.py
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
from fastapi import Request
|
||||
from lnurl import Lnurl
|
||||
from lnurl import encode as lnurl_encode
|
||||
from shortuuid import uuid
|
||||
|
||||
from .models import WithdrawLink
|
||||
|
||||
|
||||
def create_lnurl(link: WithdrawLink, req: Request) -> Lnurl:
|
||||
if link.is_unique:
|
||||
usescssv = link.usescsv.split(",")
|
||||
tohash = link.id + link.unique_hash + usescssv[link.number]
|
||||
multihash = uuid(name=tohash)
|
||||
url = req.url_for(
|
||||
"withdraw.api_lnurl_multi_response",
|
||||
unique_hash=link.unique_hash,
|
||||
id_unique_hash=multihash,
|
||||
)
|
||||
else:
|
||||
url = req.url_for("withdraw.api_lnurl_response", unique_hash=link.unique_hash)
|
||||
|
||||
try:
|
||||
return lnurl_encode(str(url))
|
||||
except Exception as e:
|
||||
raise ValueError(
|
||||
f"Error creating LNURL with url: `{url!s}`, "
|
||||
"check your webserver proxy configuration."
|
||||
) from e
|
||||
Loading…
Add table
Add a link
Reference in a new issue