mmgen-autosign: add --seed-len opt

This commit is contained in:
The MMGen Project 2024-03-10 14:43:34 +00:00
commit a9ea9ff5dc
Signed by: mmgen
GPG key ID: 3F8B1861E32B7DA2
4 changed files with 15 additions and 5 deletions

View file

@ -1 +1 @@
14.1.dev20
14.1.dev21

View file

@ -34,7 +34,8 @@ opts_data = {
--, --longhelp Print help message for long options (common options)
-c, --coins=c Coins to sign for (comma-separated list)
-I, --no-insert-check Dont check for device insertion
-l, --led Use status LED to signal standby, busy and error
-l, --seed-len=N Specify wallet seed length of N bits (for setup 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})
-M, --mnemonic-fmt=F During setup, prompt for mnemonic seed phrase of format

View file

@ -36,7 +36,12 @@ class wallet(wallet):
self._print_seed_type()
mn_len = self._choose_seedlen(self.mn_lens)
if self.cfg.seed_len:
from ..obj import Int
msg('Using seed length {} (user-configured)'.format(Int(self.cfg.seed_len).hl()))
mn_len = self.conv_cls(self.wl_id).seedlen_map[self.cfg.seed_len // 8]
else:
mn_len = self._choose_seedlen(self.mn_lens)
from ..mn_entry import mn_entry
self.mnemonic = mn_entry(self.cfg, self.wl_id)

View file

@ -123,6 +123,7 @@ class CmdTestAutosignBase(CmdTestBase):
mn_type = None,
mn_file = None,
use_dfl_wallet = False,
seed_len = None,
usr_entry_modes = False,
passwd = 'abc'):
@ -133,6 +134,7 @@ class CmdTestAutosignBase(CmdTestBase):
'mmgen-autosign',
self.opts
+ ([] if mn_desc == 'default' else [f'--mnemonic-fmt={mn_type}'])
+ ([f'--seed-len={seed_len}'] if seed_len else [])
+ ['setup'],
no_passthru_opts = True)
@ -144,8 +146,9 @@ class CmdTestAutosignBase(CmdTestBase):
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()
t.expect('words: ',{ 12:'1', 18:'2', 24:'3' }[len(mn)])
t.expect('OK? (Y/n): ','\n')
if not seed_len:
t.expect('words: ',{ 12:'1', 18:'2', 24:'3' }[len(mn)])
t.expect('OK? (Y/n): ','\n')
from mmgen.mn_entry import mn_entry
entry_mode = 'full'
mne = mn_entry(cfg, mn_type, entry_mode)
@ -541,6 +544,7 @@ class CmdTestAutosign(CmdTestAutosignBase):
fh.write('\n'.join(new_data) + '\n')
t = self.run_setup(
mn_type = 'bip39',
seed_len = 256,
usr_entry_modes = True)
with open(fn, 'w') as fh:
fh.write('\n'.join(old_data) + '\n')