checks if hostname is .onion and change scheme (#11)
* checks if hostname is .onion and change scheme * resolve @motorina0 's comments
This commit is contained in:
parent
7d32a36d51
commit
049826071c
3 changed files with 13 additions and 5 deletions
|
|
@ -3,10 +3,10 @@ from sqlite3 import Row
|
|||
from typing import Dict, Optional
|
||||
from urllib.parse import ParseResult, urlparse, urlunparse
|
||||
|
||||
from fastapi import Request
|
||||
from fastapi.param_functions import Query
|
||||
from lnurl.types import LnurlPayMetadata
|
||||
from pydantic import BaseModel
|
||||
from starlette.requests import Request
|
||||
|
||||
from lnbits.lnurl import encode as lnurl_encode
|
||||
|
||||
|
|
@ -55,8 +55,13 @@ class PayLink(BaseModel):
|
|||
data["max"] /= data["fiat_base_multiplier"]
|
||||
return cls(**data)
|
||||
|
||||
def lnurl(self, req: Request) -> str:
|
||||
def lnurl(self, req: Request) -> str:
|
||||
url = req.url_for("lnurlp.api_lnurl_response", link_id=self.id)
|
||||
# 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 lnurl_encode(str(url))
|
||||
|
||||
def success_action(self, payment_hash: str) -> Optional[Dict]:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue