2020-08-24 11:55:06 +00:00
|
|
|
import click
|
|
|
|
from typing import (
|
2020-09-28 14:49:37 +00:00
|
|
|
Any,
|
2020-08-24 11:55:06 +00:00
|
|
|
)
|
|
|
|
|
2020-09-28 14:49:37 +00:00
|
|
|
from eth2deposit.key_handling.key_derivation.mnemonic import (
|
2020-08-24 11:55:06 +00:00
|
|
|
verify_mnemonic,
|
|
|
|
)
|
2020-09-28 14:49:37 +00:00
|
|
|
from eth2deposit.utils.constants import (
|
2020-08-24 11:55:06 +00:00
|
|
|
WORD_LISTS_PATH,
|
|
|
|
)
|
2020-09-28 14:49:37 +00:00
|
|
|
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()
|
2020-09-28 14:49:37 +00:00
|
|
|
@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,
|
2020-09-28 14:49:37 +00:00
|
|
|
default='',
|
2020-08-24 11:55:06 +00:00
|
|
|
)
|
2020-09-28 14:49:37 +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)
|