Browse Source

history: better handling of None timestamps

regtest_lnd
ThomasV 6 years ago
committed by SomberNight
parent
commit
81588c4b93
No known key found for this signature in database GPG Key ID: B33B5F232C6271E9
  1. 8
      electrum/gui/qt/history_list.py
  2. 4
      electrum/lnworker.py

8
electrum/gui/qt/history_list.py

@ -141,7 +141,6 @@ class HistoryModel(QAbstractItemModel, Logger):
if is_lightning: if is_lightning:
status = 0 status = 0
if timestamp is None: if timestamp is None:
timestamp = sys.maxsize
status_str = 'unconfirmed' status_str = 'unconfirmed'
else: else:
status_str = format_time(int(timestamp)) status_str = format_time(int(timestamp))
@ -155,9 +154,10 @@ class HistoryModel(QAbstractItemModel, Logger):
except KeyError: except KeyError:
tx_mined_info = self.tx_mined_info_from_tx_item(tx_item) tx_mined_info = self.tx_mined_info_from_tx_item(tx_item)
status, status_str = self.parent.wallet.get_tx_status(tx_hash, tx_mined_info) status, status_str = self.parent.wallet.get_tx_status(tx_hash, tx_mined_info)
# we sort by timestamp
if conf<=0: # we sort by timestamp
timestamp = sys.maxsize if timestamp is None:
timestamp = float("inf")
if role == Qt.UserRole: if role == Qt.UserRole:
# for sorting # for sorting

4
electrum/lnworker.py

@ -11,7 +11,6 @@ from typing import Optional, Sequence, Tuple, List, Dict, TYPE_CHECKING
import threading import threading
import socket import socket
import json import json
import operator
from datetime import datetime, timezone from datetime import datetime, timezone
from functools import partial from functools import partial
@ -197,7 +196,8 @@ class LNWorker(PrintError):
'timestamp': closing_timestamp, 'timestamp': closing_timestamp,
} }
out.append(item) out.append(item)
out.sort(key=operator.itemgetter('timestamp')) # sort by timestamp
out.sort(key=lambda x: (x.get('timestamp') or float("inf")))
balance_msat = 0 balance_msat = 0
for item in out: for item in out:
balance_msat += item['amount_msat'] * (1 if item['direction']=='received' else -1) balance_msat += item['amount_msat'] * (1 if item['direction']=='received' else -1)

Loading…
Cancel
Save