mmgen-xmrwallet txview: add autosign support

This commit is contained in:
The MMGen Project 2023-04-30 09:36:00 +00:00
commit db4cc3a679
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 16 additions and 5 deletions

View file

@ -137,7 +137,8 @@ JSON and thus suitable for efficient incremental backup using git.
TXVIEW OPERATION NOTES
Transactions are displayed in chronological order based on submit time or
creation time.
creation time. With --autosign, submitted transactions on the removable
device are displayed.
SECURITY WARNING

View file

@ -49,7 +49,7 @@ opts_data = {
'[opts] sweep [xmr_keyaddrfile] SWEEP_SPEC',
'[opts] submit [TX_file]',
'[opts] relay <TX_file>',
'[opts] txview <TX_file> ...',
'[opts] txview [TX_file] ...',
'[opts] export-outputs [wallets]',
'[opts] import-key-images [wallets]',
],
@ -113,7 +113,7 @@ cmd_args = cfg._args
if cmd_args and cfg.autosign and (
cmd_args[0] in (
MoneroWalletOps.kafile_arg_ops
+ ('export-outputs','import-key-images')
+ ('export-outputs','import-key-images','txview')
)
or len(cmd_args) == 1 and cmd_args[0] == 'submit'
):
@ -171,5 +171,5 @@ try:
except Exception as e:
ymsg(f'Unable to stop wallet daemon: {type(e).__name__}: {e}')
if cfg.autosign and not cfg.test_suite:
if m.do_umount and cfg.autosign and not cfg.test_suite:
asi.do_umount()

View file

@ -616,6 +616,7 @@ class MoneroWalletOps:
opts = ('wallet_dir',)
trust_daemon = False
do_umount = True
def __init__(self,cfg,uarg_tuple):
@ -1812,12 +1813,21 @@ class MoneroWalletOps:
die(1,'Exiting at user request')
class txview(base):
opts = ('watch_only','autosign')
do_umount = False
async def main(self):
if self.cfg.autosign:
asi = get_autosign_obj(self.cfg,'xmr')
files = [f for f in asi.xmr_tx_dir.iterdir() if f.name.endswith('.'+MoneroMMGenTX.Submitted.ext)]
else:
files = uarg.infile
txs = sorted(
(MoneroMMGenTX.View( self.cfg, Path(fn) ) for fn in uarg.infile),
(MoneroMMGenTX.View( self.cfg, Path(fn) ) for fn in files),
key = lambda x: x.data.create_time
)
if self.cfg.autosign:
asi.do_umount()
self.cfg._util.stdout_or_pager(
'\n'.join(tx.get_info() for tx in txs)
)