Piggy wallet: fix QR code background, order descending, fix balance updates

This commit is contained in:
Thomas Farstrike
2025-05-30 08:35:34 +02:00
parent f1ad24a330
commit 36607cb5f9
2 changed files with 7 additions and 8 deletions
@@ -205,6 +205,8 @@ def build_main_ui():
receive_qr.set_light_color(lv.color_white())
receive_qr.update("tfar@getalby.com", len("tfar@getalby.com"))
receive_qr.align(lv.ALIGN.TOP_RIGHT,0,0)
receive_qr.set_style_border_color(lv.color_white(), 0)
receive_qr.set_style_border_width(3, 0);
style_line = lv.style_t()
style_line.init()
style_line.set_line_width(2)
@@ -24,12 +24,12 @@ class UniqueSortedList:
def add(self, item):
# Check if item already exists (using __eq__)
if item not in self._items:
# Insert item in sorted position (using __lt__)
# Insert item in sorted position for descending order (using __gt__)
for i, existing_item in enumerate(self._items):
if item < existing_item:
if item > existing_item:
self._items.insert(i, item)
return
# If item is larger than all existing items, append it
# If item is smaller than all existing items, append it
self._items.append(item)
def __iter__(self):
@@ -56,9 +56,8 @@ class UniqueSortedList:
return False
return all(p1 == p2 for p1, p2 in zip(self._items, other))
# Payment class remains unchanged
class Payment:
def __init__(self, epoch_time, amount_sats, comment):
self.epoch_time = epoch_time
self.amount_sats = amount_sats
@@ -96,8 +95,6 @@ class Payment:
return (self.epoch_time, self.amount_sats, self.comment) >= (other.epoch_time, other.amount_sats, other.comment)
class Wallet:
# These values could be loading from a cache.json file at __init__
@@ -374,7 +371,7 @@ class NWCWallet(Wallet):
elif type != "incoming":
print(f"WARNING: invalid notification type {type}, ignoring.")
continue
new_balance = self.balance + amount
new_balance = self.last_known_balance + amount
self.handle_new_balance(new_balance, False)
epoch_time = transaction["created_at"]
comment = self.getCommentFromTransaction(notification)