-
Notifications
You must be signed in to change notification settings - Fork 1
/
models.py
58 lines (47 loc) · 1.44 KB
/
models.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
import json
from datetime import datetime, timezone
from typing import Optional
from fastapi import Query
from lnurl.types import LnurlPayMetadata
from pydantic import BaseModel, Field
class CreateDomain(BaseModel):
wallet: str = Query(...)
domain: str = Query(...)
cf_token: str = Query(...)
cf_zone_id: str = Query(...)
webhook: str = Query(None)
cost: int = Query(..., ge=0)
class Domain(BaseModel):
id: str
wallet: str
domain: str
cf_token: str
cf_zone_id: str
webhook: Optional[str]
cost: int
time: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
class CreateAddress(BaseModel):
domain: str = Query(...)
username: str = Query(...)
email: str = Query(None)
wallet_endpoint: str = Query(...)
wallet_key: str = Query(...)
sats: int = Query(..., ge=0)
duration: int = Query(..., ge=1)
class Address(BaseModel):
id: str
wallet: str
domain: str
email: Optional[str]
username: str
wallet_key: str
wallet_endpoint: str
sats: int
duration: int
paid: bool
time: datetime = Field(default_factory=lambda: datetime.now(timezone.utc))
async def lnurlpay_metadata(self, domain) -> LnurlPayMetadata:
text = f"Payment to {self.username}"
identifier = f"{self.username}@{domain}"
metadata = [["text/plain", text], ["text/identifier", identifier]]
return LnurlPayMetadata(json.dumps(metadata))