commit 42cbe74e95699ccbc293d39ab499b15c6d38f922
parent 2a112b867b48427e5561e1d94ac9c7a85051fcb7
Author: ThomasV <thomasv@electrum.org>
Date: Fri, 1 Feb 2019 21:22:39 +0100
history: better handling of None timestamps
Diffstat:
2 files changed, 6 insertions(+), 6 deletions(-)
diff --git a/electrum/gui/qt/history_list.py b/electrum/gui/qt/history_list.py
@@ -140,7 +140,6 @@ class HistoryModel(QAbstractItemModel, Logger):
if is_lightning:
status = 0
if timestamp is None:
- timestamp = sys.maxsize
status_str = 'unconfirmed'
else:
status_str = format_time(int(timestamp))
@@ -154,9 +153,10 @@ class HistoryModel(QAbstractItemModel, Logger):
except KeyError:
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)
- # we sort by timestamp
- if conf<=0:
- timestamp = sys.maxsize
+
+ # we sort by timestamp
+ if timestamp is None:
+ timestamp = float("inf")
if role == Qt.UserRole:
# for sorting
diff --git a/electrum/lnworker.py b/electrum/lnworker.py
@@ -11,7 +11,6 @@ from typing import Optional, Sequence, Tuple, List, Dict, TYPE_CHECKING
import threading
import socket
import json
-import operator
from datetime import datetime, timezone
from functools import partial
@@ -197,7 +196,8 @@ class LNWorker(PrintError):
'timestamp': closing_timestamp,
}
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
for item in out:
balance_msat += item['amount_msat'] * (1 if item['direction']=='received' else -1)