Repository navigation
Accept 35-character testnet P2SH BTC addresses - #541
Open
Plastic-time wants to merge 1 commit into
Open
Plastic-time wants to merge 1 commit into
Plastic-time wants to merge 1 commit into
Conversation
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.
btc_address("2MzQwSSnBHWHqSAqtTVQ6v47XtaisrJa1Vc")currently fails even though it is a valid testnet P2SH address. Base58Check encodings of a 25-byte payload with version byte0xc4are always 35 characters long, but_validate_old_btc_addressonly admits lengths 25–34, so every testnet P2SH address is rejected before its checksum is checked.This change raises the upper bound to 35 characters. Some 35-character strings decode to more than 25 bytes;
int.to_bytes(25)would then raiseOverflowError, which the@validatordecorator does not catch, so those values are now rejected explicitly before the checksum check.Tests add a valid testnet P2SH address, the same address with a corrupted checksum, and a 35-character value that exceeds 25 bytes.
Validation on Python 3.12:
crypto-eth-addressesextra, which fail identically onmasterin this environment.ruff check,ruff format --checkandgit diff --checkpass.Relation to #540: both PRs edit
_validate_old_btc_address, so whichever merges second will need a small rebase. With #540's byte-preserving decoder, the explicit length check there already covers the oversized case, and only therange(25, 36)change from this PR is needed; I checked that combination passes all BTC tests from both PRs.Prepared with AI assistance.