btcd/address
Lrifton92 27bbee94a5 address: reject v2-v16 segwit addresses encoded with bech32
BIP-350 requires that segregated witness outputs of version 1 through 16
use the bech32m checksum, while only version 0 uses bech32. decodeSegWitAddress
only special-cased versions 0 and 1, so a witness program with version 2-16
encoded using the legacy bech32 checksum decoded successfully, in violation of
the spec and contrary to the BIP-350 reference decoder (which rejects any
non-zero witness version that is not bech32m).

Generalize the version 1 check to cover all versions >= 1, matching the
reference decode() function. Add the relevant BIP-350 INVALID_ADDRESS vectors
(v2 and v16 encoded with bech32) as a regression test; they decoded
successfully before this change and are now rejected.

Signed-off-by: Lrifton92 <Lrifton92@users.noreply.github.com>
2026-07-21 02:22:23 +02:00
..
base58 address: move to top-level module, use v2 2026-05-14 17:56:18 -07:00
bech32 address: move to top-level module, use v2 2026-05-14 17:56:18 -07:00
address.go address: reject v2-v16 segwit addresses encoded with bech32 2026-07-21 02:22:23 +02:00
address_test.go address: move to top-level module, use v2 2026-05-14 17:56:18 -07:00
bip350_diff_test.go address: reject v2-v16 segwit addresses encoded with bech32 2026-07-21 02:22:23 +02:00
go.mod multi: pin new v2 submodule tags and bump to v0.26.0-beta.rc1 2026-05-14 19:25:06 -07:00
go.sum multi: pin new v2 submodule tags and bump to v0.26.0-beta.rc1 2026-05-14 19:25:06 -07:00
hash160.go address: move to top-level module, use v2 2026-05-14 17:56:18 -07:00
internal_test.go address: move to top-level module, use v2 2026-05-14 17:56:18 -07:00
p2a_address_test.go multi: use new v2 modules everywhere 2026-05-14 18:05:33 -07:00