Skip to content

Accept uniformly uppercase SegWit addresses - #545

Open
36taransingh5-dotcom wants to merge 2 commits into
python-validators:masterfrom
36taransingh5-dotcom:fix-uppercase-segwit
Open

36taransingh5-dotcom wants to merge 2 commits into
python-validators:masterfrom
36taransingh5-dotcom:fix-uppercase-segwit

Conversation

@36taransingh5-dotcom

Copy link
Copy Markdown

btc_address() rejects all-uppercase SegWit addresses, including BC1QW508D6QEJXTDG4Y5R3ZARVARY0C5XW7KV8F3T4, a valid BIP 173 example. BIP 173 allows uppercase encodings for presentation and QR codes, while forbidding mixed case.

Normalize only uniformly cased ASCII SegWit strings before applying the existing pattern. Mixed-case strings remain rejected, including case changes confined to the prefix or data. The ASCII check prevents Unicode case lookalikes from becoming accepted during normalization. Legacy Base58 validation is unchanged.

Tests cover four mainnet/testnet examples in both cases, six mixed-case inputs, trailing newlines, and Kelvin-sign lookalikes. The four uppercase regression cases fail before the change. This keeps the documented regex-only estimate for SegWit; it does not add checksum validation or claim full BIP compliance.

Validation on Linux, CPython 3.12.15:

  • Baseline: 1,516 tests passed.
  • Final complete suite, including configured doctests: 1,530 passed.
  • Repository-wide Ruff lint and formatting checks, strict Pyright, Bandit, and git diff --check passed.
  • Re-read the committed source and tests and reran these checks against their published contents.

Other Python versions and operating systems were not run locally. Hosted CI has not been verified.

Standard and vectors: https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki

Prepared and validated with AI assistance.

Normalize only uniformly cased ASCII SegWit strings, retaining rejection of mixed case and leaving legacy Base58 validation unchanged.
Cover uniformly uppercase and lowercase BIP 173 examples, mixed-case rejection, trailing newlines and Unicode case lookalikes.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant