autosign: silence duplicate file opening messages for XMR compat
This commit is contained in:
parent
a000ca85d2
commit
efc5931118
5 changed files with 17 additions and 16 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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):
|
||||
|
|
|
|||
|
|
@ -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]
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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',
|
||||
|
|
|
|||
Loading…
Reference in a new issue