Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions src/codex32/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,6 +189,10 @@ def _share_command(index: str, plain: bool, context: _CliContext, core: BitcoinC
derived = derive_share(artifacts, index)
except CodexError as error:
raise _CommandError(str(error)) from error
if core is not None and sys.stdout.isatty() and not plain:
given = [artifact for artifact in artifacts if isinstance(artifact, Secret)]
seed = cast(MasterSeed, given[0] if given else _secret(artifacts))
_print(f"Master fingerprint: {core.fingerprint(seed).hex().upper()}\n")
_emit(derived, plain)
if sys.stdin.isatty() and sys.stdout.isatty() and not plain:
try:
Expand Down
12 changes: 7 additions & 5 deletions tests/test_cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -1754,13 +1754,15 @@ def test_create_rejects_bip39_partial_basis_and_selector_conflicts() -> None:
assert result.exit_code != 0


def test_terminal_secret_has_fingerprint_but_share_does_not() -> None:
secret = _invoke_terminal(["secret"], VECTOR_1["secret_s"])
def test_terminal_secret_and_share_show_the_master_fingerprint() -> None:
secret = _invoke_terminal(["secret"], VECTOR_2["share_A"], VECTOR_2["share_C"])
share = _invoke_terminal(["share", "d"], VECTOR_2["share_A"], VECTOR_2["share_C"])
from_secret = _invoke_terminal(["share", "d"], VECTOR_2["secret_S"], VECTOR_2["share_C"])
fingerprint = _FakeBitcoinCore().fingerprint(cast(MasterSeed, parse_codex32(VECTOR_2["secret_S"])))
line = f"Master fingerprint: {fingerprint.hex().upper()}"

assert secret.exit_code == share.exit_code == 0
assert "Master fingerprint:" in secret.stdout
assert "Master fingerprint:" not in share.stdout
assert secret.exit_code == share.exit_code == from_secret.exit_code == 0
assert line in secret.stdout and line in share.stdout and line in from_secret.stdout
assert "Backup identifier:" in secret.stdout and "Backup identifier:" in share.stdout


Expand Down
Loading