From d6975cac62ec7a5de406d383570e613076b4d2eb Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 13 Sep 2026 15:50:13 +0000 Subject: [PATCH] xmrwallet: new `short_addr_width`, `hdr_addr_width` global vars --- mmgen/xmrwallet/file/tx.py | 10 ++++------ mmgen/xmrwallet/include.py | 8 ++++---- mmgen/xmrwallet/ops/__init__.py | 6 ++++-- mmgen/xmrwallet/ops/label.py | 4 ++-- mmgen/xmrwallet/rpc.py | 7 +++---- 5 files changed, 17 insertions(+), 18 deletions(-) diff --git a/mmgen/xmrwallet/file/tx.py b/mmgen/xmrwallet/file/tx.py index dbac979a..1ce84cfa 100755 --- a/mmgen/xmrwallet/file/tx.py +++ b/mmgen/xmrwallet/file/tx.py @@ -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 ''}]") diff --git a/mmgen/xmrwallet/include.py b/mmgen/xmrwallet/include.py index afda28fb..3715f656 100755 --- a/mmgen/xmrwallet/include.py +++ b/mmgen/xmrwallet/include.py @@ -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'])) diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index c8a9e879..6442920a 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -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) diff --git a/mmgen/xmrwallet/ops/label.py b/mmgen/xmrwallet/ops/label.py index 8da7e571..3bb59d16 100755 --- a/mmgen/xmrwallet/ops/label.py +++ b/mmgen/xmrwallet/ops/label.py @@ -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: ', diff --git a/mmgen/xmrwallet/rpc.py b/mmgen/xmrwallet/rpc.py index 4b4a930a..949ebc19 100755 --- a/mmgen/xmrwallet/rpc.py +++ b/mmgen/xmrwallet/rpc.py @@ -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']))