another v1 fixup + moved lnurl stuff to models
This commit is contained in:
parent
42b5edaf5d
commit
8b2b36a4f9
11 changed files with 82 additions and 104 deletions
20
models.py
20
models.py
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
from typing import Optional
|
||||
|
||||
from fastapi import Request
|
||||
from lnurl.core import encode as lnurl_encode
|
||||
from pydantic import BaseModel
|
||||
|
||||
|
||||
|
|
@ -20,5 +22,19 @@ class MyExtension(BaseModel):
|
|||
name: str
|
||||
lnurlwithdrawamount: int
|
||||
total: int
|
||||
lnurlpay: Optional[str]
|
||||
lnurlwithdraw: Optional[str]
|
||||
|
||||
def lnurlpay(self, req: Request) -> str:
|
||||
url = req.url_for("myextension.api_lnurl_pay", myextension_id=self.id)
|
||||
url_str = str(url)
|
||||
if url.netloc.endswith(".onion"):
|
||||
url_str = url_str.replace("https://", "http://")
|
||||
|
||||
return lnurl_encode(url_str)
|
||||
|
||||
def lnurlwithdraw(self, req: Request) -> str:
|
||||
url = req.url_for("myextension.api_lnurl_withdraw", myextension_id=self.id)
|
||||
url_str = str(url)
|
||||
if url.netloc.endswith(".onion"):
|
||||
url_str = url_str.replace("https://", "http://")
|
||||
|
||||
return lnurl_encode(url_str)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue