From db4cc3a67958ee2801c70d0a3225dca69a25ba32 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 30 Apr 2023 09:36:00 +0000 Subject: [PATCH] mmgen-xmrwallet txview: add autosign support --- mmgen/help/xmrwallet.py | 3 ++- mmgen/main_xmrwallet.py | 6 +++--- mmgen/xmrwallet.py | 12 +++++++++++- 3 files changed, 16 insertions(+), 5 deletions(-) diff --git a/mmgen/help/xmrwallet.py b/mmgen/help/xmrwallet.py index d0176348..db47ea59 100755 --- a/mmgen/help/xmrwallet.py +++ b/mmgen/help/xmrwallet.py @@ -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 diff --git a/mmgen/main_xmrwallet.py b/mmgen/main_xmrwallet.py index 982690ff..01e28701 100755 --- a/mmgen/main_xmrwallet.py +++ b/mmgen/main_xmrwallet.py @@ -49,7 +49,7 @@ opts_data = { '[opts] sweep [xmr_keyaddrfile] SWEEP_SPEC', '[opts] submit [TX_file]', '[opts] relay ', - '[opts] txview ...', + '[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() diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index 3d565277..6a75d88e 100755 --- a/mmgen/xmrwallet.py +++ b/mmgen/xmrwallet.py @@ -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) )