segregated witness: in simple terms, what are the main differences between the addresses bech32 P2WPKH and P2WSH?

  • P2WPKH – This means "Pay to witness the public key hash" and thePubkey script 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 means "Pay witness Hash Script" and thePubkey script 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).

These data have been taken from: http://bcoin.io/guides/segwit.html


Examples:

For him P2WPKH address: "bc1qw508d6qejxtdg4y5r3zarvary0c5xw7kv8f3t4"

OP_0, 0x14, HASH160 (PubKey) – it looks (in hexadecimal):

00 14 751e76e8199196d454941c45d1b3a323f1433bd6

For him P2WSH address: "bc1qrp33g0q5c5txsp9arysrx4k6zdkfs4nce4xj0gdcccefvpysxf3qccfmv3"

OP_0, 0x20, SHA256 (script) – it looks (in hexadecimal):

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