autosign: skip dfl wallet prompt if --seed-len or --mnemonic-fmt specified

This commit is contained in:
The MMGen Project 2026-05-07 17:52:59 +00:00
commit 9e40e6c8c9
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
3 changed files with 10 additions and 6 deletions

View file

@ -817,14 +817,19 @@ class Autosign:
remove_wallet_dir()
create_wallet_dir()
wf = find_file_in_dir(get_wallet_cls('mmgen'), self.cfg.data_dir)
if wf and keypress_confirm(
def get_mn_wallet():
return Wallet(self.cfg, in_fmt=self.mn_fmts[self.cfg.mnemonic_fmt or self.dfl_mn_fmt])
if self.cfg.mnemonic_fmt or self.cfg.seed_len:
ss_in = get_mn_wallet()
elif (wf := find_file_in_dir(get_wallet_cls('mmgen'), self.cfg.data_dir)) and keypress_confirm(
cfg = self.cfg,
prompt = f'Default wallet ‘{wf}’ found.\nUse default wallet for autosigning?',
default_yes = True):
ss_in = Wallet(Config(), fn=wf)
else:
ss_in = Wallet(self.cfg, in_fmt=self.mn_fmts[self.cfg.mnemonic_fmt or self.dfl_mn_fmt])
ss_in = get_mn_wallet()
ss_out = Wallet(self.cfg, ss=ss_in, passwd_file=str(self.keyfile))
ss_out.write_to_file(desc='autosign wallet', outdir=self.wallet_dir)

View file

@ -42,7 +42,8 @@ opts_data = {
the file in volatile memory for use during the signing
session, thus permitting the deletion of the original
file for increased security.
-l, --seed-len=N Specify wallet seed length of N bits (for setup only)
-l, --seed-len=N Specify wallet seed length of N bits (for setup with
mnemonic seed phrase only)
-L, --led Use status LED to signal standby, busy and error
-m, --mountpoint=M Specify an alternate mountpoint 'M'
(default: {asi.dfl_mountpoint!r})

View file

@ -227,8 +227,6 @@ class CmdTestAutosignBase(CmdTestBase):
t.expect('Use default wallet for autosigning? (Y/n): ', 'y')
t.passphrase('MMGen wallet', wallet_passwd)
else:
if use_dfl_wallet is not None: # None => no dfl wallet present
t.expect('Use default wallet for autosigning? (Y/n): ', 'n')
mn_file = mn_file or {'mmgen': dfl_words_file, 'bip39': dfl_bip39_file}[mn_type]
mn = read_from_file(mn_file).strip().split()
if not seed_len: