mirror of
https://github.com/LBRYFoundation/LBRY-Vault.git
synced 2025-08-28 16:01:30 +00:00
add 'txpos' field to lightning history items, in case two transactions have the same timestamp
This commit is contained in:
parent
7a51f034e4
commit
d94e40d2be
1 changed files with 5 additions and 2 deletions
|
@ -140,6 +140,7 @@ class HistoryModel(QAbstractItemModel, Logger):
|
||||||
timestamp = tx_item['timestamp']
|
timestamp = tx_item['timestamp']
|
||||||
if is_lightning:
|
if is_lightning:
|
||||||
status = 0
|
status = 0
|
||||||
|
txpos = tx_item['txpos']
|
||||||
if timestamp is None:
|
if timestamp is None:
|
||||||
status_str = 'unconfirmed'
|
status_str = 'unconfirmed'
|
||||||
else:
|
else:
|
||||||
|
@ -165,7 +166,7 @@ class HistoryModel(QAbstractItemModel, Logger):
|
||||||
HistoryColumns.STATUS:
|
HistoryColumns.STATUS:
|
||||||
# height breaks ties for unverified txns
|
# height breaks ties for unverified txns
|
||||||
# txpos breaks ties for verified same block txns
|
# txpos breaks ties for verified same block txns
|
||||||
(-timestamp, conf, -status, -height, -txpos) if not is_lightning else (-timestamp, 0,0,0,0),
|
(-timestamp, conf, -status, -height, -txpos) if not is_lightning else (-timestamp, 0,0,0,-txpos),
|
||||||
HistoryColumns.DESCRIPTION:
|
HistoryColumns.DESCRIPTION:
|
||||||
tx_item['label'] if 'label' in tx_item else None,
|
tx_item['label'] if 'label' in tx_item else None,
|
||||||
HistoryColumns.AMOUNT:
|
HistoryColumns.AMOUNT:
|
||||||
|
@ -286,7 +287,7 @@ class HistoryModel(QAbstractItemModel, Logger):
|
||||||
for tx_item in r['transactions']:
|
for tx_item in r['transactions']:
|
||||||
txid = tx_item['txid']
|
txid = tx_item['txid']
|
||||||
transactions[txid] = tx_item
|
transactions[txid] = tx_item
|
||||||
for tx_item in lightning_history:
|
for i, tx_item in enumerate(lightning_history):
|
||||||
txid = tx_item.get('txid')
|
txid = tx_item.get('txid')
|
||||||
ln_value = tx_item['amount_msat']/1000.
|
ln_value = tx_item['amount_msat']/1000.
|
||||||
if txid and txid in transactions:
|
if txid and txid in transactions:
|
||||||
|
@ -297,8 +298,10 @@ class HistoryModel(QAbstractItemModel, Logger):
|
||||||
else:
|
else:
|
||||||
tx_item['lightning'] = True
|
tx_item['lightning'] = True
|
||||||
tx_item['ln_value'] = Satoshis(ln_value)
|
tx_item['ln_value'] = Satoshis(ln_value)
|
||||||
|
tx_item['txpos'] = i # for sorting
|
||||||
key = tx_item['payment_hash'] if 'payment_hash' in tx_item else tx_item['type'] + tx_item['channel_id']
|
key = tx_item['payment_hash'] if 'payment_hash' in tx_item else tx_item['type'] + tx_item['channel_id']
|
||||||
transactions[key] = tx_item
|
transactions[key] = tx_item
|
||||||
|
|
||||||
self.beginInsertRows(QModelIndex(), 0, len(transactions)-1)
|
self.beginInsertRows(QModelIndex(), 0, len(transactions)-1)
|
||||||
self.transactions = transactions
|
self.transactions = transactions
|
||||||
self.endInsertRows()
|
self.endInsertRows()
|
||||||
|
|
Loading…
Add table
Reference in a new issue