TwView: improve sort keys for deterministic output

This commit is contained in:
The MMGen Project 2024-03-08 14:13:22 +00:00
commit 54d68ab33f
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 14 additions and 5 deletions

View file

@ -120,6 +120,7 @@ class BitcoinTwTransaction:
# unconfirmed transactions, e.g. replaced transactions, and the 'blocktime' field is missing
# for these, so use 'time' as a fallback.
self.time = self.tx.get('blocktime') or self.tx['time']
self.time_received = self.tx.get('timereceived')
def blockheight_disp(self,color):
return (

View file

@ -16,6 +16,14 @@ from ....tw.view import TwView
class EthereumTwView(TwView):
sort_funcs = {
'addr': lambda i: i.addr,
'age': lambda i: 0 - i.confs,
'amt': lambda i: i.amt,
'txid': lambda i: f'{i.txid} {i.vout:04}',
'twmmid': lambda i: i.twmmid.sort_key
}
def age_disp(self,o,age_fmt): # TODO
pass

View file

@ -167,7 +167,7 @@ class TwTxHistory(TwView):
}
sort_funcs = {
'age': lambda i: i.time,
'age': lambda i: '{:010}.{:010}'.format(0xffffffff - abs(i.confirmations), i.time_received or 0),
'blockheight': lambda i: 0 - abs(i.confirmations), # old/altcoin daemons return no 'blockheight' field
'amt': lambda i: i.wallet_outputs_total,
'total_amt': lambda i: i.outputs_total,

View file

@ -232,11 +232,11 @@ class TwView(MMGenObject,metaclass=AsyncInit):
}
sort_funcs = {
'addr': lambda i: i.addr,
'age': lambda i: 0 - i.confs,
'amt': lambda i: i.amt,
'addr': lambda i: '{} {:010} {:024.12f}'.format(i.addr, 0xffffffff - abs(i.confs), i.amt),
'age': lambda i: '{:010} {:024.12f}'.format(0xffffffff - abs(i.confs), i.amt),
'amt': lambda i: '{:024.12f} {:010} {}'.format(i.amt, 0xffffffff - abs(i.confs), i.addr),
'txid': lambda i: f'{i.txid} {i.vout:04}',
'twmmid': lambda i: i.twmmid.sort_key
'twmmid': lambda i: '{} {:010} {:024.12f}'.format(i.twmmid.sort_key, 0xffffffff - abs(i.confs), i.amt)
}
def sort_info(self,include_group=True):