Skip to content

Commit dc5d257

Browse files
claudeBenWestgate
authored andcommitted
cli: Trim two lines from the early record gate
Reassign the expected_fingerprint argument instead of copying it into a local, and give existing_secret its None default before the source checks instead of in an else branch. Behavior is unchanged. The installed package drops from 5161 to 5159 logical review lines, which keeps the integrated #7/#42/#57/#46/#80/#81 tip under the <5200 budget. Security: the record gate still runs before any card is generated or shown, and interrupts at that gate still raise _WalletSetupInterrupted. Validation: ruff check, ruff format --check, mypy src/codex32, and pytest (918 passed, with and without -O). Refs #81, #38. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018az69UX4773mYohXAtE8kD
1 parent 12d33d4 commit dc5d257

1 file changed

Lines changed: 3 additions & 5 deletions

File tree

‎src/codex32/cli.py‎

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -401,16 +401,15 @@ def _initialize_wallet(
401401
try:
402402
if confirmed:
403403
_print("Master-seed backup confirmed.\n", err=True)
404-
expected = expected_fingerprint
405404
if restore and not identity_checked:
406-
expected = _recorded_fingerprint(core, secret)
405+
expected_fingerprint = _recorded_fingerprint(core, secret)
407406
if not restore:
408407
_show_fingerprint(core, secret, "Write it on the wallet record")
409408
name = core.initialize(
410409
secret,
411410
lambda prompt: _text(prompt, optional=True),
412411
lambda message: _print(message, err=True),
413-
expected_fingerprint=expected,
412+
expected_fingerprint=expected_fingerprint,
414413
account=account,
415414
timestamp=timestamp,
416415
)
@@ -496,6 +495,7 @@ def _create(
496495
if isinstance(source, (Share, Secret)) and not isinstance(source, MasterSeed):
497496
raise _UsageError(f"Enter one {_profile_rules(profile).label}, not a share or another backup type.")
498497
try:
498+
existing_secret: MasterSeed | None = None
499499
if isinstance(source, MasterSeed):
500500
if threshold == 0 and identifier is not None and identifier != source.header.identifier:
501501
raise _UsageError(
@@ -504,8 +504,6 @@ def _create(
504504
existing_secret = source
505505
elif source is not None:
506506
existing_secret = _generated_secret(source, None, identifier, core.fingerprint_seed)
507-
else:
508-
existing_secret = None
509507
try:
510508
expected = _recorded_fingerprint(core, existing_secret) if existing_secret is not None else None
511509
except (EOFError, KeyboardInterrupt) as error:

0 commit comments

Comments
 (0)