Files
MicroPythonOS/internal_filesystem/apps/com.micropythonos.nostr/assets/payment.py
T
Thomas Farstrike 36cc20bf45 Add com.micropythonos.nostr
Initial commit, not ready for release.
2026-01-16 18:39:53 +01:00

44 lines
1.8 KiB
Python

# Payment class remains unchanged
class Payment:
def __init__(self, epoch_time, amount_sats, comment):
self.epoch_time = epoch_time
self.amount_sats = amount_sats
self.comment = comment
def __str__(self):
sattext = "sats"
if self.amount_sats == 1:
sattext = "sat"
if not self.comment:
verb = "spent"
if self.amount_sats > 0:
verb = "received!"
return f"{self.amount_sats} {sattext} {verb}"
#return f"{self.amount_sats} {sattext} @ {self.epoch_time}: {self.comment}"
return f"{self.amount_sats} {sattext}: {self.comment}"
def __eq__(self, other):
if not isinstance(other, Payment):
return False
return self.epoch_time == other.epoch_time and self.amount_sats == other.amount_sats and self.comment == other.comment
def __lt__(self, other):
if not isinstance(other, Payment):
return NotImplemented
return (self.epoch_time, self.amount_sats, self.comment) < (other.epoch_time, other.amount_sats, other.comment)
def __le__(self, other):
if not isinstance(other, Payment):
return NotImplemented
return (self.epoch_time, self.amount_sats, self.comment) <= (other.epoch_time, other.amount_sats, other.comment)
def __gt__(self, other):
if not isinstance(other, Payment):
return NotImplemented
return (self.epoch_time, self.amount_sats, self.comment) > (other.epoch_time, other.amount_sats, other.comment)
def __ge__(self, other):
if not isinstance(other, Payment):
return NotImplemented
return (self.epoch_time, self.amount_sats, self.comment) >= (other.epoch_time, other.amount_sats, other.comment)