Bech32 addresses start with bc1 on the main net and tb1 on the test net. I want to know whether a segwit address is valid or not. How can I check that segwit addresses are correctly inserted?

  • 3
    Are you looking for a specification, or example implementations, or libraries that can do this for you? Commented Aug 16, 2022 at 18:45
  • 2
    Please provide more information what you're trying to achieve, what you have tried, and how the outcome differed from your expectations? Pieter has some good pointers what would help us. Also, if you're looking to implement it, have you read the bech32 specification in BIP173, and the bech32m specification in BIP350?
    – Murch
    Commented Aug 16, 2022 at 19:01
  • 1
    Think they just want sipa's bech32 site? bitcoin.sipa.be/bech32/demo/demo.html Commented Aug 16, 2022 at 20:56
  • @Murch I want to understand and implement this in a wallet. users may lock their coins or assets using a wrong address.
    – MJay
    Commented Aug 17, 2022 at 10:44
  • @PieterWuille If you know any java implementation of that, it would be really helping.
    – MJay
    Commented Aug 17, 2022 at 11:06

2 Answers 2


Bech32 is specified in BIP173. Native segwit outputs version 0 (P2WPKH and P2WSH) use bech32 addresses. Native segwit outputs version 1+ (P2TR) use the improved bech32m for their addresses. Bech32m is specified in BIP350.

Besides the specifications the BIPs contain test vectors which should be deployed in their entirety to verify any implementation.

A Java implementation of bech32(m) addresses can be found here in bitcoinj.


Bitcoin core command to validate an address: https://developer.bitcoin.org/reference/rpc/validateaddress.html

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.