From 32595f621bfa5cd2a6b2966c6d29ef1e10cfc1cd Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sat, 29 Nov 2025 09:12:49 +0000 Subject: [PATCH] whitespace, string formatting, minor fixes and cleanups --- mmgen/autosign.py | 24 ++++++++++++------------ mmgen/tw/view.py | 2 +- mmgen/tx/util.py | 4 ++-- mmgen/xmrwallet/__init__.py | 9 +++------ mmgen/xmrwallet/file/tx.py | 2 +- mmgen/xmrwallet/ops/__init__.py | 4 ++-- mmgen/xmrwallet/ops/submit.py | 6 ++---- test/cmdtest_d/xmr_autosign.py | 7 ++++--- 8 files changed, 27 insertions(+), 31 deletions(-) diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 5ad54117..3ce629b8 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -339,6 +339,7 @@ class Signable: class xmr_signable: # mixin class automount = True + summary_footer = '' def need_daemon_restart(self, m, new_idx): old_idx = self.parent.xmr_cur_wallet_idx @@ -349,14 +350,6 @@ class Signable: bmsg('\nAutosign summary:') msg('\n'.join(s.get_info(indent=' ') for s in signables) + self.summary_footer) - class xmr_transaction(xmr_signable, automount_transaction): - dir_name = 'xmr_tx_dir' - desc = 'Monero transaction' - rawext = 'rawtx' - sigext = 'sigtx' - subext = 'subtx' - summary_footer = '' - async def sign(self, f): from . import xmrwallet from .xmrwallet.file.tx import MoneroMMGenTX @@ -370,6 +363,13 @@ class Signable: tx2.write(ask_write=False) return tx2 + class xmr_transaction(xmr_signable, automount_transaction): + dir_name = 'xmr_tx_dir' + desc = 'Monero non-compat transaction' + rawext = 'rawtx' + sigext = 'sigtx' + subext = 'subtx' + class xmr_wallet_outputs_file(xmr_signable, base): desc = 'Monero wallet outputs file' rawext = 'raw' @@ -520,10 +520,10 @@ class Autosign: if sys.platform == 'darwin': # test suite uses ‘fixed-up’ shm_dir from .platform.darwin.util import MacOSRamDisk self.ramdisk = MacOSRamDisk( - cfg, - self.macOS_ramdisk_name, - self._get_macOS_ramdisk_size(), - path = self.shm_dir) + cfg, + self.macOS_ramdisk_name, + self._get_macOS_ramdisk_size(), + path = self.shm_dir) self.keyfile = self.mountpoint / 'autosign.key' diff --git a/mmgen/tw/view.py b/mmgen/tw/view.py index 7337e723..5fceace9 100755 --- a/mmgen/tw/view.py +++ b/mmgen/tw/view.py @@ -442,7 +442,7 @@ class TwView(MMGenObject, metaclass=AsyncInit): spc * (self.cols - len(f'{self.hdr_lbl} (sort order: {sort_info})'))) if hasattr(self, 'sid'): - yield f'Seed ID: {self.sid.hl()}' + yield f'Seed ID: {self.sid.hl(color=color)}' if self.filters: yield 'Filters: {}{}'.format( diff --git a/mmgen/tx/util.py b/mmgen/tx/util.py index e8f069af..149e19ab 100755 --- a/mmgen/tx/util.py +++ b/mmgen/tx/util.py @@ -20,8 +20,8 @@ def get_autosign_obj(cfg): '_clone': cfg, 'mountpoint': cfg.autosign_mountpoint, 'coins': cfg.coin, - 'online': not cfg.offline, # used only in online environment (xmrwallet, txcreate, txsend, txbump) - })) + # used only in online environment (xmrwallet, txcreate, txsend, txbump): + 'online': not cfg.offline})) def mount_removable_device(cfg): asi = get_autosign_obj(cfg) diff --git a/mmgen/xmrwallet/__init__.py b/mmgen/xmrwallet/__init__.py index dd86c2ef..102955cc 100755 --- a/mmgen/xmrwallet/__init__.py +++ b/mmgen/xmrwallet/__init__.py @@ -23,14 +23,12 @@ tx_priorities = { 1: 'low', 2: 'normal', 3: 'high', - 4: 'highest' -} + 4: 'highest'} uargs = namedtuple('xmrwallet_uargs', [ 'infile', 'wallets', - 'spec', -]) + 'spec']) uarg_info = ( lambda e, hp: { @@ -72,8 +70,7 @@ op_names = { 'export_outputs_sign': 'export', 'import_outputs': 'import', 'import_key_images': 'import', - 'wallet': 'wallet', # virtual class -} + 'wallet': 'wallet'} # virtual class kafile_arg_ops = ( 'create', diff --git a/mmgen/xmrwallet/file/tx.py b/mmgen/xmrwallet/file/tx.py index 6f6eb688..bdbbd896 100755 --- a/mmgen/xmrwallet/file/tx.py +++ b/mmgen/xmrwallet/file/tx.py @@ -275,7 +275,7 @@ class MoneroMMGenTX: if self.name not in ('View', 'Completed'): assert fn.name.endswith('.' + self.ext), ( - 'TX file {fn} has incorrect extension (not {self.ext!r})') + f'TX file {fn} has incorrect extension (not {self.ext!r})') assert getattr(d, self.req_field), ( f'{self.name} TX missing required field {self.req_field!r}') assert bool(d.sign_time) == self.signed, '{a} has {b}sign time!'.format( diff --git a/mmgen/xmrwallet/ops/__init__.py b/mmgen/xmrwallet/ops/__init__.py index 22060d69..6fe60d7d 100755 --- a/mmgen/xmrwallet/ops/__init__.py +++ b/mmgen/xmrwallet/ops/__init__.py @@ -41,6 +41,8 @@ class OpBase: break self.cfg = cfg + self.uargs = uarg_tuple + classes = tuple(gen_classes()) self.opts = tuple(set(opt for cls in classes for opt in xmrwallet.opts)) @@ -49,8 +51,6 @@ class OpBase: global fmt_amt, hl_amt, addr_width - self.uargs = uarg_tuple - def fmt_amt(amt): return self.proto.coin_amt(amt, from_unit='atomic').fmt(5, prec=12, color=True) def hl_amt(amt): diff --git a/mmgen/xmrwallet/ops/submit.py b/mmgen/xmrwallet/ops/submit.py index 5e11f466..33a5d606 100755 --- a/mmgen/xmrwallet/ops/submit.py +++ b/mmgen/xmrwallet/ops/submit.py @@ -120,10 +120,8 @@ class OpResubmit(OpSubmit): def get_tx(self): from ...autosign import Signable fns = Signable.xmr_transaction(self.asi).get_submitted() - return sorted( - (MoneroMMGenTX.Submitted(self.cfg, Path(fn)) for fn in fns), - key = lambda x: getattr(x.data, 'submit_time', None) or x.data.create_time - )[-1] + return sorted((MoneroMMGenTX.Submitted(self.cfg, Path(fn)) for fn in fns), + key = lambda x: getattr(x.data, 'submit_time', None) or x.data.create_time)[-1] class OpAbort(OpBase): opts = ('watch_only', 'autosign') diff --git a/test/cmdtest_d/xmr_autosign.py b/test/cmdtest_d/xmr_autosign.py index 4c04fa17..b343eed2 100755 --- a/test/cmdtest_d/xmr_autosign.py +++ b/test/cmdtest_d/xmr_autosign.py @@ -365,9 +365,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet, CmdTestAutosignThreaded): async def resubmit_transfer_tx1(self): return await self._submit_transfer_tx( - relay_parm = self.tx_relay_daemon_proxy_parm, - op = 'resubmit', - check_bal = False) + relay_parm = self.tx_relay_daemon_proxy_parm, + op = 'resubmit', + check_bal = False) async def submit_transfer_tx2(self): return await self._submit_transfer_tx(relay_parm=self.tx_relay_daemon_parm) @@ -530,6 +530,7 @@ class CmdTestXMRCompat(CmdTestXMRAutosign): ('alice_twview2', 'viewing Alice’s tracking wallets (reload, sort options)'), ('alice_twview3', 'viewing Alice’s tracking wallets (check balances)'), ('alice_listaddresses2', 'listing Alice’s addresses (sort options)'), + ('stop_daemons', 'stopping all wallet and coin daemons'), ) def __init__(self, cfg, trunner, cfgs, spawn):