Originally published on Unchained.com.
unleashed is the official US collaborative custody partner of Bitcoin Magazine and an integral sponsor of related content published through Bitcoin Magazine. For more information on the services offered, custodial products and the relationship between Unchained and Bitcoin Magazine, please visit our website.
If you've been using Bitcoin for a while, you've probably noticed that some Bitcoin addresses look very different from others. You may also have seen discussions around several acronyms starting with “P2”, such as P2PKH or P2WSH. If you're unfamiliar with what these acronyms mean, here we'll look at all of the standardized on-chain methods of receiving bitcoin throughout its history and explain some key differences that make each method unique.
P2PK
Pay-to-Public-Key (P2PK) is the original method of receiving Bitcoin and does not involve an address. Instead, as the name suggests, bitcoin is paid directly to an exposed public key. The very first person-to-person Bitcoin transaction used P2PK, when Satoshi Nakamoto sent coins to Hal Finney in block 170.
P2PK is no longer used because it is a more expensive, less private, and less secure way to receive bitcoins than later methods.
Fast facts
P2PKH
Pay-to-Public-Key-Hash (P2PKH) was available in the early days of Bitcoin and first appeared on the blockchain less than two weeks after the genesis block. P2PKH brings several improvements over P2PK, such as the use of an address. As indicated in our previous articleaddresses contain a checksum which 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 they are coded in Base58 format. They start with a prefix of 1 and are currently responsible for receiving and securing 43% of the mined bitcoin supply, more than any other address type.
Creating a P2PKH address involves placing a single public key via the SHA-256 and RIPEMD-160 hash functions. This reduces the amount of data, saving block space and transaction fees for the user. This also introduces additional resistance to reverse engineering of the private key beyond the secp256k1 elliptic curve already considered unbreakable.
Fast facts
P2MS
Pay-to-Multisig (P2MS) is a trivial transaction type that was only briefly relevant and never allowed more than 100 bitcoins to be held at a time across all network participants. Nevertheless, P2MS is part of the Bitcoin story.
P2MS was introduced as a standard script in early 2012, as specified by BIP 11. However, this transaction type suffered from the same problems as P2PK since it included exposed public keys and did not use any address formats. It also limited the number of public keys in a multisig quorum to three. Within a few months, P2MS would be replaced by an alternative method of receiving bitcoins in a multisig arrangement called P2SH, which we will discuss next.
Fast facts
P2SH
Pay-to-Script-Hash (P2SH) was introduced into Bitcoin as a soft fork in accordance with BIP 16 on April 1, 2012. Like most forks, the story behind it is fascinating. P2SH shares a lot in common with P2PKH. The main difference is that the address is created by hashing an exchange script instead of hashing a single public key.
A swap script can be thought of as coded instructions specifying how bitcoins received at the P2SH address can be spent in the future. There could be a wide range of possibilities, including several different public keys. The recipient, not the sender, determines the details of the script, and the spending instructions are not publicly exposed until the bitcoin is spent outside the address.
Although advanced users can create complex scripts, the most common uses of P2SH have been to create nested SegWit addresses (covered below) and multisig wallets. For example, a script might include three public keys and specify that the signatures of two of the corresponding private keys can spend bitcoin. This would create a 2 of 3 multisig address.
P2SH addresses are exactly 34 characters long and start with a prefix of 3, as specified by BIP 13. Prior to the April 1 soft fork, a handful of transactions experimented with this alternative prefix, the first of which can be found in Block 170,052.
Fast facts
P2WPKH
Pay-to-Witness-Public-Key-Hash (P2WPKH) is the first of two address types introduced into Bitcoin during the SegWit soft fork in August 2017. The history behind this extremely important and particularly controversial soft fork is documented in a book titled The block warwritten by Jonathan Bier.
P2WPKH is the SegWit variant of P2PKH, which basically means that choosing this type of address over the older P2PKH addresses will help you save money on transaction fees when moving your bitcoin.
SegWit addresses are very different from older address types because, in accordance with BIP 173, they use Bech32 encoding instead of Base58. Most notably, there are no capital letters in Bech32. P2WPKH addresses can be identified by a bc1q prefix and a character length of exactly 42.
Fast facts
P2WSH
Pay-to-Witness-Script-Hash (P2WSH) is the SegWit variant of P2SH. The main advantage of using P2WSH over P2SH is that it can help reduce transaction fees, and the main reason to use a script hash instead of a public key hash is to adapt to multisig agreements.
Like P2WPKH, a P2WSH address begins with the prefix bc1q. However, its character length is longer, exactly 62. Unlike the address types covered so far, P2WSH addresses are created using the SHA-256 hash function alone, not including RIPEMD-160, which results in increased character length. This was implemented cautiously, adding additional protection against a fairly nuanced and extremely unlikely multisig attack vector.
Fast facts
Nested SegWit (P2SH-P2WPKH and P2SH-P2WSH)
Nested SegWit (also known as Wrapped SegWit) is technically not a different address type than the one we covered above. However, this is a unique way to use the address types discussed previously in a way that is 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 SegWit native address types, P2WPKH and P2WSH. Only entities that had upgraded could send to these new addresses. This meant that people who wanted to be able to receive bitcoin from anyone (including those who hadn't upgraded) couldn't yet use a Native SegWit wallet. However, since SegWit offered cheaper transaction fees, most people were eager to start using it.
The clever solution to this dilemma was to use the P2SH transaction type. Entities that had not yet implemented SegWit could still send bitcoins to P2SH addresses which, as noted above, are built with an exchange script specifying instructions for how the bitcoins can later be spent. It turns out that these instructions could incorporate the new SegWit spending model, giving users a bridge to lower fees. Consequently, P2SH addresses using this trick became known as Nested SegWit and played an important role in the SegWit adoption process.
Ostensibly, Nested SegWit addresses are indistinguishable from other P2SH addresses, so the bitcoin supply held in this arrangement is impossible to know. Additionally, since all modern Bitcoin tools can now send directly to Native SegWit addresses, there is no longer any good reason to use Nested SegWit.
Fast facts
P2TR
Pay-to-Taproot (P2TR) is the newest address type, made available by the Taproot soft-fork in November 2021. Adoption of P2TR remains quite low at the time of writing, and many software and services Bitcoin is still working on integration.
While P2WPKH and P2WSH are known as SegWit V0, P2TR is considered SegWit V1. Notably, P2TR uses a digital signature algorithm called Schnorr, which differs from the ECDSA format used in earlier types of Bitcoin transactions. Schnorr signatures have several benefits, including additional discounts on transaction fees and increased privacy.
Regarding privacy, the key and signature aggregations enabled by Schnorr allow multisig addresses to be indistinguishable from singlesig addresses, and the full spending requirements for a P2TR address are not necessarily publicly revealed. The creator of the address can even include several custom exchange scripts to choose from in order to spend the bitcoin 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.
Fast facts
Reference table
Now that we have covered all the standardized methods for receiving bitcoins on-chain, some quick facts and address features can be combined into a handy table for your reference.
Originally published on Unchained.com.
unleashed is the official US collaborative custody partner of Bitcoin Magazine and an integral sponsor of related content published through Bitcoin Magazine. For more information on the services offered, custodial products and the relationship between Unchained and Bitcoin Magazine, please visit our website.