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

42 lines
993 B
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
)
from eth2deposit.key_handling.key_derivation.mnemonic import (
2020-08-24 11:55:06 +00:00
verify_mnemonic,
)
from eth2deposit.utils.constants import (
2020-08-24 11:55:06 +00:00
WORD_LISTS_PATH,
)
from .generate_keys import (
generate_keys,
generate_keys_arguments_wrapper,
)
2020-08-24 11:55:06 +00:00
def validate_mnemonic(mnemonic: str) -> str:
if verify_mnemonic(mnemonic, WORD_LISTS_PATH):
return mnemonic
else:
raise click.BadParameter('That is not a valid mnemonic in any language.')
@click.command()
@click.pass_context
@generate_keys_arguments_wrapper
2020-08-24 11:55:06 +00:00
@click.option(
'--mnemonic',
prompt='Please enter your mnemonic separated by spaces (" ").',
required=True,
type=str,
)
@click.option(
'--mnemonic-password',
type=str,
default='',
2020-08-24 11:55:06 +00:00
)
def existing_mnemonic(ctx: click.Context, mnemonic: str, mnemonic_password: str, **kwargs: Any) -> None:
ctx.obj = {'mnemonic': mnemonic, 'mnemonic_password': mnemonic_password}
ctx.forward(generate_keys)