staking-deposit-cli/eth2deposit/cli/new_mnemonic.py

46 lines
1.5 KiB
Python
Raw Normal View History

2020-08-24 11:55:06 +00:00
import click
from typing import (
Any,
2020-08-24 11:55:06 +00:00
)
2020-08-24 11:55:06 +00:00
from eth2deposit.key_handling.key_derivation.mnemonic import (
get_languages,
get_mnemonic,
)
from eth2deposit.utils.constants import WORD_LISTS_PATH
from .generate_keys import (
generate_keys,
2020-09-28 15:20:08 +00:00
generate_keys_arguments_decorator,
2020-08-24 11:55:06 +00:00
)
languages = get_languages(WORD_LISTS_PATH)
2020-08-24 11:55:06 +00:00
@click.command()
@click.pass_context
2020-08-24 11:55:06 +00:00
@click.option(
'--mnemonic_language',
prompt='Please choose your mnemonic language',
type=click.Choice(languages, case_sensitive=False),
default='english',
)
2020-09-28 15:20:08 +00:00
@generate_keys_arguments_decorator
def new_mnemonic(ctx: click.Context, mnemonic_language: str, **kwargs: Any) -> None:
2020-08-24 11:55:06 +00:00
mnemonic = get_mnemonic(language=mnemonic_language, words_path=WORD_LISTS_PATH)
test_mnemonic = ''
while mnemonic != test_mnemonic:
click.clear()
click.echo('This is your seed phrase. Write it down and store it safely, it is the ONLY way to retrieve your deposit.') # noqa: E501
click.echo('\n\n%s\n\n' % mnemonic)
click.pause('Press any key when you have written down your mnemonic.')
click.clear()
test_mnemonic = click.prompt('Please type your mnemonic (separated by spaces) to confirm you have written it down\n\n') # noqa: E501
test_mnemonic = test_mnemonic.lower()
click.clear()
# Do NOT use mnemonic_password.
ctx.obj = {'mnemonic': mnemonic, 'mnemonic_password': ''}
2020-09-29 14:24:18 +00:00
ctx.params['validator_start_index'] = 0
ctx.forward(generate_keys)