Skip to content

fix: decode uppercase segwit addresses#20

Open
modelsbridgeaicom-ship-it wants to merge 1 commit into
BitgesellOfficial:masterfrom
modelsbridgeaicom-ship-it:fix/bech32-uppercase-decode
Open

fix: decode uppercase segwit addresses#20
modelsbridgeaicom-ship-it wants to merge 1 commit into
BitgesellOfficial:masterfrom
modelsbridgeaicom-ship-it:fix/bech32-uppercase-decode

Conversation

@modelsbridgeaicom-ship-it

Copy link
Copy Markdown

Summary

  • Normalize Bech32/SegWit HRPs when decoding addresses so all-uppercase BGL1... addresses decode like their lowercase form.
  • Reuse the same parsing in address_to_hash, address_to_script, address_type, address_net_type, and get_witness_version.
  • Add focused regression coverage for uppercase mainnet SegWit decoding.

Why

Bech32 addresses are valid when entirely lowercase or entirely uppercase. Before this change, the decoding helpers only recognized lowercase bgl / tbgl prefixes, so an uppercase address could fail hash/script conversion even though it represents the same address.

Validation

  • python -m compileall -q pybgl tests.py setup.py setup_tools.py
  • Focused RED/GREEN regression using local lightweight native-extension stubs:
    • origin/master returned None / UNKNOWN for uppercase Bech32 decode paths.
    • this branch returns the same hash/script/type/network/witness version as lowercase.
  • git diff --check passes with Windows line-ending warnings only.

Bounty context: submitted for the Bitgesell PR bounty program: BitgesellOfficial/bitgesell#39. Payment details can be provided if maintainers accept the PR and request them.

@MyTH-zyxeon

Copy link
Copy Markdown

Maintainer-facing review assist for the Bitgesell #39 bounty lane:

This PR is a focused bug fix for uppercase Bech32/SegWit address decoding in pybgl/functions/address.py plus regression coverage in pybgl/test/bech32_address_decode.py (+51/-14). It is currently OPEN/MERGEABLE/CLEAN with no prior PR comments or review threads visible.

What looks good:

  • The helper centralizes SegWit HRP splitting and normalizes BGL/TBGL prefixes before the decode helpers branch.
  • The touched public helpers are the right surface for this failure class: address_to_hash, address_to_script, address_type, address_net_type, and get_witness_version.
  • The new regression checks uppercase mainnet P2WPKH equivalence against the lowercase address across hash, script, type, network, and witness version.

Review points before approval:

  • Confirm whether rebase_32_to_5() intentionally rejects mixed-case Bech32 payloads. Bech32 permits all-lowercase or all-uppercase strings, but mixed-case addresses should stay invalid; if the decoder accepts both alphabets in one payload, add a mixed-case rejection fixture.
  • Consider adding one TBGL1... uppercase testnet fixture so the TESTNET_SEGWIT_ADDRESS_PREFIX path is covered too.
  • If maintainers require full package confidence, ask for a plain python tests.py or equivalent package-level run in addition to the focused compile/RED-GREEN evidence already listed.

If those checks line up, this looks like a real Bitgesell-owned bug fix rather than a metadata-only cleanup, so it is a reasonable #39 bounty-review candidate.

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