There may be many novice friends like me who, when using WEB3 wallet for the first time, happily opened the Bitcoin wallet and prepared to copy the address, but suddenly found that the wallet they created actually had multiple different addresses. It was like walking to an unfamiliar crossroads, with a confused look on my face.
Why are there different addresses? Which of these addresses should I use?
Multiple Bitcoin addresses of OKX wallet
What are these addresses?
The Bitcoin community is a community with ever-evolving technology, and the development of technology generates new content. Different address formats can be considered the result of the application of new technologies. Next, let's explore the differences between different address formats.
Legacy Address (P2P KH)
This format was adopted when Bitcoin was first launched in 2009, so it is called the Legacy format. Because the Bitcoin address at that time was created from a public/private key pair, it is also called a payment public key hash (P2P KH) address.
At present, it seems that Legacy type addresses will take up more space in transactions, resulting in higher transaction fees. Currently, this type of address is only used when using some old wallets that are incompatible with the new address.
It can be found that Legacy addresses have a feature, that is, they all start with " 1 ". This is because when generating addresses, a prefix will be added to the generated public key according to different scenarios (such as: test network/main network), and the address of the public key with the prefix added will eventually start with " 1 " after Hash calculation.
Nested SegWit Address (P 2 SH-P 2 WPKH)
Compared with the traditional Legacy address, the P 2 SH address uses the hash of the redeem-script instead of the public key hash. In layman's terms, P2P KH pays to the hash of a public key, while P 2 SH pays to the redemption script. Only when the recipient meets the transfer conditions of the redemption script can the funds in it be spent.
Since the payment object is converted from a public key to a script, the flexibility is greatly expanded, and the execution logic of the redemption script can be customized. Typical applications include implementing multi-signature transactions.
On the basis of P 2 SH, if the segregated witness technology is embedded, the format of this address is the segregated witness compatible address (Nested SegWit). You can learn about the content related to the segregated witness when introducing the segregated witness address. After the introduction of the segregated witness technology, the transaction volume can be reduced, thereby reducing the transaction fee.
You can see that the P 2 SH address starts with “ 3 ”.
Native SegWit Address
Before introducing this type of address, we need to introduce the key technology in it - Segregated Witness (SegWit). As the name suggests, Segregated Witness is to isolate the witness data (witness) and process it separately.
A significant advantage of doing so is that it reduces the size of transaction information, thereby reducing transaction fees. Another benefit brought by the reduction in size is that the upper limit of Bitcoin block transaction size has been increased from 1 MB to 4 MB.
The characteristic of the segregated witness address is that the address starts with "bc 1".
Taproot
The advantages of Taproot addresses are privacy and efficiency in complex transaction scenarios. Compared with Native SegWit, it uses the Schnorr algorithm instead of the elliptic curve digital signature algorithm. The former is more efficient in batch transaction scenarios and improves the privacy of multi-signature wallets.
The characteristic of the main root address is that the address usually starts with "bc 1 q".
What address format should I choose?
Current mainstream wallets such as OKX, Unisat and other wallets support the above four types of addresses. Therefore, in order to reduce transaction fees, it is more reasonable to use Native SegWit and Taproot format addresses.
In addition, if you are interested in Bitcoin inscriptions, these two addresses are your best choice. Most wallets have done additional processing on the inscriptions of these two addresses to protect your special UTXO from being mistakenly transferred in transactions. Look for wallet addresses starting with "bc 1"!
Of course, wallets with different address formats can trade funds, so there is no need to worry.
If you want to check the balance or block information of Bitcoin, you are welcome to use ZAN's node service. We provide a rich API for developers to use. API documentation details: https://docs.zan.top/reference/zan_getbalance-enhance
A little deeper - introduction to key technologies
After the above introduction, everyone has more or less a preliminary understanding of the wallet. If you are as interested in some of the technical acquisitions in the wallet as I am, then let’s take a look at the mysterious technology inside.
Redeem Script
When introducing P 2 SH, we know that this is a technology for redemption script transactions. So what is a redemption script and what is its role in the Bitcoin ecosystem?
Before introducing the redemption script, we need to introduce the basic structure of Bitcoin transactions.
The following is a typical P2P K-type transaction, where the address starting with 04 ae wants to transfer 10 BTC to the address starting with 15 kD. The account with the 04 ae address needs to show others on the chain that he does have the right to use this account (owns the private key), so he needs to provide a signature (ScriptSig) in this transaction to prove his identity.
In addition to obtaining the signature, the verifier also needs to find the output script of the previous transaction corresponding to the UTXO. The combination of these two scripts is the redemption script. The purpose of the redemption script is to prove the legitimacy of the transaction.
In this transaction, we can see that the signature and output script are both a computer instruction. "OP_PUSHBYTES" means PUSH a piece of data into the stack. First, in ScriptSig 04 ae, the entire transaction is signed with its own private key, and the signature will be pushed into the stack. Then the public key is pushed into the stack, and finally in "OP_CHECKSIG", the signature is decrypted with the public key to compare whether the transaction is consistent. If it is consistent, it means that the identity is valid.
In addition to this P2P K method, the redemption script can also implement different identity authentication methods such as P2P KH and P 2 SH.
Segregated Witness
From the above introduction, we can know that the newer wallet formats currently use the isolated witness technology. So what is a witness and how is it isolated?
The Witness here can be considered as the script signature (scriptSig) information in the basic structure of Bitcoin. Segregated Witness extracts it from the basic structure and places it in a new data structure.
As can be seen in the figure above, the only necessary content in a transaction is the information about the transaction source and the transaction output. The size of the transaction has been reduced. Since the yellow part (the total size of the transaction) has a size limit, transmitting the transaction signature separately can allow a block to accommodate more transactions. In addition, since the content of the signature part is not counted when calculating the signature of the transaction, the problem of transaction scalability can be effectively solved.
Below is a P 2 TR transaction. You can see that this transaction has an additional Witness part. Its function is to verify the legitimacy of the transaction. After using Witness instead of ScriptSig, the way to verify the legitimacy is still the same, that is, by using the public key to decrypt the Witness signature and verify whether the content of the transaction is consistent. The node will only request the Witness information when it needs to verify the legitimacy of the transaction. Now you can use the ZAN Node service for free (visit ZAN.TOP) to connect to the BTC network stably and at high speed.
In summary, Segregated Witness is to transmit the content of the transaction signature part and the rest of the content separately, thereby reducing the size of a single transaction and increasing the capacity of the entire block. In addition, since the content of the signature part is not counted when calculating the Hash value of the transaction, it can effectively solve the problem of transaction ductility.
This article was written by Yeezo (X account @GaoYeezo 75065 ) of ZAN Team (X account @zan_team).