| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
The bech32/segwit branch guard routes both `bc` (mainnet) and `tb` (testnet) HRPs into the regex, but the regex accepted `(bc|tc)`. `tc` is not a valid Bitcoin HRP (mainnet is `bc`, testnet is `tb`), and since the guard never lets a `tc`-prefixed value reach the regex, that alternative was dead code. As a result every valid testnet segwit address was rejected. Change the regex alternative to `(bc|tb)` and add a testnet address test.
| Back | FazBrowse Home | New Git URL |
Summary
btc_address() rejects every valid testnet bech32/segwit address.
The segwit branch is guarded by:
so both mainnet (bc) and testnet (tb) HRPs are routed into the regex — but the regex only accepts bc or tc:
tc is not a valid Bitcoin human-readable part (mainnet is bc, testnet is tb — see BIP173). Because the guard never lets a tc-prefixed value reach the regex, the tc alternative is dead code; the intended prefix is clearly tb. As written, any tb... address matches the guard, then fails the regex, and btc_address returns a ValidationError.
Reproduction
Fix
Tests
Added the canonical BIP173 testnet address to the valid-address cases in tests/crypto_addresses/test_btc_address.py. It fails on the current code and passes with the fix; the full file passes (9 tests).