From c8b8e373830bbd3624ca98317611414d3074d214 Mon Sep 17 00:00:00 2001 From: The MMGen Project Date: Sun, 3 Mar 2024 09:59:01 +0000 Subject: [PATCH] xmrwallet autosign: cleanups --- mmgen/autosign.py | 7 +++--- mmgen/help/xmrwallet.py | 34 +++++++++++++++------------- mmgen/main_xmrwallet.py | 3 +-- mmgen/xmrwallet.py | 4 ++-- test/cmdtest_py_d/ct_xmr_autosign.py | 4 ++-- 5 files changed, 27 insertions(+), 25 deletions(-) diff --git a/mmgen/autosign.py b/mmgen/autosign.py index 0cc4f29e..22a56789 100755 --- a/mmgen/autosign.py +++ b/mmgen/autosign.py @@ -19,7 +19,7 @@ from subprocess import run,DEVNULL from .cfg import Config from .util import msg,msg_r,ymsg,rmsg,gmsg,bmsg,die,suf,fmt,fmt_list,async_run -from .color import yellow,red,orange +from .color import yellow,red,orange,brown from .wallet import Wallet,get_wallet_cls from .filename import find_file_in_dir from .ui import keypress_confirm @@ -266,11 +266,12 @@ class Signable: dir_name = 'xmr_outputs_dir' clean_all = True summary_footer = '\n' + action_desc = 'imported and signed' async def sign(self,f): from .xmrwallet import MoneroWalletOps,xmrwallet_uargs wallet_idx = MoneroWalletOps.wallet.get_idx_from_fn(f) - m = MoneroWalletOps.export_key_images( + m = MoneroWalletOps.import_outputs( self.parent.xmrwallet_cfg, xmrwallet_uargs( infile = str(self.parent.wallet_files[0]), # MMGen wallet file @@ -514,7 +515,7 @@ class Autosign: good.append(ret) if ret else bad.append(f) self.cfg._util.qmsg('') await asyncio.sleep(0.3) - msg(f'{len(good)} {target.desc}{suf(good)} signed') + msg(brown(f'{len(good)} {target.desc}{suf(good)} {target.action_desc}')) if bad: rmsg(f'{len(bad)} {target.desc}{suf(bad)} {target.fail_msg}') if good and not self.cfg.no_summary: diff --git a/mmgen/help/xmrwallet.py b/mmgen/help/xmrwallet.py index 63ef7224..eea3e7af 100755 --- a/mmgen/help/xmrwallet.py +++ b/mmgen/help/xmrwallet.py @@ -61,10 +61,10 @@ dump - produce JSON dumps of wallet metadata (accounts, addresses and labels) for a list or range of wallets restore - same as ‘create’, but additionally restore wallet metadata from the corresponding JSON dump files created with ‘dump’ -export-outputs - export outputs of watch-only wallets for later import - into their corresponding offline wallets -import-key-images - import key images signed by offline wallets into their - corresponding watch-only wallets +export-outputs - export outputs of watch-only wallets for import into + their corresponding offline wallets +import-key-images - import key images signed by offline wallets into their + corresponding watch-only wallets ‘LABEL’ OPERATION NOTES @@ -344,23 +344,25 @@ three cases: You might also need to do it, however, if an offline wallet is unable to sign a transaction due to missing outputs. -Export outputs from a wallet as follows (note that the --rescan-blockchain -option is required only after a ‘resubmit’ – otherwise it should be omitted): - -$ mmgen-xmrwallet --autosign --rescan-blockchain export-outputs - At the start of a new signing session, you must export outputs from ALL wallets you intend to transact with. This is necessary because the offline signing wallets have just been created and know nothing about the state of -their watch-only counterparts. +their online counterparts. -Then insert the removable device on the offline machine to import the outputs -into the corresponding signing wallet(s) (and optionally redo any failed -transaction signing operation). The signing wallet(s) will also create -signed key images. +Export outputs from a wallet as follows (for all wallets, omit the index): -Following a ‘resubmit’, you must then import the signed key images into your -online wallet as follows: +$ mmgen-xmrwallet --autosign export-outputs + +Then insert the removable device on the offline machine. This will import +the outputs into the corresponding signing wallet(s) (and optionally redo any +failed transaction signing operation). + +Following a ‘resubmit’, add the --rescan-blockchain option: + +$ mmgen-xmrwallet --autosign --rescan-blockchain export-outputs + +Insert the removable device on your online machine and import the signed key +images into your online wallet as follows: $ mmgen-xmrwallet --autosign import-key-images diff --git a/mmgen/main_xmrwallet.py b/mmgen/main_xmrwallet.py index a836d456..db463a39 100755 --- a/mmgen/main_xmrwallet.py +++ b/mmgen/main_xmrwallet.py @@ -48,8 +48,7 @@ opts_data = { '[opts] relay ', '[opts] resubmit | abort (for use with --autosign only)', '[opts] txview | txlist [TX_file] ...', - '[opts] export-outputs [wallets]', - '[opts] import-key-images [wallets]', + '[opts] export-outputs | import-key-images [wallets]', ], 'options': """ -h, --help Print this help message diff --git a/mmgen/xmrwallet.py b/mmgen/xmrwallet.py index c0a335e0..3421eee5 100755 --- a/mmgen/xmrwallet.py +++ b/mmgen/xmrwallet.py @@ -1908,8 +1908,8 @@ class MoneroWalletOps: m.write() return True - class export_key_images(wallet): - action = 'signing wallet outputs file with' + class import_outputs(wallet): + action = 'importing wallet outputs into' start_daemon = False async def main(self,fn,wallet_idx,restart_daemon=True): diff --git a/test/cmdtest_py_d/ct_xmr_autosign.py b/test/cmdtest_py_d/ct_xmr_autosign.py index 619f56bd..6358d47f 100755 --- a/test/cmdtest_py_d/ct_xmr_autosign.py +++ b/test/cmdtest_py_d/ct_xmr_autosign.py @@ -356,9 +356,9 @@ class CmdTestXMRAutosign(CmdTestXMRWallet,CmdTestAutosignThreaded): def _export_outputs(self,wallet_arg,add_opts=[]): self.insert_device_online() t = self._xmr_autosign_op( - op = 'export-outputs', + op = 'export-outputs', wallet_arg = wallet_arg, - add_opts = add_opts ) + add_opts = add_opts) t.written_to_file('Wallet outputs') self.remove_device_online() return t