lnbits-legend/lnbits/extensions/satspay/models.py

40 lines
792 B
Python
Raw Normal View History

2021-04-04 18:20:52 +01:00
from sqlite3 import Row
from typing import NamedTuple
2021-04-07 01:50:38 +01:00
import time
2021-04-04 18:20:52 +01:00
2021-04-05 01:48:35 +01:00
2021-04-04 18:20:52 +01:00
class Charges(NamedTuple):
id: str
user: str
description: str
onchainwallet: str
onchainaddress: str
lnbitswallet: str
payment_request: str
payment_hash: str
webhook: str
completelink: str
completelinktext: str
2021-04-07 01:50:38 +01:00
time: int
2021-04-04 18:20:52 +01:00
amount: int
balance: int
timestamp: int
@classmethod
2021-04-05 01:48:35 +01:00
def from_row(cls, row: Row) -> "Charges":
return cls(**dict(row))
2021-04-07 01:50:38 +01:00
@property
def time_elapsed(self):
if (self.timestamp + (self.time * 60)) >= time.time():
return False
else:
return True
@property
def paid(self):
if self.balance >= self.amount:
return True
else:
return False