<ul>
<li><strong>P2WPKH</strong> - This stands for <strong>"Pay To Witness Public Key Hash"</strong> and the scriptPubkey is OP_0 0x14 {20-byte-hash}, where OP_0 is the version, byte 0x14 is the size of the data, and the {20-byte-hash} is a HASH160(PubKey). </li>
<li><strong>P2WSH</strong> - This stands for <strong>"Pay To Witness Script Hash"</strong>  and the scriptPubkey is OP_0 0x20 {32-byte-hash}, where OP_0 is the version, byte 0x20 is the size of the data, and the {32-byte-hash} is a SHA256(script).</li>
</ul>

<p>This data is taken from: <a href="http://bcoin.io/guides/segwit.html" rel="noreferrer">http://bcoin.io/guides/segwit.html</a></p>

<hr>

<p>Examples:</p>

<p>For the <strong>P2WPKH</strong> address: "<strong>bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4</strong>"</p>

<p>OP_0 , 0x14 , HASH160(PubKey) -- looks like (in hex):</p>

<p>00 14 751e76e8199196d454941c45d1b3a323f1433bd6</p>

<p>For the <strong>P2WSH</strong> address: "<strong>bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3</strong>"</p>

<p>OP_0 , 0x20 , SHA256(script) -- looks like (in hex):</p>

<p>00 20 1863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262</p>

<p>Examples taken from <a href="http://bitcoin.sipa.be/bech32/demo/demo.html" rel="noreferrer">http://bitcoin.sipa.be/bech32/demo/demo.html</a> and <a href="https://github.com/sipa/bech32/blob/master/ref/c%2B%2B/tests.cpp" rel="noreferrer">https://github.com/sipa/bech32/blob/master/ref/c%2B%2B/tests.cpp</a> </p>

CC BY-SA 4.0
2018-12-13T23:38:11.703Z
Not MD5 (lol), it's SHA256.
Pieter Wuille
CC BY-SA 4.0
2018-12-13T23:39:09.497Z
Ah, thanks!  I thought md5 sounded wrong myself!
kawthuldrok
CC BY-SA 4.0
2018-12-13T23:17:14.743Z
2018-12-14T22:12:28.493Z
2018-12-14T22:12:28.493Z
kawthuldrok
<p>I've read over the <a href="https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki" rel="noreferrer">bip173</a>, <a href="https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki" rel="noreferrer">bip141</a>, and <a href="https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki" rel="noreferrer">bip143</a> specifications and they're a bit too technical to get at the simple answers I'm looking for.</p>

CC BY-SA 4.0
2018-12-13T23:21:17.933Z
Are you asking about the differences between P2WPKH/P2WSH in general, or about the differences between their corresponding address formats?
Pieter Wuille
CC BY-SA 4.0
2018-12-13T23:34:17.280Z
In short, both.  As you can see, I've added some of the research I've done over the past month or so.  I'm programming a bech32 encoder/decoder in perl, but also trying to understand bech32, segwit, P2WPKH, and P2WSH beyond simply porting the code from the node/c++ code in bip173.
kawthuldrok
CC BY-SA 4.0
2018-12-13T23:38:19.157Z
Also, there were few simple and concise answers that I could find with a google search that correspond to bech32 validation and how bech32 relates to SegWit, so I wanted to share the conclusions I came to.
kawthuldrok
<segregated-witness><bech32-address><p2wpkh><p2wsh>
In simple terms, what are the major differences between P2WPKH and P2WSH bech32 addresses?
kawthuldrok
# In simple terms, what are the major differences between P2WPKH and P2WSH bech32 addresses?

(Asked by: username_0 on 2018-12-13)

I've read over the [bip173](https://github.com/bitcoin/bips/blob/master/bip-0173.mediawiki), [bip141](https://github.com/bitcoin/bips/blob/master/bip-0141.mediawiki), and [bip143](https://github.com/bitcoin/bips/blob/master/bip-0143.mediawiki) specifications and they're a bit too technical to get at the simple answers I'm looking for.

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

> **Comments:**
> **username_1**: Are you asking about the differences between P2WPKH/P2WSH in general, or about the differences between their corresponding address formats?  
> **username_0**: In short, both.  As you can see, I've added some of the research I've done over the past month or so.  I'm programming a bech32 encoder/decoder in perl, but also trying to understand bech32, segwit, P2WPKH, and P2WSH beyond simply porting the code from the node/c++ code in bip173.  
> **username_0**: Also, there were few simple and concise answers that I could find with a google search that correspond to bech32 validation and how bech32 relates to SegWit, so I wanted to share the conclusions I came to.  

---

## 1 answers

### Answer by username_0 on 2018-12-13. Score: 8 | Accepted answer

* **P2WPKH** - This stands for **"Pay To Witness Public Key Hash"** and the scriptPubkey is OP\_0 0x14 {20-byte-hash}, where OP\_0 is the version, byte 0x14 is the size of the data, and the {20-byte-hash} is a HASH160(PubKey).
* **P2WSH** - This stands for **"Pay To Witness Script Hash"** and the scriptPubkey is OP\_0 0x20 {32-byte-hash}, where OP\_0 is the version, byte 0x20 is the size of the data, and the {32-byte-hash} is a SHA256(script).

This data is taken from: <http://bcoin.io/guides/segwit.html>

---

Examples:

For the **P2WPKH** address: "**bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4**"

OP\_0 , 0x14 , HASH160(PubKey) -- looks like (in hex):

00 14 751e76e8199196d454941c45d1b3a323f1433bd6

For the **P2WSH** address: "**bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3**"

OP\_0 , 0x20 , SHA256(script) -- looks like (in hex):

00 20 1863143c14c5166804bd19203356da136c985678cd4d27a1b8c6329604903262

Examples taken from <http://bitcoin.sipa.be/bech32/demo/demo.html> and <https://github.com/sipa/bech32/blob/master/ref/c%2B%2B/tests.cpp>

> **Comments:**
> **username_1**: Not MD5 (lol), it's SHA256.  
> **username_0**: Ah, thanks!  I thought md5 sounded wrong myself!  

---

