From e3e215f0c666d57c5bd109beba9c0e0702b96db9 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Thu, 27 Nov 2025 11:34:09 +0000 Subject: [PATCH] xmrwallet: silence messages for `compat_call` --- mmgen/xmrwallet/__init__.py | 4 +++- mmgen/xmrwallet/ops/label.py | 13 +++++++------ mmgen/xmrwallet/ops/sweep.py | 12 +++++++----- mmgen/xmrwallet/ops/wallet.py | 14 ++++++++------ mmgen/xmrwallet/rpc.py | 4 ++-- 5 files changed, 27 insertions(+), 20 deletions(-) diff --git a/mmgen/xmrwallet/__init__.py b/mmgen/xmrwallet/__init__.py index 71b85939..dd86c2ef 100755 --- a/mmgen/xmrwallet/__init__.py +++ b/mmgen/xmrwallet/__init__.py @@ -130,4 +130,6 @@ def op(op, cfg, infile, wallets, *, spec=None, compat_call=False): 'daemon': cfg.daemon or cfg.monero_daemon, 'watch_only': cfg.watch_only or cfg.autosign or bool(cfg.autosign_mountpoint), 'wallet_dir': twctl_cls.get_tw_dir(cfg, cfg._proto)}) - return op_cls(op)(cfg, uargs(infile, wallets, spec)) + ret = op_cls(op)(cfg, uargs(infile, wallets, spec)) + ret.compat_call = compat_call + return ret diff --git a/mmgen/xmrwallet/ops/label.py b/mmgen/xmrwallet/ops/label.py index abac6f9a..fa4cf005 100755 --- a/mmgen/xmrwallet/ops/label.py +++ b/mmgen/xmrwallet/ops/label.py @@ -31,12 +31,13 @@ class OpLabel(OpMixinSpec, OpWallet): async def main(self, add_timestr='ask', auto=False): - gmsg('\n{a} label for wallet {b}, account #{c}, address #{d}'.format( - a = 'Setting' if self.label else 'Removing', - b = self.source.idx, - c = self.account, - d = self.address_idx - )) + if not self.compat_call: + gmsg('\n{a} label for wallet {b}, account #{c}, address #{d}'.format( + a = 'Setting' if self.label else 'Removing', + b = self.source.idx, + c = self.account, + d = self.address_idx)) + h = MoneroWalletRPC(self, self.source) h.open_wallet('source') diff --git a/mmgen/xmrwallet/ops/sweep.py b/mmgen/xmrwallet/ops/sweep.py index fc1cb9e0..34495c50 100755 --- a/mmgen/xmrwallet/ops/sweep.py +++ b/mmgen/xmrwallet/ops/sweep.py @@ -169,10 +169,10 @@ class OpSweep(OpMixinSpec, OpWallet): die(2, f'{self.account}: requested account index out of bounds (>{max_acct})') async def main(self): - - gmsg( - f'\n{self.stem.capitalize()}ing account #{self.account}' - f' of wallet {self.source.idx}{self.add_desc}') + if not self.compat_call: + gmsg( + f'\n{self.stem.capitalize()}ing account #{self.account}' + f' of wallet {self.source.idx}{self.add_desc}') h = MoneroWalletRPC(self, self.source) @@ -191,7 +191,9 @@ class OpSweep(OpMixinSpec, OpWallet): if self.cfg.tx_relay_daemon: self.display_tx_relay_info(indent=' ') - msg('Saving TX data to file') + if not self.compat_call: + msg('Saving TX data to file') + new_tx.write(delete_metadata=True) if self.cfg.no_relay or self.cfg.autosign: diff --git a/mmgen/xmrwallet/ops/wallet.py b/mmgen/xmrwallet/ops/wallet.py index 184aae30..5a0278bf 100755 --- a/mmgen/xmrwallet/ops/wallet.py +++ b/mmgen/xmrwallet/ops/wallet.py @@ -204,11 +204,12 @@ class OpWallet(OpBase): return 'offline signing ' if self.cfg.offline else 'watch-only ' if self.cfg.watch_only else '' async def main(self): - gmsg('\n{a}ing {b} {c}wallet{d}'.format( - a = self.stem.capitalize(), - b = len(self.addr_data), - c = self.add_wallet_desc, - d = suf(self.addr_data))) + if not self.compat_call: + gmsg('\n{a}ing {b} {c}wallet{d}'.format( + a = self.stem.capitalize(), + b = len(self.addr_data), + c = self.add_wallet_desc, + d = suf(self.addr_data))) data = [] for n, d in enumerate(self.addr_data): # [d.sec,d.addr,d.wallet_passwd,d.viewkey] fn = self.get_wallet_fn(d) @@ -218,7 +219,8 @@ class OpWallet(OpBase): c = len(self.addr_data), d = fn.name)) data.append(await self.process_wallet(d, fn, last=n == len(self.addr_data) - 1)) - gmsg(f'\n{len(data)} wallet{suf(len(data))} {self.stem}ed\n') + if not self.compat_call: + gmsg(f'\n{len(data)} wallet{suf(len(data))} {self.stem}ed\n') return data if self.return_data else sum(map(bool, data)) def head_msg(self, wallet_idx, fn): diff --git a/mmgen/xmrwallet/rpc.py b/mmgen/xmrwallet/rpc.py index fec3e40e..9b05d230 100755 --- a/mmgen/xmrwallet/rpc.py +++ b/mmgen/xmrwallet/rpc.py @@ -89,7 +89,7 @@ class MoneroWalletRPC: addrs_data = [ self.c.call('get_address', account_index=i) for i in range(len(accts_data['subaddress_accounts']))] - if print: + if print and not self.parent.compat_call: msg('\n' + '\n'.join(self.gen_accts_info( accts_data, addrs_data, @@ -113,7 +113,7 @@ class MoneroWalletRPC: return (ret['account_index'], ret['base_address']) def print_acct_addrs(self, wallet_data, account, silent=False): - if not silent: + if not (self.parent.compat_call or silent): msg('\n Addresses of account #{} ({}):'.format( account, wallet_data.accts_data['subaddress_accounts'][account]['label']))