diff --git a/electrum/gui/qml/components/History.qml b/electrum/gui/qml/components/History.qml index 1df795418..92a4c0eff 100644 --- a/electrum/gui/qml/components/History.qml +++ b/electrum/gui/qml/components/History.qml @@ -27,6 +27,8 @@ Pane { model: visualModel readonly property variant sectionLabels: { + 'local': qsTr('Local'), + 'mempool': qsTr('Mempool'), 'today': qsTr('Today'), 'yesterday': qsTr('Yesterday'), 'lastweek': qsTr('Last week'), diff --git a/electrum/gui/qml/components/controls/HistoryItemDelegate.qml b/electrum/gui/qml/components/controls/HistoryItemDelegate.qml index 952bee4ba..66599ffe9 100644 --- a/electrum/gui/qml/components/controls/HistoryItemDelegate.qml +++ b/electrum/gui/qml/components/controls/HistoryItemDelegate.qml @@ -64,7 +64,7 @@ Item { Layout.rowSpan: 2 source: model.lightning ? "../../../icons/lightning.png" - : model.complete + : model.complete && model.section != 'local' ? tx_icons[Math.min(6,model.confirmations)] : '../../../icons/offline_tx.png' } @@ -93,7 +93,7 @@ Item { } Label { font.pixelSize: constants.fontSizeSmall - text: model.date + text: model.date ? model.date : '' color: constants.mutedForeground } Label { diff --git a/electrum/gui/qml/qetransactionlistmodel.py b/electrum/gui/qml/qetransactionlistmodel.py index c61133a14..80a1bc7a7 100644 --- a/electrum/gui/qml/qetransactionlistmodel.py +++ b/electrum/gui/qml/qetransactionlistmodel.py @@ -89,34 +89,34 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): item['value'] = QEAmount(amount_sat=item['value'].value) item['balance'] = QEAmount(amount_sat=item['balance'].value) - # newly arriving txs have no (block) timestamp - # TODO? + if 'txid' in item: + tx = self.wallet.get_input_tx(item['txid']) + item['complete'] = tx.is_complete() + + # newly arriving txs, or (partially/fully signed) local txs have no (block) timestamp if not item['timestamp']: - item['timestamp'] = datetime.timestamp(datetime.now()) + txinfo = self.wallet.get_tx_info(tx) + item['section'] = 'mempool' if item['complete'] and not txinfo.can_broadcast else 'local' + else: + item['section'] = self.get_section_by_timestamp(item['timestamp']) + item['date'] = self.format_date_by_section(item['section'], datetime.fromtimestamp(item['timestamp'])) + + return item - txts = datetime.fromtimestamp(item['timestamp']) + def get_section_by_timestamp(self, timestamp): + txts = datetime.fromtimestamp(timestamp) today = datetime.today().replace(hour=0, minute=0, second=0, microsecond=0) if (txts > today): - item['section'] = 'today' + return 'today' elif (txts > today - timedelta(days=1)): - item['section'] = 'yesterday' + return 'yesterday' elif (txts > today - timedelta(days=7)): - item['section'] = 'lastweek' + return 'lastweek' elif (txts > today - timedelta(days=31)): - item['section'] = 'lastmonth' + return 'lastmonth' else: - item['section'] = 'older' - - item['date'] = self.format_date_by_section(item['section'], datetime.fromtimestamp(item['timestamp'])) - - if 'txid' in item: - tx = self.wallet.get_input_tx(item['txid']) - item['complete'] = tx.is_complete() - #else: - #item['complete'] = True - - return item + return 'older' def format_date_by_section(self, section, date): #TODO: l10n @@ -154,9 +154,10 @@ class QETransactionListModel(QAbstractListModel, QtEventListener): tx['height'] = info.height tx['confirmations'] = info.conf tx['timestamp'] = info.timestamp + tx['section'] = self.get_section_by_timestamp(info.timestamp) tx['date'] = self.format_date_by_section(tx['section'], datetime.fromtimestamp(info.timestamp)) index = self.index(i,0) - roles = [self._ROLE_RMAP[x] for x in ['height','confirmations','timestamp','date']] + roles = [self._ROLE_RMAP[x] for x in ['section','height','confirmations','timestamp','date']] self.dataChanged.emit(index, index, roles) return i = i + 1