lnbits-legend/lnbits/extensions/scrub/models.py
2022-06-21 15:33:23 +01:00

29 lines
621 B
Python

from sqlite3 import Row
from pydantic import BaseModel
from starlette.requests import Request
from lnbits.lnurl import encode as lnurl_encode # type: ignore
class CreateScrubLink(BaseModel):
wallet: str
description: str
payoraddress: str
class ScrubLink(BaseModel):
id: str
wallet: str
description: str
payoraddress: str
@classmethod
def from_row(cls, row: Row) -> "ScrubLink":
data = dict(row)
return cls(**data)
def lnurl(self, req: Request) -> str:
url = req.url_for("scrub.api_lnurl_response", link_id=self.id)
return lnurl_encode(url)