minor fixes
This commit is contained in:
parent
9e91b0dbc5
commit
4b41093ce9
3 changed files with 20 additions and 16 deletions
|
|
@ -98,10 +98,13 @@ class tool_cmd(tool_cmd_base):
|
|||
|
||||
async def twops(self,
|
||||
obj,pager,reverse,wide,sort,age_fmt,show_mmid,wide_show_confs,interactive):
|
||||
|
||||
obj.reverse = reverse
|
||||
obj.age_fmt = age_fmt
|
||||
obj.show_mmid = show_mmid
|
||||
|
||||
await obj.get_data(sort_key=sort,reverse_sort=reverse)
|
||||
|
||||
if interactive:
|
||||
await obj.view_and_sort()
|
||||
return True
|
||||
|
|
|
|||
|
|
@ -78,7 +78,8 @@ class TwCommon:
|
|||
async def set_dates(rpc,us):
|
||||
if us and us[0].date is None:
|
||||
# 'blocktime' differs from 'time', is same as getblockheader['time']
|
||||
dates = [o['blocktime'] for o in await rpc.gathered_call('gettransaction',[(o.txid,) for o in us])]
|
||||
dates = [ o.get('blocktime',0)
|
||||
for o in await rpc.gathered_call('gettransaction',[(o.txid,) for o in us]) ]
|
||||
for idx,o in enumerate(us):
|
||||
o.date = dates[idx]
|
||||
|
||||
|
|
@ -113,20 +114,21 @@ class TwCommon:
|
|||
ret.append('Grouped')
|
||||
return ret
|
||||
|
||||
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 do_sort(self,key=None,reverse=False):
|
||||
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
|
||||
}
|
||||
key = key or self.sort_key
|
||||
if key not in sort_funcs:
|
||||
die(1,f'{key!r}: invalid sort key. Valid options: {" ".join(sort_funcs.keys())}')
|
||||
if key not in self.sort_funcs:
|
||||
die(1,f'{key!r}: invalid sort key. Valid options: {" ".join(self.sort_funcs)}')
|
||||
self.sort_key = key
|
||||
assert type(reverse) == bool
|
||||
self.data.sort(key=sort_funcs[key],reverse=reverse or self.reverse)
|
||||
self.data.sort(key=self.sort_funcs[key],reverse=reverse or self.reverse)
|
||||
|
||||
async def format_for_display(self):
|
||||
data = self.data
|
||||
|
|
@ -236,9 +238,10 @@ class TwCommon:
|
|||
await getattr(self,action)(self.parent)
|
||||
|
||||
async def a_print(self,parent):
|
||||
outfile = '{}-{}[{}].out'.format(
|
||||
outfile = '{}-{}{}[{}].out'.format(
|
||||
parent.dump_fn_pfx,
|
||||
parent.proto.dcoin,
|
||||
('' if parent.proto.network == 'mainnet' else '-'+parent.proto.network.upper()),
|
||||
','.join(parent.sort_info(include_group=False)).lower() )
|
||||
msg('')
|
||||
from ..fileutil import write_data_to_file
|
||||
|
|
|
|||
|
|
@ -20,7 +20,7 @@
|
|||
twuo: Tracking wallet unspent outputs class for the MMGen suite
|
||||
"""
|
||||
|
||||
import time
|
||||
import asyncio
|
||||
from collections import namedtuple
|
||||
|
||||
from ..globalvars import g
|
||||
|
|
@ -58,7 +58,7 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
txid = ListItemAttr(CoinTxID)
|
||||
vout = ListItemAttr(int,typeconv=False)
|
||||
amt = ImmutableAttr(None)
|
||||
amt2 = ListItemAttr(None)
|
||||
amt2 = ListItemAttr(None) # the ETH balance for token account
|
||||
label = ListItemAttr(TwComment,reassign_ok=True)
|
||||
twmmid = ImmutableAttr(TwMMGenID,include_proto=True)
|
||||
addr = ImmutableAttr(CoinAddr,include_proto=True)
|
||||
|
|
@ -256,7 +256,6 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
await uo.get_data()
|
||||
uo.oneshot_msg = yellow(f'{capfirst(uo.item_desc)} #{idx} removed\n\n')
|
||||
else:
|
||||
import asyncio
|
||||
await asyncio.sleep(3)
|
||||
uo.oneshot_msg = red('Address could not be removed\n\n')
|
||||
|
||||
|
|
@ -271,7 +270,6 @@ class TwUnspentOutputs(MMGenObject,TwCommon,metaclass=AsyncInit):
|
|||
uo.item_desc,
|
||||
idx ))
|
||||
else:
|
||||
import asyncio
|
||||
await asyncio.sleep(3)
|
||||
uo.oneshot_msg = red('Label could not be added\n\n')
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue