xmrwallet autosign: cleanups

This commit is contained in:
The MMGen Project 2024-03-03 09:59:01 +00:00
commit c8b8e37383
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
5 changed files with 27 additions and 25 deletions

View file

@ -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:

View file

@ -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 <wallet index>
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 <wallet index>
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 <wallet index>
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

View file

@ -48,8 +48,7 @@ opts_data = {
'[opts] relay <TX_file>',
'[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

View file

@ -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):

View file

@ -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