Many newcomers, like myself, may be excited to open a Bitcoin wallet for the first time, only to discover that the wallet has multiple different addresses. It can be quite confusing, like standing at a strange crossroad.
Why are there different addresses? Which one should we use?
The multiple Bitcoin addresses in the OKX wallet
What are these addresses?
The Bitcoin community is a constantly evolving community where new technologies are constantly being developed. Different address formats can be seen as a result of these new technological applications. Let’s explore the differences between these different address formats.
Legacy Address (P2PKH)
This format was used when Bitcoin was first introduced in 2009, hence the name Legacy format. It is also called the Pay-to-Public-Key-Hash (P2PKH) address because Bitcoin addresses were created from public/private key pairs.
Currently, it seems that Legacy addresses take up more space in transactions, resulting in higher transaction fees. Currently, this type of address is only used when using old wallets that are not compatible with new addresses.
One characteristic of Legacy addresses is that they all start with “1.” This is because when generating an address, a prefix is added to the public key based on different scenarios (such as testnet/mainnet), and the address will ultimately start with “1” after the hashed calculation.
Nested SegWit Address (P2SH-P2WPKH)
Compared to the traditional Legacy address, the P2SH address uses the hash of a redeem script instead of the hash of a public key. In simple terms, P2PKH pays to the hash of a public key, while P2SH pays to a redeem script. The funds inside can only be spent if the recipient meets the conditions specified in the redeem script.
By changing the payment object from a public key to a script, the flexibility is greatly increased, allowing for custom execution logic of the redeem script. A typical application includes implementing multi-signature transactions.
If the Segregated Witness (SegWit) technology is also embedded in the P2SH address, the format of this address is called a Nested SegWit address. You can learn more about Segregated Witness-related content when introducing SegWit addresses. After introducing Segregated Witness technology, the transaction size can be reduced, thus reducing transaction fees.
P2SH addresses start with “3.”
SegWit Address (Native SegWit)
Before introducing this type of address, let’s introduce the key technology inside it – Segregated Witness (SegWit). As the name suggests, Segregated Witness isolates witness data and handles it separately.
One significant advantage of doing this is reducing the size of transaction information, thus reducing transaction fees. Another benefit of reducing the size is that it increases the maximum block transaction size of Bitcoin from 1 MB to 4 MB.
The characteristic of SegWit addresses is that they start with “bc1.”
Taproot Address
The advantage of Taproot addresses lies in privacy and efficiency in complex transaction scenarios. Compared to Native SegWit, it uses the Schnorr algorithm instead of the Elliptic Curve Digital Signature Algorithm (ECDSA). The former is more efficient in batch transaction scenarios and enhances the privacy of multi-signature wallets.
Taproot addresses generally start with “bc1q.”
Which address format should I choose?
Currently, mainstream wallets such as OKX and Unisat support all four address formats mentioned above. Therefore, to reduce transaction fees, using Native SegWit and Taproot formats is more reasonable.
Furthermore, if you are interested in Bitcoin scripts, then these two address formats are the best choice. Most wallets have made additional adjustments to the scripts of these two address formats to protect your special Unspent Transaction Outputs (UTXOs) from being mistakenly transferred in transactions. Look for wallet addresses starting with “bc1”!
Of course, wallets with different address formats can still transact funds without any concerns.
If you want to check Bitcoin balances or block information, feel free to use ZAN’s node service. We provide a rich API for developers to use. For API documentation, please visit:
https://docs.zan.top/reference/zan_getbalance-enhance
Going deeper – Introduction to key technologies
After the above introduction, everyone should have a preliminary understanding of wallets, but if you are interested in some of the technologies inside wallets, like me, let’s take a look at the mysterious technologies inside.
Redeem Script
When introducing P2SH, we learned that it is a technology for redeem script transactions. So, what is a redeem script, and what is its role in the Bitcoin ecosystem?
Before introducing the redeem script, we need to explain the basic structure of a Bitcoin transaction.
Below is a typical P2PK transaction, where an address starting with “04 ae” wants to send 10 BTC to an address starting with “15 kD.” The account of the address starting with “04 ae” needs to prove ownership (having the private key) of the account to others on the chain, so they need to provide a signature (ScriptSig) in this transaction to prove their identity.
In addition to obtaining the signature, the verifier also needs to find the output script of the previous transaction corresponding to the UTXO. These two scripts concatenated together form the redeem script. The redeem script is used to prove the validity of the transaction.
In this transaction, we can see that both the signature and the output script are computer instructions. “OP_PUSHBYTES” indicates pushing data into the stack. First, in the ScriptSig, “04 ae” signs the entire transaction with its private key, and the generated signature is pushed into the stack. Then, the public key is pushed into the stack. Finally, in “OP_CHECKSIG,” the signature is decrypted with the public key to verify if the transaction is consistent. If it is consistent, it means the identity is valid.
In addition to the P2PKH method, the redeem script can also implement different identity verification methods such as P2PKH and P2SH.
Segregated Witness (SegWit)
From the above introduction, we can see that newer wallet formats all adopt Segregated Witness (SegWit) technology. So, what is a witness, and how is it segregated?
In this context, the witness can be seen as the script signature (ScriptSig) information in the basic structure of a Bitcoin transaction. Segregated Witness separates this information from the basic structure and places it in a new data structure.
In the above image, we can see that only the necessary information of the transaction, such as the transaction source and transaction output, is left. The size of the transaction is reduced. Since the yellow part (total size of the transaction) has a size limit, separating the transaction’s signature for transmission allows a block to accommodate more transactions. Additionally, since the signature part is not included in the calculation of the transaction’s hash value, it effectively solves the problem of transaction malleability.
Below is a P2TR transaction, and we can see that this transaction has an additional Witness part. Its role is to verify the legality of the transaction. After replacing ScriptSig with Witness, the method of verifying legality remains the same, that is, using the public key to decrypt the signature in the Witness and verify if the transaction’s content is consistent. Only nodes that need to verify the legality of the transaction will request Witness information. Now you can easily and stably connect to the BTC network using ZAN Node service (visit ZAN.TOP).
To summarize, Segregated Witness is the separation of the transaction’s signature part and the rest of the transaction in a single transaction, reducing the size of an individual transaction and increasing the capacity of the entire block. Furthermore, since the signature part is not included in the calculation of the transaction’s hash value, it effectively solves the problem of transaction malleability.
This article was written by Yeezo (@GaoYeezo 75065), a member of the ZAN Team (X account @zan_team).