xmrwallet: new short_addr_width, hdr_addr_width global vars

This commit is contained in:
The MMGen Project 2026-09-13 15:50:13 +00:00
commit d6975cac62
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 17 additions and 18 deletions

View file

@ -118,12 +118,9 @@ class MoneroMMGenTX:
[' Payment ID: {P}', pmt_id]))
from ...util2 import format_elapsed_hr
if full_address or self.cfg.full_address:
addr_disp = d.dest_address.hl(0)
else:
from ..ops import addr_width
addr_disp = d.dest_address.fmt(0, addr_width, color=True)
from ..ops import short_addr_width
from .. import tx_priorities
return fmt(fs, strip_char='\t', indent=indent).format(
a = orange(self.file_id),
b = d.seed_id.hl(),
@ -140,7 +137,8 @@ class MoneroMMGenTX:
F = (Int(d.priority).hl() + f' [{tx_priorities[d.priority]}]')
if d.priority else None,
n = d.fee.hl(),
o = addr_disp,
o = d.dest_address.hl(0) if full_address or self.cfg.full_address else
d.dest_address.fmt(0, short_addr_width, color=True),
P = pink(pmt_id.hex()) if pmt_id else None,
s = make_timestr(d.submit_time) if d.submit_time else None,
S = pink(f" [cold signed{', submitted' if d.complete else ''}]")

View file

@ -31,10 +31,11 @@ def gen_acct_addr_info(self, wallet_data, account, *, indent=''):
if d['account_index'] == account:
addrs_data[d['address_index']]['unlocked_balance'] = d['unlocked_balance']
from .ops import addr_width
from .ops import fmt_amt, hdr_addr_width, short_addr_width
yield fs.format(
I = '',
A = 'Address'.ljust(addr_width),
A = 'Address'.ljust(hdr_addr_width),
U = 'Used'.ljust(5),
B = ' Unlocked Balance',
L = 'Label')
@ -44,10 +45,9 @@ def gen_acct_addr_info(self, wallet_data, account, *, indent=''):
bal = addr['unlocked_balance']
if self.cfg.skip_empty_addresses and addr['used'] and not bal:
continue
from .ops import fmt_amt
yield fs.format(
I = addr['address_index'],
A = ca.hl(0) if self.cfg.full_address else ca.fmt(0, addr_width, color=True),
A = ca.hl(0) if self.cfg.full_address else ca.fmt(0, short_addr_width, color=True),
U = (red('True ') if addr['used'] else green('False')),
B = fmt_amt(bal),
L = pink(addr['label']))

View file

@ -25,6 +25,8 @@ from .. import uarg_info
fmt_amt = hl_amt = lambda *args, **kwargs: None # pylint
short_addr_width = 24
class OpBase:
opts = ('wallet_dir',)
@ -53,14 +55,14 @@ class OpBase:
if not hasattr(self, 'stem'):
self.stem = self.name
global fmt_amt, hl_amt, addr_width
global fmt_amt, hl_amt, hdr_addr_width
def fmt_amt(amt):
return self.proto.coin_amt(amt, from_unit='atomic').fmt(5, prec=12, color=True)
def hl_amt(amt):
return self.proto.coin_amt(amt, from_unit='atomic').hl()
addr_width = 95 if self.cfg.full_address else 24
hdr_addr_width = 95 if self.cfg.full_address else short_addr_width
self.proto = init_proto(cfg, 'xmr', network=self.cfg.network, need_amt=True)

View file

@ -62,11 +62,11 @@ class OpLabel(OpMixinSpec, OpWallet):
else '')
if not self.compat_call:
from . import short_addr_width
ca = CoinAddr(self.proto, addr['address'])
from . import addr_width
msg('\n {a} {b}\n {c} {d}\n {e} {f}'.format(
a = 'Address: ',
b = ca.hl(0) if self.cfg.full_address else ca.fmt(0, addr_width, color=True),
b = ca.hl(0) if self.cfg.full_address else ca.fmt(0, short_addr_width, color=True),
c = 'Existing label:',
d = pink(addr['label']) if addr['label'] else gray('[none]'),
e = 'New label: ',

View file

@ -64,12 +64,12 @@ class MoneroWalletRPC:
gmsg_r('done')
def gen_accts_info(self, accts_data, addrs_data, *, indent=' ', skip_empty_ok=False):
from .ops import addr_width
from .ops import fmt_amt, hdr_addr_width, short_addr_width
fs = indent + ' {I:<3} {A} {N} {B} {L}'
yield indent + f'Accounts of wallet {self.fn.name}:'
yield fs.format(
I = '',
A = 'Base Address'.ljust(addr_width),
A = 'Base Address'.ljust(hdr_addr_width),
N = 'nAddrs',
B = ' Unlocked Balance',
L = 'Label')
@ -77,10 +77,9 @@ class MoneroWalletRPC:
if skip_empty_ok and self.cfg.skip_empty_accounts and not e['unlocked_balance']:
continue
ca = CoinAddr(self.proto, e['base_address'])
from .ops import fmt_amt
yield fs.format(
I = str(e['account_index']),
A = ca.hl(0) if self.cfg.full_address else ca.fmt(0, addr_width, color=True),
A = ca.hl(0) if self.cfg.full_address else ca.fmt(0, short_addr_width, color=True),
N = red(str(len(addrs_data[i]['addresses'])).ljust(6)),
B = fmt_amt(e['unlocked_balance']),
L = pink(e['label']))