Repository navigation
bip93: Report an unused length instead of a failed checksum - #209
Draft
BenWestgate wants to merge 1 commit into
Draft
BenWestgate wants to merge 1 commit into
BenWestgate wants to merge 1 commit into
Conversation
When a string's checksum fails and its length is one its application
never uses, parse_codex32 now raises the application's length error
("This input has 47 characters. A Bitcoin master-seed backup must have
exactly 48, 54, 61, 67, 74, or 127 characters.") instead of "The
checksum does not match." A wrong length is the clearer reason, and
GUIs and API callers now get it too.
The checksum is still verified before any application rule accepts the
input; the length only picks the reason for a rejection. The CLI's own
rewrite of this message is gone.
Claude-Session: https://claude.ai/code/session_01Q1TNm1YeYW8K9W2eBvxmCD
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Before:
parse_codex32said "The checksum does not match." for a 47-characterms1string. Only the CLI rewrote that to the length error, so GUIs and API callers never saw it.After: when the checksum fails and the length is one the application never uses, the library raises the application's length error, for example "This input has 47 characters. A Bitcoin master-seed backup must have exactly 48, 54, 61, 67, 74, or 127 characters." A string with a valid length and a bad checksum still says the checksum does not match.
The checksum is still verified before any application rule accepts the input. The length only picks the reason for a rejection. Generic length errors (too short, the 94/95 gap, too long) already came first and are unchanged.
How:
_decode_codex32checks the profile text length when the checksum fails. The CLI's own rewrite in_parseis gone.api.mdand three tests that pinned the old order are updated.Stacked on #161. It changes which error a parse failure raises, so per project policy it needs a security review before it is marked ready.
Checks run locally:
python -m pytestandpython -O -m pytest(918 passed), ruff, ruff format, mypy.Generated by Claude Code