|
|
|
|
@ -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 |
|
|
|
|
|