diff --git a/electrum/gui/qml/components/controls/FormattedAmount.qml b/electrum/gui/qml/components/controls/FormattedAmount.qml index b33880ad3..80d6d778a 100644 --- a/electrum/gui/qml/components/controls/FormattedAmount.qml +++ b/electrum/gui/qml/components/controls/FormattedAmount.qml @@ -47,8 +47,9 @@ GridLayout { if (historic && timestamp) fiatLabel.text = '(' + Daemon.fx.fiatValueHistoric(amount, timestamp) + ' ' + Daemon.fx.fiatCurrency + ')' else - fiatLabel.text = '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')' - + fiatLabel.text = Daemon.fx.isRecent(timestamp) + ? '(' + Daemon.fx.fiatValue(amount) + ' ' + Daemon.fx.fiatCurrency + ')' + : '' } onAmountChanged: setFiatValue() diff --git a/electrum/gui/qml/components/controls/HistoryItemDelegate.qml b/electrum/gui/qml/components/controls/HistoryItemDelegate.qml index 79e40b4fd..3491a2a9a 100644 --- a/electrum/gui/qml/components/controls/HistoryItemDelegate.qml +++ b/electrum/gui/qml/components/controls/HistoryItemDelegate.qml @@ -105,10 +105,14 @@ Item { function updateText() { if (!Daemon.fx.enabled) { text = '' - } else if (Daemon.fx.historicRates) { + } else if (Daemon.fx.historicRates && model.timestamp) { text = Daemon.fx.fiatValueHistoric(model.value, model.timestamp) + ' ' + Daemon.fx.fiatCurrency } else { - text = Daemon.fx.fiatValue(model.value, false) + ' ' + Daemon.fx.fiatCurrency + if (Daemon.fx.isRecent(model.timestamp)) { + text = Daemon.fx.fiatValue(model.value, false) + ' ' + Daemon.fx.fiatCurrency + } else { + text = '' + } } } Component.onCompleted: updateText() diff --git a/electrum/gui/qml/qefx.py b/electrum/gui/qml/qefx.py index fcb7316da..5546aca63 100644 --- a/electrum/gui/qml/qefx.py +++ b/electrum/gui/qml/qefx.py @@ -1,4 +1,4 @@ -from datetime import datetime +from datetime import datetime, timedelta from decimal import Decimal from PyQt6.QtCore import pyqtProperty, pyqtSignal, pyqtSlot, QObject, QRegularExpression @@ -164,3 +164,15 @@ class QEFX(QObject, QtEventListener): return str(v.to_integral_value()) else: return self.config.format_amount(v) + + @pyqtSlot(str, result=bool) + def isRecent(self, timestamp): + # return True if unknown, e.g. timestamp not known yet, tx in mempool + try: + td = Decimal(timestamp) + if td == 0: + return True + except Exception: + return True + dt = datetime.fromtimestamp(int(td)) + return dt + timedelta(days=1) > datetime.today()