[fix] add lnurl field back (#105)
This commit is contained in:
parent
db8de4804d
commit
b1c92a067d
3 changed files with 33 additions and 3 deletions
13
helpers.py
13
helpers.py
|
|
@ -1,3 +1,6 @@
|
|||
from fastapi import Request
|
||||
from lnurl import encode as lnurl_encode
|
||||
|
||||
from .nostr.key import PrivateKey
|
||||
|
||||
|
||||
|
|
@ -6,3 +9,13 @@ def parse_nostr_private_key(key: str) -> PrivateKey:
|
|||
return PrivateKey.from_nsec(key)
|
||||
else:
|
||||
return PrivateKey(bytes.fromhex(key))
|
||||
|
||||
|
||||
def lnurl_encode_link_id(req: Request, link_id: str) -> str:
|
||||
url = req.url_for("lnurlp.api_lnurl_response", link_id=link_id)
|
||||
url = url.replace(path=url.path)
|
||||
url_str = str(url)
|
||||
if url.netloc.endswith(".onion"):
|
||||
# change url string scheme to http
|
||||
url_str = url_str.replace("https://", "http://")
|
||||
return str(lnurl_encode(url_str).bech32)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue