<p>Bech32 is specified in <a href="https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki" rel="nofollow noreferrer">BIP173</a>. 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 <a href="https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki" rel="nofollow noreferrer">BIP350</a>.</p>
<p>Besides the specifications the BIPs contain test vectors which should be deployed in their entirety to verify any implementation.</p>
<p>A Java implementation of bech32(m) addresses can be found here in <a href="https://github.com/bitcoinj/bitcoinj/blob/44d0576ce4310a3d6f1859964e391fa8d981d409/core/src/main/java/org/bitcoinj/base/Bech32.java" rel="nofollow noreferrer">bitcoinj</a>.</p>

CC BY-SA 4.0
2022-08-17T14:54:12.540Z
2022-08-17T14:54:12.540Z
Murch
<p>Bitcoin core command to validate an address: <a href="https://developer.bitcoin.org/reference/rpc/validateaddress.html" rel="nofollow noreferrer">https://developer.bitcoin.org/reference/rpc/validateaddress.html</a></p>

CC BY-SA 4.0
2022-08-23T09:34:27.930Z
2022-08-23T09:34:27.930Z
Greg Tonoski
<p>Bech32 addresses start with <code>bc1</code> on the main net and <code>tb1</code> 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?</p>

CC BY-SA 4.0
2022-08-16T18:45:23.233Z
Are you looking for a specification, or example implementations, or libraries that can do this for you?
Pieter Wuille
CC BY-SA 4.0
2022-08-16T19:01:24.393Z
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](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki), and the bech32m specification in [BIP350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki)?
Murch
CC BY-SA 4.0
2022-08-16T20:56:16.073Z
Think they just want sipa's bech32 site? https://bitcoin.sipa.be/bech32/demo/demo.html
Michael Folkson
CC BY-SA 4.0
2022-08-17T10:44:59.320Z
@Murch I want to understand and implement this in a wallet. users may lock their coins or assets using a wrong address.
MJay
CC BY-SA 4.0
2022-08-17T11:06:22.957Z
@PieterWuille If you know any java implementation of that, it would be really helping.
MJay
CC BY-SA 4.0
2022-08-23T19:41:28.567Z
There's a pull request for a java implementation [here](https://github.com/sipa/bech32/pull/46), but it would need to be reviewed and tested before using it
meshcollider
<segregated-witness><bech32-address>
Bitcoin Bech32 address validation
MJay
# Bitcoin Bech32 address validation

(Asked by: username_0 on 2022-08-16)

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?

**Tags:** segregated-witness, bech32-address

> **Comments:**
> **username_1**: Are you looking for a specification, or example implementations, or libraries that can do this for you?  
> **username_2**: Please provide more information what you're trying to achieve, what you have tried, and how the outcome differed from your expectations? username_1 has some good pointers what would help us. Also, if you're looking to implement it, have you read the bech32 specification in [BIP173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki), and the bech32m specification in [BIP350](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki)?  
> **username_3**: Think they just want sipa's bech32 site? https://bitcoin.sipa.be/bech32/demo/demo.html  
> **username_0**: @username_2 I want to understand and implement this in a wallet. users may lock their coins or assets using a wrong address.  
> **username_0**: @username_1 If you know any java implementation of that, it would be really helping.  
> **username_4**: There's a pull request for a java implementation [here](https://github.com/sipa/bech32/pull/46), but it would need to be reviewed and tested before using it  

---

## 2 answers

### Answer by username_2 on 2022-08-17. Score: 2 | Accepted answer

Bech32 is specified in [BIP173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki). 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](https://github.com/bitcoin/bips/blob/master/bip-0350.mediawiki).

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](https://github.com/bitcoinj/bitcoinj/blob/44d0576ce4310a3d6f1859964e391fa8d981d409/core/src/main/java/org/bitcoinj/base/Bech32.java).


---

### Answer by username_5 on 2022-08-23. Score: 1

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


---

