From efc59311181e5e0f9b13b38269f3c655d087efbe Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 1 Nov 2026 12:51:05 +0000 Subject: [PATCH] autosign: silence duplicate file opening messages for XMR compat --- mmgen/autosign/signable.py | 8 ++++---- mmgen/proto/xmr/tx/completed.py | 4 ++-- mmgen/xmrwallet/file/__init__.py | 8 ++++++-- mmgen/xmrwallet/file/tx.py | 9 +++------ mmgen/xmrwallet/ops/txview.py | 4 ++-- 5 files changed, 17 insertions(+), 16 deletions(-) diff --git a/mmgen/autosign/signable.py b/mmgen/autosign/signable.py index c76a15c1..29045fc9 100644 --- a/mmgen/autosign/signable.py +++ b/mmgen/autosign/signable.py @@ -261,10 +261,10 @@ class Signable: tx.write(ask_write=False) return tx - async def do_sign(self, f, compat_call=False): + async def do_sign(self, f, compat_call=False, silent_load=False): from .. import xmrwallet from ..xmrwallet.file.tx import MoneroMMGenTX - tx = MoneroMMGenTX.Completed(self.parent.xmrwallet_cfg, f) + tx = MoneroMMGenTX.Completed(self.parent.xmrwallet_cfg, f, silent_load=silent_load) m = xmrwallet.op( 'sign', self.parent.xmrwallet_cfg, @@ -281,9 +281,9 @@ class Signable: subext = 'asubtx' async def sign(self, f, compat_call=False): - tx1 = UnsignedTX(cfg=self.parent.xmrwallet_cfg, filename=f) + tx1 = UnsignedTX(cfg=self.parent.xmrwallet_cfg, filename=f, quiet_open=True) tx2 = SignedTX(cfg=self.parent.xmrwallet_cfg, data=tx1.__dict__, automount=self.automount) - tx2.compat_data = await self.do_sign(f, compat_call=compat_call) + tx2.compat_data = await self.do_sign(f, compat_call=compat_call, silent_load=True) tx2.file.write(ask_write=False, outdir=self.dir) return tx2 diff --git a/mmgen/proto/xmr/tx/completed.py b/mmgen/proto/xmr/tx/completed.py index f61d60ae..7291b327 100644 --- a/mmgen/proto/xmr/tx/completed.py +++ b/mmgen/proto/xmr/tx/completed.py @@ -22,12 +22,12 @@ class Completed(Base, TxCompleted): def compat_tx(self): from ....xmrwallet.file.tx import MoneroMMGenTX if self.compat_data: - return MoneroMMGenTX.ViewData(self.cfg, self.compat_data) + return MoneroMMGenTX.CompletedFromData(self.cfg, self.compat_data) elif self.raw_compat_data: return MoneroMMGenTX.Completed(self.cfg, None, compat_data=self.raw_compat_data) else: from pathlib import Path - return MoneroMMGenTX.View(self.cfg, Path(self.infile)) + return MoneroMMGenTX.Completed(self.cfg, Path(self.infile), silent_load=True) @cached_property def timestamp(self): diff --git a/mmgen/xmrwallet/file/__init__.py b/mmgen/xmrwallet/file/__init__.py index b49516cc..2a0708a6 100644 --- a/mmgen/xmrwallet/file/__init__.py +++ b/mmgen/xmrwallet/file/__init__.py @@ -55,6 +55,10 @@ class MoneroMMGenFile: 'base_chksum': self.base_chksum, 'data': self.data._asdict() | ({'metadata': None} if delete_metadata else {})} - def extract_data_from_file(self, cfg, fn): - data = json.loads(get_data_from_file(cfg, str(fn), desc=self.desc, silent=self.silent_load)) + def extract_data_from_file(self, cfg, fn, *, silent_load=False): + data = json.loads(get_data_from_file( + cfg, + str(fn), + desc = self.desc, + silent = silent_load or self.silent_load)) return data.get(self.data_label) or data['MMGenTransaction'][self.data_label] diff --git a/mmgen/xmrwallet/file/tx.py b/mmgen/xmrwallet/file/tx.py index a7c5fff4..b203df57 100644 --- a/mmgen/xmrwallet/file/tx.py +++ b/mmgen/xmrwallet/file/tx.py @@ -255,7 +255,7 @@ class MoneroMMGenTX: desc = 'transaction' forbidden_fields = () - def __init__(self, cfg, fn, *, compat_data=None): + def __init__(self, cfg, fn, *, compat_data=None, silent_load=False): super().__init__() @@ -265,7 +265,7 @@ class MoneroMMGenTX: d_wrap = compat_data else: try: - d_wrap = self.extract_data_from_file(cfg, fn) + d_wrap = self.extract_data_from_file(cfg, fn, silent_load=silent_load) except Exception as e: die('MoneroMMGenTXFileParseError', f'{type(e).__name__}: {e}\nCould not load transaction file') @@ -339,10 +339,7 @@ class MoneroMMGenTX: ext = 'subtx' silent_load = True - class View(Completed): - silent_load = True - - class ViewData(Completed): + class CompletedFromData(Completed): def __init__(self, cfg, data): MoneroMMGenTX.Base.__init__(self) self.cfg = cfg diff --git a/mmgen/xmrwallet/ops/txview.py b/mmgen/xmrwallet/ops/txview.py index 88dec0c8..816d19eb 100644 --- a/mmgen/xmrwallet/ops/txview.py +++ b/mmgen/xmrwallet/ops/txview.py @@ -40,7 +40,7 @@ class OpTxview(OpBase): files = self.uargs.infile txs = sorted( - (mtx.View(self.cfg, Path(fn)) for fn in files), + (mtx.Completed(self.cfg, Path(fn), silent_load=True) for fn in files), # old TX files have no ‘submit_time’ field: key = lambda x: getattr(x.data, 'submit_time', None) or x.data.create_time) @@ -68,7 +68,7 @@ class OpTxlist(OpTxview): @property def col_hdr(self): - return mtx.View.oneline_fs.format( + return mtx.Completed.oneline_fs.format( a = 'Network', b = 'Seed ID', c = 'Submitted' if self.cfg.autosign else 'Date',