@@ -24,7 +24,7 @@ def __init__(self):
2424 self ._items = []
2525
2626 def add (self , item ):
27- print (f"before add: { str (self )} " )
27+ # print(f"before add: {str(self)}")
2828 # Check if item already exists (using __eq__)
2929 if item not in self ._items :
3030 # Insert item in sorted position for descending order (using __gt__)
@@ -34,7 +34,7 @@ def add(self, item):
3434 return
3535 # If item is smaller than all existing items, append it
3636 self ._items .append (item )
37- print (f"after add: { str (self )} " )
37+ # print(f"after add: {str(self)}")
3838
3939 def __iter__ (self ):
4040 # Return iterator for the internal list
@@ -71,13 +71,14 @@ def __str__(self):
7171 sattext = "sats"
7272 if self .amount_sats == 1 :
7373 sattext = "sat"
74- return f"{ self .amount_sats } { sattext } @ { self .epoch_time } : { self .comment } "
74+ #return f"{self.amount_sats} {sattext} @ {self.epoch_time}: {self.comment}"
75+ return f"{ self .amount_sats } { sattext } : { self .comment } "
7576
7677 def __eq__ (self , other ):
7778 if not isinstance (other , Payment ):
7879 return False
7980 return self .epoch_time == other .epoch_time and self .amount_sats == other .amount_sats and self .comment == other .comment
80- '''
81+
8182 def __lt__ (self , other ):
8283 if not isinstance (other , Payment ):
8384 return NotImplemented
@@ -87,18 +88,16 @@ def __le__(self, other):
8788 if not isinstance (other , Payment ):
8889 return NotImplemented
8990 return (self .epoch_time , self .amount_sats , self .comment ) <= (other .epoch_time , other .amount_sats , other .comment )
90- '''
91+
9192 def __gt__ (self , other ):
9293 if not isinstance (other , Payment ):
9394 return NotImplemented
94- #return (self.epoch_time, self.amount_sats, self.comment) > (other.epoch_time, other.amount_sats, other.comment)
95- return self .epoch_time > other .epoch_time
96- '''
95+ return (self .epoch_time , self .amount_sats , self .comment ) > (other .epoch_time , other .amount_sats , other .comment )
96+
9797 def __ge__ (self , other ):
9898 if not isinstance (other , Payment ):
9999 return NotImplemented
100100 return (self .epoch_time , self .amount_sats , self .comment ) >= (other .epoch_time , other .amount_sats , other .comment )
101- '''
102101
103102class Wallet :
104103
@@ -278,6 +277,7 @@ def __init__(self, nwc_url):
278277 super ().__init__ ()
279278 self .nwc_url = nwc_url
280279 self .connected = False
280+ self .relay , self .wallet_pubkey , self .secret , self .lud16 = self .parse_nwc_url (self .nwc_url )
281281
282282 def getCommentFromTransaction (self , transaction ):
283283 comment = ""
@@ -295,7 +295,6 @@ def getCommentFromTransaction(self, transaction):
295295 return comment
296296
297297 def wallet_manager_thread (self ):
298- self .relay , self .wallet_pubkey , self .secret , self .lud16 = self .parse_nwc_url (self .nwc_url )
299298 self .private_key = PrivateKey (bytes .fromhex (self .secret ))
300299 self .relay_manager = RelayManager ()
301300 self .relay_manager .add_relay (self .relay )
@@ -375,15 +374,15 @@ def wallet_manager_thread(self):
375374 continue
376375 new_balance = self .last_known_balance + amount
377376 self .handle_new_balance (new_balance , False )
378- epoch_time = transaction ["created_at" ]
377+ epoch_time = notification ["created_at" ]
379378 comment = self .getCommentFromTransaction (notification )
380379 paymentObj = Payment (epoch_time , amount , comment )
381380 self .handle_new_payment (paymentObj )
382381 else :
383382 print ("Unsupported response, ignoring." )
384383 except Exception as e :
385384 print (f"DEBUG: Error processing response: { e } " )
386- time .sleep (1 )
385+ time .sleep (0.2 )
387386
388387 print ("NWCWallet: manage_wallet_thread stopping, closing connections..." )
389388 self .relay_manager .close_connections ()
0 commit comments