feat: add optional domain field (#120)

* feat: add optional domain field
closes #119
This commit is contained in:
dni ⚡ 2026-01-15 09:20:54 +01:00 committed by GitHub
commit 17135b45ae
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 107 additions and 46 deletions

View file

@ -10,11 +10,16 @@ def parse_nostr_private_key(key: str) -> PrivateKey:
return PrivateKey(bytes.fromhex(key))
def lnurl_encode_link_id(req: Request, link_id: str) -> str:
def lnurl_encode_link(req: Request, link_id: str, domain: str | None = None) -> str:
if domain:
url_str = f"https://{domain}/lnurlp/{link_id}"
return str(lnurl_encode(url_str).bech32)
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)