Bug Fix: invalid address error message and test #33257

pull tomt1664 wants to merge 1 commits into bitcoin:master from tomt1664:fix_address_errors changing 2 files +5 −4
  1. tomt1664 commented at 1:40 pm on August 26, 2025: none

    Error message returned for an invalid HRP string for a correctly encoded bech32 addresses was incorrect. It was returning 'Not a valid Bech32 or Base58 encoding'. but it should return “Invalid or unsupported prefix for Segwit (Bech32) address (expected …, got …).”

    The check in the DecodeDestination function that returns "Invalid or unsupported prefix for Segwit (Bech32) address (expected ..., got ...)." was not reachable for any address, as the HRP was checked at the start of the DecodeDestination function, and if it didn’t match, then the address was assumed to be base58 or an invalid encoding, even if it was valid bech32 but with incorrect HRP.

    This fix checks if the address is a valid bech32 encoding, and then only if an invalid encoding AND incorrect HRP, then attempts to verify a base58 encoding.

  2. fix address error messages and test 5ebce6f635
  3. DrahtBot commented at 1:40 pm on August 26, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33257.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. tomt1664 closed this on Aug 26, 2025


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-09-02 12:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me