Comparison of Bitcoin address types: P2PKH, P2SH, P2WPKH, etc.
Originally published on Unchained.com.
Unchained is Bitcoin Magazine’s Official US Co-Managing Partner and an essential sponsor of related content published through Bitcoin Magazine. Please visit our website to learn more about the services offered, our storage products, and the relationship between Unchained and Bitcoin Magazine.
If you’ve been using Bitcoin for a while, you’ve probably noticed that some Bitcoin addresses appear quite different from others. You may have also seen discussions of several abbreviations that start with “P2”, such as P2PKH or P2WSH. If you’re unfamiliar with what these abbreviations mean, here we take a look at all the standardized on-chain methods for receiving Bitcoin throughout history, and explain some of the essential differences that make each method unique.
P2PK
Pay-to-Public-Key (P2PK) is the original way to receive Bitcoin and does not involve an address. Instead, as the name suggests, Bitcoin is paid directly to the exposed public keys. The first Bitcoin transaction from one person to another used P2PK when Satoshi Nakamoto sent coins to Hal Finney in block 170.
P2PK is deprecated because it is a more expensive, less private, and less secure method of receiving Bitcoin compared to its successors.
Quick Facts
P2PKH
Pay-to-Public-Key-Hash (P2PKH) has been available since the early days of Bitcoin, first appearing on the blockchain less than two weeks after the genesis block was created. P2PKH has made several improvements to P2PK, including address utilization. As explained in a previous article, the address contains a checksum that helps prevent typos and loss of Bitcoin.
P2PKH addresses are typically 34 or 33 characters long (but could theoretically be as short as 26 characters) and are encoded in Base58 format. It starts with a prefix. One It is currently responsible for receiving and securing 43% of the mined Bitcoin supply, more than any other address type.
To generate a P2PKH address, you need to enter a single public key through the hash functions SHA-256 and RIPEMD-160. This helps reduce data volume, ultimately saving users block space and transaction fees. It also introduces additional resistance to reverse engineering the private key beyond the secp256k1 elliptic curve, which is already known to be unbreakable.
Quick Facts
P2MS
Pay-to-Multisig (P2MS) is a type of trivial transaction that has only been relevant for a short time and has never involved every network participant holding more than 100 Bitcoin at a time. Nonetheless, P2MS is part of Bitcoin history.
P2MS was introduced as a standard script in early 2012 as specified in BIP 11. However, this transaction type suffered from the same problems as P2PK because it involved an exposed public key and did not use an address format. We also limited the number of public keys in a multisig quorum to three. In a few months, P2MS will be replaced by an alternative method of receiving Bitcoin with a multi-signature arrangement called P2SH. We’ll discuss this next.
Quick Facts
P2SH
Pay-to-Script-Hash (P2SH) was introduced to Bitcoin as a soft fork following BIP 16 on April 1, 2012. As with most forks, the story behind it is interesting. P2SH shares many things in common with P2PKH. The main difference is that addresses are generated by hashing an exchange script instead of hashing a single public key.
A redemption script can be thought of as coded instructions that specify how the Bitcoin received to a P2SH address can be spent in the future. There can be a wide range of possibilities, including multiple different public keys. The recipient, not the sender, determines the script details, and spending instructions are not publicly exposed until the Bitcoin is spent out of that address.
Advanced users can construct complex scripts, but the most common uses for P2SH are creating nested SegWit addresses (described below) and multi-signature wallets. For example, a script could include three public keys and specify that the signatures of two of those private keys can be used to spend Bitcoin. This creates a 2/3 multi-signature address.
P2SH addresses are exactly 34 characters long and begin with the prefix 3, as specified in BIP 13. Prior to the April 1 soft fork, a handful of exchanges experimented with this alternative prefix, the first of which was found on Block. 170,052.
Quick Facts
P2WPKH
Pay-to-Witness-Public-Key-Hash (P2WPKH) is the first of two address types introduced to Bitcoin through the SegWit soft fork in August 2017. The story behind this very important and particularly controversial soft fork is documented in the following books: The Blocksize War by Jonathan Bier.
P2WPKH is a SegWit variant of P2PKH, basically, choosing this address type instead of the old P2PKH address will help you save on transaction fees when moving Bitcoin.
SegWit addresses look quite different from previous address types because they use Bech32 encoding instead of Base58 per BIP 173. In particular, Bech32 has no uppercase letters. A P2WPKH address can be identified by the prefix bc1q and a character length of exactly 42.
Quick Facts
P2WSH
Pay-to-Witness-Script-Hash (P2WSH) is a SegWit variant of P2SH. The main advantage of using P2WSH over P2SH is that it can help lower transaction fees, and the main reason for using script hashes instead of public key hashes is to accommodate multi-signature arrangements.
Like P2WPKH, P2WSH addresses start with the prefix bc1q. However, the character length is exactly 62 characters. Unlike the address types we’ve covered so far, P2WSH addresses do not include RIPEMD-160 and are generated using only the SHA-256 hashing function, which increases character length. This has been carefully implemented, adding additional protection against very subtle and highly unlikely multi-signature attack vectors.
Quick Facts
Nested SegWit (P2SH-P2WPKH and P2SH-P2WSH)
Nested SegWit (also known as Wrapped SegWit) is technically no different from the address types covered above. Nonetheless, this is a unique way to use the previously discussed address types in a way that was temporarily useful to the Bitcoin community.
When the SegWit soft fork occurred, not all Bitcoin nodes, software, and services were immediately upgraded to support the new default SegWit address types, P2WPKH and P2WSH. Only upgraded entities can send to these new addresses. This meant that native SegWit wallets were not yet available to those who wanted the ability to receive Bitcoin from anyone, even those who had not upgraded. However, most people wanted to use SegWit because it offered cheaper transaction fees.
A clever solution to this dilemma was to utilize the P2SH transaction type. Businesses that have not yet implemented SegWit can send Bitcoin to a P2SH address. As explained above, a P2SH address is built with a redemption script that specifies instructions on how the Bitcoin can be spent later. As a result, these guidelines may incorporate new SegWit spending models to provide users with a bridge to reduced fees. Therefore, P2SH addresses that use this trick are known as Nested SegWit and have played an important role in the SegWit adoption process.
On the surface, Nested SegWit addresses are indistinguishable from other P2SH addresses, so it is unknown how much Bitcoin supply is contained in this arrangement. Additionally, all modern Bitcoin tools can now send directly to native SegWit addresses, so there is no reason to use Nested SegWit anymore.
Quick Facts
P2TR
Pay-to-Taproot (P2TR) is the latest address type available through the Taproot soft fork in November 2021. As of this writing, P2TR adoption remains fairly low and many Bitcoin software and services are still working on integration.
P2WPKH and P2WSH are known as SegWit V0, while P2TR is considered SegWit V1. In particular, P2TR uses a digital signature algorithm called Schnorr, which is different from the ECDSA format used for previous types of Bitcoin transactions. Schnorr signatures have several advantages, including additional transaction fee savings and increased privacy protection.
Regarding privacy, the key and signature aggregation enabled by Schnorr makes it impossible to distinguish multi-signature addresses from single signatures, and the full spending terms for a P2TR address are not necessarily publicly disclosed. The address creator can also include several custom redemption scripts that you can choose from to spend your bitcoins later.
P2TR addresses are 62 characters long and use Bech32m encoding, a slightly modified version of Bech32, as described in BIP 350. P2TR addresses can be identified by their unique bc1p prefix.
Quick Facts
reference chart
Now that we’ve covered all the standardized methods for receiving Bitcoin on-chain, we’ve combined some quick facts and address functions into a handy chart for your reference.
Originally published on Unchained.com.
Unchained is Bitcoin Magazine’s Official US Co-Managing Partner and an essential sponsor of related content published through Bitcoin Magazine. Please visit our website to learn more about the services we offer, our storage products, and the relationship between Unchained and Bitcoin Magazine.