check .onion and change scheme to http (#7)
This commit is contained in:
parent
d8b6ac40bc
commit
b2fcdffc0d
1 changed files with 13 additions and 0 deletions
13
lnurl.py
13
lnurl.py
|
|
@ -1,6 +1,7 @@
|
||||||
import json
|
import json
|
||||||
from datetime import datetime
|
from datetime import datetime
|
||||||
from http import HTTPStatus
|
from http import HTTPStatus
|
||||||
|
from urllib.parse import urlparse
|
||||||
|
|
||||||
import httpx
|
import httpx
|
||||||
import shortuuid
|
import shortuuid
|
||||||
|
|
@ -38,6 +39,12 @@ async def api_lnurl_response(request: Request, unique_hash: str):
|
||||||
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw is spent."
|
status_code=HTTPStatus.NOT_FOUND, detail="Withdraw is spent."
|
||||||
)
|
)
|
||||||
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
||||||
|
|
||||||
|
# Check if url is .onion and change to http
|
||||||
|
if urlparse(url).netloc.endswith(".onion"):
|
||||||
|
# change url string scheme to http
|
||||||
|
url = url.replace("https://", "http://")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"tag": "withdrawRequest",
|
"tag": "withdrawRequest",
|
||||||
"callback": url,
|
"callback": url,
|
||||||
|
|
@ -189,6 +196,12 @@ async def api_lnurl_multi_response(request: Request, unique_hash: str, id_unique
|
||||||
)
|
)
|
||||||
|
|
||||||
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
url = request.url_for("withdraw.api_lnurl_callback", unique_hash=link.unique_hash)
|
||||||
|
|
||||||
|
# Check if url is .onion and change to http
|
||||||
|
if urlparse(url).netloc.endswith(".onion"):
|
||||||
|
# change url string scheme to http
|
||||||
|
url = url.replace("https://", "http://")
|
||||||
|
|
||||||
return {
|
return {
|
||||||
"tag": "withdrawRequest",
|
"tag": "withdrawRequest",
|
||||||
"callback": f"{url}?id_unique_hash={id_unique_hash}",
|
"callback": f"{url}?id_unique_hash={id_unique_hash}",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue