diff --git a/src/bipsea/bip85.py b/src/bipsea/bip85.py index c5d8269..9ecf4bd 100644 --- a/src/bipsea/bip85.py +++ b/src/bipsea/bip85.py @@ -23,7 +23,7 @@ "dice": "89101'", "drng": "0'", "hex": "128169'", - "words": "39'", + "mnemonic": "39'", "wif": "2'", "xprv": "32'", } @@ -69,7 +69,7 @@ def apply_85(derived_key: ExtendedKey, path: str) -> Dict[str, Union[bytes, str] entropy = to_entropy(derived_key.data[1:]) - if app == APPLICATIONS["words"]: + if app == APPLICATIONS["mnemonic"]: language_index, n_words = indexes[:2] n_words = int(n_words[:-1]) # chop ' from hardened derivation if n_words not in N_WORDS_META.keys(): diff --git a/src/bipsea/bipsea.py b/src/bipsea/bipsea.py index e904877..0470567 100644 --- a/src/bipsea/bipsea.py +++ b/src/bipsea/bipsea.py @@ -113,19 +113,19 @@ def bip39_cmd(from_, to, input, number, passphrase, pretty): if (from_ == "random" and input) or (from_ != "random" and not input): raise click.BadOptionUsage( option_name="--from", - message="`--from words` requires `--input STRING`, `--from rand` forbids `--input`", + message="`--from [anything but 'rand']` requires `--input`, `--from rand` forbids `--input`", ) language = ISO_TO_LANGUAGE.get(from_) if language or from_ == "any": - if to == "words": + if to == "mnemonic": raise click.BadOptionUsage( option_name="--to", - message="`--to words` incompatible with `--from LANGUAGE`", + message="f`--to {from_}` incompatible with `--from [anything but 'rand']`", ) words = normalize_list(re.split(r"\s+", input), lower=True) if language and not verify_seed_words(words, language): raise click.BadParameter( - f"Unexpected {language} words from `--input` ({' '.join(words)}) or bad checksum.", + f"--input mnemonic not in {from_} or has bad checksum.", param_hint="--input", ) if from_ == "any": @@ -176,7 +176,7 @@ def bip39_cmd(from_, to, input, number, passphrase, pretty): @click.option( "-a", "--application", - default="words", + default="mnemonic", required=True, type=click.Choice(APPLICATIONS.keys()), ) @@ -184,7 +184,7 @@ def bip39_cmd(from_, to, input, number, passphrase, pretty): "-n", "--number", type=int, - help="Length of output in bytes, chars, or words, depending on the application.", + help="Length of output in bytes, chars, or words, depending on --application.", ) @click.option( "-i", @@ -209,7 +209,7 @@ def bip39_cmd(from_, to, input, number, passphrase, pretty): "-t", "--to", type=click.Choice(ENTROPY_TO_VALUES), - help="Mnemonic language for `--application words`.", + help="Output language for `--application mnemonic`.", ) def bip85_cmd(application, number, index, special, input, to): if not input: @@ -250,15 +250,15 @@ def bip85_cmd(application, number, index, special, input, to): path += f"/{app_code}" if to: - if application != "words": + if application != "mnemonic": raise click.BadOptionUsage( option_name="--to", - message="--to requires `--application words`", + message="--to requires `--application mnemonic`", ) else: to = "eng" - if application == "words": + if application == "mnemonic": language = ISO_TO_LANGUAGE[to] code_85 = next(i for i, l in INDEX_TO_LANGUAGE.items() if l == language) path += f"/{code_85}/{number}'/{index}'" diff --git a/tests/test_cli.py b/tests/test_cli.py index e89eaa2..7527c0c 100644 --- a/tests/test_cli.py +++ b/tests/test_cli.py @@ -72,7 +72,7 @@ def test_seed_option_sensitivity(runner, language, vectors): result = runner.invoke(cli, cmd) if suffix == ".": assert result.exit_code != 0 - assert "Unexpected" in result.output + assert lang_code in result.output else: assert result.exit_code == 0 result_xprv = result.output.strip().split("\n")[-1] @@ -199,7 +199,7 @@ def test_entropy_bip39(runner, vector): xprv = vector["master"] n_words = vector["mnemonic_length"] result = runner.invoke( - cli, ["entropy", "-a", "words", "--input", xprv, "-n", n_words] + cli, ["entropy", "-a", "mnemonic", "--input", xprv, "-n", n_words] ) assert result.exit_code == 0 words = result.output.strip() @@ -210,7 +210,7 @@ def test_entropy_bip39(runner, vector): def test_entropy_bip39_languages(runner, iso): xprv = MNEMONIC_12["xprv"] result = runner.invoke( - cli, ["entropy", "-a", "words", "--input", xprv, "-n", 12, "-t", iso] + cli, ["entropy", "-a", "mnemonic", "--input", xprv, "-n", 12, "-t", iso] ) assert result.exit_code == 0 words = result.output.strip()