2022-09-23 14:38:55 +01:00
|
|
|
from sqlite3 import Row
|
|
|
|
from typing import Optional
|
|
|
|
|
|
|
|
from fastapi import Query
|
|
|
|
from pydantic import BaseModel
|
|
|
|
|
2022-10-20 16:31:09 +01:00
|
|
|
|
2022-09-23 14:38:55 +01:00
|
|
|
class Gerty(BaseModel):
|
2022-09-26 10:30:48 +01:00
|
|
|
id: str = Query(None)
|
2022-09-23 14:38:55 +01:00
|
|
|
name: str
|
2022-09-29 15:08:01 +01:00
|
|
|
refresh_time: int = Query(None)
|
2022-10-20 16:58:14 +01:00
|
|
|
utc_offset: int = Query(None)
|
2022-11-17 14:13:20 +00:00
|
|
|
type: str
|
2022-10-20 16:31:09 +01:00
|
|
|
lnbits_wallets: str = Query(
|
|
|
|
None
|
|
|
|
) # Wallets to keep an eye on, {"wallet-id": "wallet-read-key, etc"}
|
|
|
|
mempool_endpoint: str = Query(None) # Mempool endpoint to use
|
|
|
|
exchange: str = Query(
|
|
|
|
None
|
|
|
|
) # BTC <-> Fiat exchange rate to pull ie "USD", in 0.0001 and sats
|
2022-09-29 12:13:12 +01:00
|
|
|
display_preferences: str = Query(None)
|
2022-09-23 14:38:55 +01:00
|
|
|
|
|
|
|
@classmethod
|
|
|
|
def from_row(cls, row: Row) -> "Gerty":
|
2022-10-20 16:31:09 +01:00
|
|
|
return cls(**dict(row))
|
2022-11-24 19:27:12 +00:00
|
|
|
|
|
|
|
|
|
|
|
#########MEMPOOL MODELS###########
|
|
|
|
|
2022-12-08 10:24:37 +00:00
|
|
|
|
2022-11-24 23:31:22 +00:00
|
|
|
class MempoolEndpoint(BaseModel):
|
|
|
|
fees_recommended: str = "/api/v1/fees/recommended"
|
|
|
|
hashrate_1w: str = "/api/v1/mining/hashrate/1w"
|
|
|
|
hashrate_1m: str = "/api/v1/mining/hashrate/1m"
|
|
|
|
statistics: str = "/api/v1/lightning/statistics/latest"
|
|
|
|
difficulty_adjustment: str = "/api/v1/difficulty-adjustment"
|
|
|
|
tip_height: str = "/api/blocks/tip/height"
|
|
|
|
mempool: str = "/api/mempool"
|
2022-11-24 19:27:12 +00:00
|
|
|
|
2022-12-08 10:24:37 +00:00
|
|
|
|
2022-11-24 19:27:12 +00:00
|
|
|
class Mempool(BaseModel):
|
2022-12-08 10:24:37 +00:00
|
|
|
mempool_endpoint: str = Query(None)
|
2022-11-24 23:31:22 +00:00
|
|
|
endpoint: str = Query(None)
|
2022-11-24 19:27:12 +00:00
|
|
|
data: str = Query(None)
|
2022-12-08 10:24:37 +00:00
|
|
|
time: int = Query(None)
|