listaddresses: showbtcaddrs -> showcoinaddrs

This commit is contained in:
The MMGen Project 2022-11-09 13:05:07 +00:00
commit 26dd466635
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 19 additions and 19 deletions

View file

@ -24,7 +24,7 @@ class BitcoinTwAddrList(TwAddrList,BitcoinTwCommon):
has_age = True
async def __init__(self,proto,usr_addr_list,minconf,showempty,showbtcaddrs,all_labels,wallet=None):
async def __init__(self,proto,usr_addr_list,minconf,showempty,showcoinaddrs,all_labels,wallet=None):
self.rpc = await rpc_init(proto)
self.proto = proto
@ -42,5 +42,5 @@ class BitcoinTwAddrList(TwAddrList,BitcoinTwCommon):
continue
if label.mmid not in self:
self[label.mmid] = { 'amt':proto.coin_amt('0'), 'lbl':label, 'addr':'' }
if showbtcaddrs:
if showcoinaddrs:
self[label.mmid]['addr'] = CoinAddr(proto,addr)

View file

@ -72,7 +72,7 @@ class BitcoinTwJSON(TwJSON):
usr_addr_list = None,
minconf = 0,
showempty = True,
showbtcaddrs = True,
showcoinaddrs = True,
all_labels = False )
return self._addrlist

View file

@ -26,7 +26,7 @@ class EthereumTwAddrList(TwAddrList):
has_age = False
async def __init__(self,proto,usr_addr_list,minconf,showempty,showbtcaddrs,all_labels,wallet=None):
async def __init__(self,proto,usr_addr_list,minconf,showempty,showcoinaddrs,all_labels,wallet=None):
from ....tw.common import TwLabel
from ....tw.ctl import TrackingWallet
@ -47,7 +47,7 @@ class EthereumTwAddrList(TwAddrList):
if not label.comment or not all_labels:
continue
self[label.mmid] = {'amt': self.proto.coin_amt('0'), 'lbl': label }
if showbtcaddrs:
if showcoinaddrs:
self[label.mmid]['addr'] = CoinAddr(self.proto,d['addr'])
self[label.mmid]['lbl'].mmid.confs = None
self[label.mmid]['amt'] += bal

View file

@ -46,22 +46,22 @@ class tool_cmd(tool_cmd_base):
async def listaddress(self,
mmgen_addr:str,
minconf: 'minimum number of confirmations' = 1,
showbtcaddr: 'display coin address in addition to MMGen ID' = True,
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs' ):
minconf: 'minimum number of confirmations' = 1,
showcoinaddr: 'display coin address in addition to MMGen ID' = True,
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs' ):
"list the specified MMGen address in the tracking wallet and its balance"
return await self.listaddresses(
mmgen_addrs = mmgen_addr,
minconf = minconf,
showbtcaddrs = showbtcaddr,
age_fmt = age_fmt )
mmgen_addrs = mmgen_addr,
minconf = minconf,
showcoinaddrs = showcoinaddr,
age_fmt = age_fmt )
async def listaddresses(self,
mmgen_addrs: 'hyphenated range or comma-separated list of addresses' = '',
minconf: 'minimum number of confirmations' = 1,
pager: 'send output to pager' = False,
showbtcaddrs: 'display coin addresses in addition to MMGen IDs' = True,
showcoinaddrs:'display coin addresses in addition to MMGen IDs' = True,
showempty: 'show addresses with no balances' = True,
all_labels: 'show all addresses with labels' = False,
age_fmt: 'format for the Age/Date column ' + options_annot_str(TwCommon.age_fmts) = 'confs',
@ -90,11 +90,11 @@ class tool_cmd(tool_cmd_base):
usr_addr_list = [MMGenID(self.proto,f'{a[0]}:{i}') for i in AddrIdxList(a[1])]
from ..tw.addrs import TwAddrList
al = await TwAddrList( self.proto, usr_addr_list, minconf, showempty, showbtcaddrs, all_labels )
al = await TwAddrList( self.proto, usr_addr_list, minconf, showempty, showcoinaddrs, all_labels )
if not al:
from ..util import die
die(0,('No tracked addresses with balances!','No tracked addresses!')[showempty])
return await al.format( showbtcaddrs, sort, show_age, age_fmt or 'confs' )
return await al.format( showcoinaddrs, sort, show_age, age_fmt or 'confs' )
async def twops(self,
obj,pager,reverse,detail,sort,age_fmt,interactive,show_mmid):

View file

@ -38,12 +38,12 @@ class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
def coinaddr_list(self):
return [self[k]['addr'] for k in self]
async def format(self,showbtcaddrs,sort,show_age,age_fmt):
async def format(self,showcoinaddrs,sort,show_age,age_fmt):
if not self.has_age:
show_age = False
if age_fmt not in self.age_fmts:
die( 'BadAgeFormat', f'{age_fmt!r}: invalid age format (must be one of {self.age_fmts!r})' )
fs = '{mid}' + ('',' {addr}')[showbtcaddrs] + ' {cmt} {amt}' + ('',' {age}')[show_age]
fs = '{mid}' + ('',' {addr}')[showcoinaddrs] + ' {cmt} {amt}' + ('',' {age}')[show_age]
mmaddrs = [k for k in self.keys() if k.type == 'mmgen']
max_mmid_len = max(len(k) for k in mmaddrs) + 2 if mmaddrs else 10
max_cmt_width = max(max(v['lbl'].comment.screen_width for v in self.values()),7)
@ -74,7 +74,7 @@ class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
yield fs.format(
mid=MMGenID.fmtc('MMGenID',width=max_mmid_len),
addr=(CoinAddr.fmtc('ADDRESS',width=addr_width) if showbtcaddrs else None),
addr=(CoinAddr.fmtc('ADDRESS',width=addr_width) if showcoinaddrs else None),
cmt=TwComment.fmtc('COMMENT',width=max_cmt_width+1),
amt='BALANCE'.ljust(max_fp_len+4),
age=age_fmt.upper(),
@ -95,7 +95,7 @@ class TwAddrList(MMGenDict,TwCommon,metaclass=AsyncInit):
e = self[mmid]
yield fs.format(
mid=MMGenID.fmtc(mmid_disp,width=max_mmid_len,color=True),
addr=(e['addr'].fmt(color=True,width=addr_width) if showbtcaddrs else None),
addr=(e['addr'].fmt(color=True,width=addr_width) if showcoinaddrs else None),
cmt=e['lbl'].comment.fmt(width=max_cmt_width,color=True,nullrepl='-'),
amt=e['amt'].fmt('4.{}'.format(max(max_fp_len,3)),color=True),
age=self.age_disp(mmid,age_fmt) if show_age and hasattr(mmid,'confs') else '-'