Web3 Beginner Series: Why Does My Bitcoin Wallet Have Multiple Addresses?

Beginner7/17/2024, 11:20:32 AM
The Bitcoin community is continuously evolving with technological advancements, leading to new features. Different address formats are one such result of these advancements. This article explains why there are multiple address types in Web3 Bitcoin wallets and what each type is used for.

Many beginners, myself included, have been excited to open their Bitcoin wallet using a WEB3 wallet for the first time. When we get ready to copy an address, we suddenly discover that the wallet we created has multiple different addresses. It’s like standing at an unfamiliar intersection, feeling completely confused. Why are there different addresses? Which one should you use?

Multiple Bitcoin Addresses in OKX Wallet

What are these addresses?

The Bitcoin community is always evolving with new technological advancements. These advancements often result in new features, such as different address formats. Let’s explore what these different address formats are and what makes them unique.

Legacy address (P2PKH)

This format was used when Bitcoin was first launched in 2009, so it is called Legacy format. Because the Bitcoin address at that time was created from a public/private key pair, it is also called Payment Public Key Hash (P2PKH). ) address.

At present, it seems that legacy type addresses will take up more space in transactions, resulting in higher transaction fees. Currently, people will only use this type of address when using some old wallets that are incompatible with the new address.

It can be found that Legacy addresses have a characteristic, the addresses all start with “1”. This is because when generating an address, a prefix will be added in front of the generated public key according to different scenarios (such as testnet/mainnet). After the public key with the prefix added is calculated through Hash, the address will eventually start with “1”.

Nested SegWit address (P2SH-P2WPKH)

Compared with traditional Legacy addresses, P2SH addresses do not use the hash of the public key, but the hash of the redemption script (redeem-script). In layman’s terms, P2PKH pays to the hash of a public key, while P2SH pays to the redemption script. Only after the recipient meets the transfer conditions of the redemption script can the funds inside 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 P2SH, if Segregated Witness technology is embedded, then the format of this address is Segregated Witness compatible address (Nested SegWit). You can learn more about Segregated Witness when introducing the Segregated Witness address. After the introduction of Segregated Witness technology, the volume of transactions can be reduced, thereby reducing transaction fees.

You can see that the P2SH address starts with “3”.

Segregated Witness Address (Native SegWit) Address

Before introducing this type of address, we need to introduce the key technology inside it - Segregated Witness (SegWit). As the name suggests, Segregated Witness isolates the witness data (witness) and processes 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 “bc1”.

Taproot address (Taproot)

The advantages of Taproot addresses are privacy and efficiency in complex transaction scenarios. Compared with Native SegWit, it uses the Schnorr algorithm to replace the elliptic curve digital signature algorithm. The former is more efficient in batch transaction scenarios and improves the privacy of multi-signature wallets.

The main root address is characterized by the address generally starting with “bc1q”.

Which Bitcoin Address Format Should I Choose?

Mainstream wallets like OKX and Unisat support all four types of Bitcoin addresses. To reduce transaction fees, it’s best to use addresses in the Native SegWit or Taproot formats.

If you’re interested in Bitcoin inscriptions, these two address types are ideal. Most wallets handle inscriptions on these addresses specifically, ensuring your special UTXOs are not mistakenly transferred. Look for wallet addresses that start with “bc1”!

Don’t worry about compatibility—wallets with different address formats can still transact with each other.

For checking your Bitcoin balance or block information, you can use ZAN’s node service. They offer a comprehensive API for developers. For more details, check out the API documentation: https://docs.zan.top/reference/zan_getbalance-enhance.

A Deeper Dive - Key Technologies Explained

After the initial overview, you should now have a basic understanding of Bitcoin wallets. For those who, like me, are fascinated by the underlying technologies, let’s explore some of the key technical aspects.

Redeem Script

When we discussed P2SH (Pay-to-Script-Hash), we mentioned it’s a technology used for redeem script transactions. But what exactly is a redeem script, and what role does it play in the Bitcoin ecosystem? Before diving into redeem scripts, let’s look at the basic structure of Bitcoin transactions. Here’s an example of a typical P2PK (Pay-to-Public-Key) transaction. Suppose an address starting with 04ae wants to send 10 BTC to an address starting with 15kD. The owner of the 04ae address must prove to the network that they have the right to use this address (i.e., they own the private key). To do this, they need to provide a signature (ScriptSig) within the transaction to verify their identity. The verifier not only needs to obtain this signature but also needs to locate the output script from the previous transaction associated with the UTXO. These two scripts together form what is known as the redeem script. The role of the redeem script is to prove the transaction’s validity.

In this transaction, you can see that the signature and output script are both computer instructions.OP_PUSHBYTES Indicates PUSHing a piece of data into the stack. First, 04ae signs the entire transaction with its own private key in ScriptSig, and the signature will be pushed onto the stack. Then push the public key into the stack, and finally at .OP_CHECKSIG , use the public key to decrypt the signature and compare whether the transaction is consistent. If they are consistent, the identity is valid.

In addition to this P2PK method, the redemption script can also implement different authentication methods such as P2PKH and P2SH.

Segregated Witness

From the above introduction, we can know that the newer wallet formats currently use Segregated Witness technology, so what is Witness and how is it isolated?

The Witness here can be thought of as the script signature (scriptSig) information in the basic structure of Bitcoin. Segregated Witness extracts it from the basic structure and puts it in a new data structure.

As you can see in the figure above, the only necessary content in the transaction is the transaction source information and transaction output information. The size of the transaction is reduced. Since the yellow part (total size of the transaction) has a size limit, the transaction will be Transmitting signatures separately allowing one block to accommodate more transactions. In addition, when calculating the signature of a transaction, the content of the signature part is not included, so the problem of transaction malleability can be effectively solved.

Below is a P2TR 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 method of verifying legitimacy is still the same, that is, by using the public key to decrypt the signature of Witness to verify whether the content of the transaction is consistent. Nodes will request Witness information only when they need to verify the legitimacy of the transaction.

In summary, Segregated Witness (SegWit) improves Bitcoin transactions by separating the transaction signatures from the rest of the transaction data. This separation reduces the size of each transaction, allowing more transactions to fit into a single block, thus increasing the block’s overall capacity. Moreover, by excluding the signature data from the transaction hash calculation, SegWit effectively addresses the problem of transaction malleability.

Disclaimer:

  1. This article is reprinted from[ZAN Team], All copyrights belong to the original author [ZAN Team]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
  2. Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
  3. Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.

Web3 Beginner Series: Why Does My Bitcoin Wallet Have Multiple Addresses?

Beginner7/17/2024, 11:20:32 AM
The Bitcoin community is continuously evolving with technological advancements, leading to new features. Different address formats are one such result of these advancements. This article explains why there are multiple address types in Web3 Bitcoin wallets and what each type is used for.

Many beginners, myself included, have been excited to open their Bitcoin wallet using a WEB3 wallet for the first time. When we get ready to copy an address, we suddenly discover that the wallet we created has multiple different addresses. It’s like standing at an unfamiliar intersection, feeling completely confused. Why are there different addresses? Which one should you use?

Multiple Bitcoin Addresses in OKX Wallet

What are these addresses?

The Bitcoin community is always evolving with new technological advancements. These advancements often result in new features, such as different address formats. Let’s explore what these different address formats are and what makes them unique.

Legacy address (P2PKH)

This format was used when Bitcoin was first launched in 2009, so it is called Legacy format. Because the Bitcoin address at that time was created from a public/private key pair, it is also called Payment Public Key Hash (P2PKH). ) address.

At present, it seems that legacy type addresses will take up more space in transactions, resulting in higher transaction fees. Currently, people will only use this type of address when using some old wallets that are incompatible with the new address.

It can be found that Legacy addresses have a characteristic, the addresses all start with “1”. This is because when generating an address, a prefix will be added in front of the generated public key according to different scenarios (such as testnet/mainnet). After the public key with the prefix added is calculated through Hash, the address will eventually start with “1”.

Nested SegWit address (P2SH-P2WPKH)

Compared with traditional Legacy addresses, P2SH addresses do not use the hash of the public key, but the hash of the redemption script (redeem-script). In layman’s terms, P2PKH pays to the hash of a public key, while P2SH pays to the redemption script. Only after the recipient meets the transfer conditions of the redemption script can the funds inside 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 P2SH, if Segregated Witness technology is embedded, then the format of this address is Segregated Witness compatible address (Nested SegWit). You can learn more about Segregated Witness when introducing the Segregated Witness address. After the introduction of Segregated Witness technology, the volume of transactions can be reduced, thereby reducing transaction fees.

You can see that the P2SH address starts with “3”.

Segregated Witness Address (Native SegWit) Address

Before introducing this type of address, we need to introduce the key technology inside it - Segregated Witness (SegWit). As the name suggests, Segregated Witness isolates the witness data (witness) and processes 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 “bc1”.

Taproot address (Taproot)

The advantages of Taproot addresses are privacy and efficiency in complex transaction scenarios. Compared with Native SegWit, it uses the Schnorr algorithm to replace the elliptic curve digital signature algorithm. The former is more efficient in batch transaction scenarios and improves the privacy of multi-signature wallets.

The main root address is characterized by the address generally starting with “bc1q”.

Which Bitcoin Address Format Should I Choose?

Mainstream wallets like OKX and Unisat support all four types of Bitcoin addresses. To reduce transaction fees, it’s best to use addresses in the Native SegWit or Taproot formats.

If you’re interested in Bitcoin inscriptions, these two address types are ideal. Most wallets handle inscriptions on these addresses specifically, ensuring your special UTXOs are not mistakenly transferred. Look for wallet addresses that start with “bc1”!

Don’t worry about compatibility—wallets with different address formats can still transact with each other.

For checking your Bitcoin balance or block information, you can use ZAN’s node service. They offer a comprehensive API for developers. For more details, check out the API documentation: https://docs.zan.top/reference/zan_getbalance-enhance.

A Deeper Dive - Key Technologies Explained

After the initial overview, you should now have a basic understanding of Bitcoin wallets. For those who, like me, are fascinated by the underlying technologies, let’s explore some of the key technical aspects.

Redeem Script

When we discussed P2SH (Pay-to-Script-Hash), we mentioned it’s a technology used for redeem script transactions. But what exactly is a redeem script, and what role does it play in the Bitcoin ecosystem? Before diving into redeem scripts, let’s look at the basic structure of Bitcoin transactions. Here’s an example of a typical P2PK (Pay-to-Public-Key) transaction. Suppose an address starting with 04ae wants to send 10 BTC to an address starting with 15kD. The owner of the 04ae address must prove to the network that they have the right to use this address (i.e., they own the private key). To do this, they need to provide a signature (ScriptSig) within the transaction to verify their identity. The verifier not only needs to obtain this signature but also needs to locate the output script from the previous transaction associated with the UTXO. These two scripts together form what is known as the redeem script. The role of the redeem script is to prove the transaction’s validity.

In this transaction, you can see that the signature and output script are both computer instructions.OP_PUSHBYTES Indicates PUSHing a piece of data into the stack. First, 04ae signs the entire transaction with its own private key in ScriptSig, and the signature will be pushed onto the stack. Then push the public key into the stack, and finally at .OP_CHECKSIG , use the public key to decrypt the signature and compare whether the transaction is consistent. If they are consistent, the identity is valid.

In addition to this P2PK method, the redemption script can also implement different authentication methods such as P2PKH and P2SH.

Segregated Witness

From the above introduction, we can know that the newer wallet formats currently use Segregated Witness technology, so what is Witness and how is it isolated?

The Witness here can be thought of as the script signature (scriptSig) information in the basic structure of Bitcoin. Segregated Witness extracts it from the basic structure and puts it in a new data structure.

As you can see in the figure above, the only necessary content in the transaction is the transaction source information and transaction output information. The size of the transaction is reduced. Since the yellow part (total size of the transaction) has a size limit, the transaction will be Transmitting signatures separately allowing one block to accommodate more transactions. In addition, when calculating the signature of a transaction, the content of the signature part is not included, so the problem of transaction malleability can be effectively solved.

Below is a P2TR 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 method of verifying legitimacy is still the same, that is, by using the public key to decrypt the signature of Witness to verify whether the content of the transaction is consistent. Nodes will request Witness information only when they need to verify the legitimacy of the transaction.

In summary, Segregated Witness (SegWit) improves Bitcoin transactions by separating the transaction signatures from the rest of the transaction data. This separation reduces the size of each transaction, allowing more transactions to fit into a single block, thus increasing the block’s overall capacity. Moreover, by excluding the signature data from the transaction hash calculation, SegWit effectively addresses the problem of transaction malleability.

Disclaimer:

  1. This article is reprinted from[ZAN Team], All copyrights belong to the original author [ZAN Team]. If there are objections to this reprint, please contact the Gate Learn team, and they will handle it promptly.
  2. Liability Disclaimer: The views and opinions expressed in this article are solely those of the author and do not constitute any investment advice.
  3. Translations of the article into other languages are done by the Gate Learn team. Unless mentioned, copying, distributing, or plagiarizing the translated articles is prohibited.
Start Now
Sign up and get a
$100
Voucher!