Skip to content

fix: enforce bech32 address case rules#4

Open
newmattock wants to merge 1 commit into
BitgesellOfficial:masterfrom
newmattock:fix-reject-mixed-case-bech32
Open

fix: enforce bech32 address case rules#4
newmattock wants to merge 1 commit into
BitgesellOfficial:masterfrom
newmattock:fix-reject-mixed-case-bech32

Conversation

@newmattock

@newmattock newmattock commented May 25, 2026

Copy link
Copy Markdown

Summary:
Enforce Bech32/SegWit address case rules in pybgl address validation.

Related bounty or issue:
BitgesellOfficial/bitgesell#81

What changed:

  • Accepts valid all-uppercase Bech32 addresses by matching the HRP case-insensitively before validation.
  • Keeps rejecting mixed-case Bech32 addresses before checksum normalization.
  • Allows digits in uppercase Bech32 payloads while still checking the uppercase Bech32 charset.
  • Adds regression tests for uppercase acceptance and mixed-case rejection.
  • Wires the focused regression into the existing top-level tests.py runner.

Validation:

  • python3 -m unittest pybgl.test.bech32_address_validation
  • python3 tests.py
  • git diff --check

Notes:
This is separate from pybgl#3 and does not touch packaging/build behavior.

@newmattock newmattock force-pushed the fix-reject-mixed-case-bech32 branch from 8cb2b8f to 04d5ad7 Compare May 25, 2026 18:48
@newmattock newmattock changed the title fix: reject mixed-case bech32 addresses fix: enforce bech32 address case rules May 25, 2026
@MyTH-zyxeon

Copy link
Copy Markdown

Review-assist note for the Bitgesell #81 improvement lane.

I checked the public PR body and diff. This is a focused address-validation correctness fix:

  • accepts all-uppercase Bech32/SegWit addresses by matching the HRP case-insensitively before validation
  • keeps mixed-case Bech32 payloads rejected before checksum normalization, which matches the normal Bech32 safety rule
  • allows numeric characters in uppercase payload validation instead of requiring every payload character to satisfy isupper()
  • adds a dedicated regression module and wires it into the existing top-level tests.py runner

Suggested maintainer checks before merge:

  • run python3 -m unittest pybgl.test.bech32_address_validation
  • run python3 tests.py to confirm the new focused test stays in the default suite
  • manually test one lowercase, one uppercase, and one mixed-case Bitgesell SegWit address fixture
  • confirm this PR remains independent from packaging/build changes in pybgl#3

From the public patch shape, this looks like a useful low-risk wallet/address correctness candidate for the #81 improvement queue. I did not run wallet, node, RPC, or live-chain actions for this review-assist note.

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.

2 participants