Market Cap: $3.2872T 0.380%
Volume(24h): $81.5121B -1.040%
Fear & Greed Index:

50 - Neutral

  • Market Cap: $3.2872T 0.380%
  • Volume(24h): $81.5121B -1.040%
  • Fear & Greed Index:
  • Market Cap: $3.2872T 0.380%
Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos
Top Cryptospedia

Select Language

Select Language

Select Currency

Cryptos
Topics
Cryptospedia
News
CryptosTopics
Videos

What is the difference between P2PKH and P2SH for wallet addresses?

P2PKH addresses start with "1" and require a public key and signature to spend funds, while P2SH addresses begin with "3" and allow complex spending conditions like multisignature setups.

Jun 15, 2025 at 03:35 pm

Understanding P2PKH and P2SH in Bitcoin Transactions

When interacting with Bitcoin wallets, users often encounter different types of addresses. Two of the most common are P2PKH (Pay-to-Public-Key-Hash) and P2SH (Pay-to-Script-Hash). These terms refer to the underlying transaction scripts that dictate how funds can be spent. Understanding their differences is essential for anyone working with Bitcoin transactions, especially developers, wallet providers, and advanced users.


What Is P2PKH?

P2PKH (Pay-to-Public-Key-Hash) is the original and most basic type of Bitcoin address. It starts with the number "1" and was introduced in the early versions of Bitcoin. When sending funds to a P2PKH address, the sender specifies that the recipient must provide both a valid public key and a digital signature matching the hash embedded in the script.

To break it down:

  • The recipient's public key is hashed twice—first with SHA-256, then with RIPEMD-160—to create a shorter, secure identifier.
  • This hash is encoded using Base58Check to produce the familiar "1..." format.
  • When spending from a P2PKH output, the user must reveal their public key and provide a signature proving ownership.

This method ensures simplicity and widespread compatibility across older systems.


What Is P2SH?

P2SH (Pay-to-Script-Hash) introduces more flexibility into Bitcoin transactions. Introduced via BIP 16, this type of address typically starts with "3". Instead of locking funds to a public key hash, P2SH locks them to the hash of a script. This means that the actual conditions required to spend the coins are hidden until redemption time.

Here’s how it works:

  • A complex script is created by the recipient or wallet provider. This could include multisignature logic, timelocks, or other custom conditions.
  • The hash of this script is encoded into a P2SH address.
  • When someone sends funds to this address, they only know the hash—not the full details of the redemption conditions.
  • Upon spending, the redeemer provides both the original script and any data required to satisfy its conditions (like multiple signatures).

This model enhances privacy and allows for advanced smart contract-like features on Bitcoin without exposing complexity upfront.


Key Differences Between P2PKH and P2SH

While both P2PKH and P2SH are used to send and receive Bitcoin, they differ significantly in structure and use cases:

  • Address Format:

    • P2PKH addresses start with “1” due to version byte encoding.
    • P2SH addresses begin with “3”.
  • Redemption Logic:

    • In P2PKH, the spender reveals the public key and signature during redemption.
    • In P2SH, the spender reveals the original script and data satisfying its conditions at the time of spending.
  • Complexity and Flexibility:

    • P2PKH supports only simple single-signature transactions.
    • P2SH enables complex conditions like multisig, m-of-n thresholds, and custom logic.
  • Privacy and On-chain Footprint:

    • P2PKH exposes public keys immediately upon spending.
    • P2SH hides the full script until redemption, reducing on-chain visibility of complex logic.

These distinctions make each suitable for different scenarios, such as everyday transactions versus collaborative fund management.


How Are These Addresses Generated?

Creating P2PKH and P2SH addresses involves cryptographic operations and encoding steps. Below is a simplified breakdown:

For P2PKH Address Generation:

  • Generate a private key using ECDSA.
  • Derive the corresponding public key.
  • Apply SHA-256 followed by RIPEMD-160 to obtain the public key hash.
  • Prepend the network byte (e.g., 0x00 for mainnet).
  • Perform double SHA-256 checksum and append first 4 bytes.
  • Encode the result using Base58Check to get the final address.

For P2SH Address Generation:

  • Create a redeem script (e.g., multisig).
  • Hash the script with SHA-256 and RIPEMD-160.
  • Add the P2SH version byte (e.g., 0x05 for mainnet).
  • Compute the double SHA-256 checksum.
  • Use Base58Check encoding to form the final address.

Each step plays a crucial role in ensuring security and interoperability within the Bitcoin ecosystem.


Use Cases for Each Type

The choice between P2PKH and P2SH depends heavily on the intended use case:

  • P2PKH is ideal for straightforward peer-to-peer transactions where simplicity and wide support are priorities. Most early wallets and exchanges default to P2PKH addresses.

  • P2SH shines in environments requiring additional security layers or cooperative control. Common applications include:

    • Multisignature wallets where multiple parties must approve a transaction.
    • Escrow services where funds are released after certain conditions are met.
    • Time-locked contracts that delay fund availability until a future block height or timestamp.

By abstracting complex logic behind a hash, P2SH improves usability while maintaining the integrity of Bitcoin’s scripting system.


Frequently Asked Questions

Q: Can I convert a P2PKH address to a P2SH address?

No, you cannot directly convert one type of address to another. However, you can create a new P2SH address using a custom script and transfer funds from your P2PKH address to it.

Q: Which address type offers better privacy?
P2SH generally offers better privacy because the underlying script logic remains hidden until the transaction is spent. In contrast, P2PKH exposes the public key when funds are moved.

Q: Are P2SH addresses compatible with all Bitcoin wallets?

Most modern wallets support P2SH addresses, especially those implementing BIP 16. However, some legacy systems may not recognize them or require manual configuration.

Q: Why do P2SH addresses start with "3"?

This is due to the version byte used during encoding. For P2SH addresses on the Bitcoin mainnet, the version byte is set to 0x05, which results in the "3" prefix when encoded with Base58Check.

Disclaimer:info@kdj.com

The information provided is not trading advice. kdj.com does not assume any responsibility for any investments made based on the information provided in this article. Cryptocurrencies are highly volatile and it is highly recommended that you invest with caution after thorough research!

If you believe that the content used on this website infringes your copyright, please contact us immediately (info@kdj.com) and we will delete it promptly.

Related knowledge

How do I transfer XRP to my Coinbase wallet?

How do I transfer XRP to my Coinbase wallet?

Jun 16,2025 at 04:57pm

Understanding the Basics of XRP and Coinbase CompatibilityBefore initiating any transfer, it’s essential to confirm whether Coinbase supports XRP. As of recent updates, Coinbase has resumed offering XRP trading services on its platform after a period of uncertainty due to legal issues involving Ripple Labs. However, availability may vary depending on yo...

How do I deposit BNB into my Trust Wallet?

How do I deposit BNB into my Trust Wallet?

Jun 15,2025 at 03:56pm

Understanding BNB and Trust Wallet CompatibilityBefore initiating a deposit, it’s crucial to understand what BNB is and how it interacts with Trust Wallet. BNB (Binance Coin) is a utility token created by the Binance exchange. It can be used for paying transaction fees, participating in token sales, and more. Trust Wallet, on the other hand, is a mobile...

How do I send USDT to my Ledger Nano X?

How do I send USDT to my Ledger Nano X?

Jun 15,2025 at 06:28am

What is USDT and Why Use Ledger Nano X?USDT, also known as Tether, is one of the most widely used stablecoins in the cryptocurrency ecosystem. It operates on various blockchain networks such as Ethereum (ERC-20), Tron (TRC-20), and others, offering users a digital asset pegged 1:1 to the US dollar. When it comes to storing USDT securely, hardware wallet...

How do I deposit Bitcoin into my Trezor hardware wallet?

How do I deposit Bitcoin into my Trezor hardware wallet?

Jun 14,2025 at 12:29pm

What is a Trezor Hardware Wallet?A Trezor hardware wallet is a secure device designed to store cryptocurrencies offline, protecting them from online threats. Unlike software wallets, which are vulnerable to hacking and malware, Trezor stores private keys on the physical device itself. This ensures that transactions can only be approved by physically int...

How to set the transaction limit of a wallet address?

How to set the transaction limit of a wallet address?

Jun 16,2025 at 04:08am

Understanding the Concept of Transaction Limits in Cryptocurrency WalletsIn the cryptocurrency ecosystem, transaction limits refer to predefined restrictions placed on the amount of digital assets that can be sent or received by a wallet address within a specified timeframe. These limits are typically enforced by platforms such as exchanges, custodial w...

How is the Gas fee of a wallet address calculated?

How is the Gas fee of a wallet address calculated?

Jun 14,2025 at 07:57pm

Understanding the Basics of Gas Fees in Blockchain TransactionsIn the cryptocurrency ecosystem, particularly within Ethereum-based networks, a Gas fee is an essential component of executing transactions or smart contract operations. The Gas fee serves as compensation for miners or validators who process and confirm transactions on the blockchain. It is ...

How do I transfer XRP to my Coinbase wallet?

How do I transfer XRP to my Coinbase wallet?

Jun 16,2025 at 04:57pm

Understanding the Basics of XRP and Coinbase CompatibilityBefore initiating any transfer, it’s essential to confirm whether Coinbase supports XRP. As of recent updates, Coinbase has resumed offering XRP trading services on its platform after a period of uncertainty due to legal issues involving Ripple Labs. However, availability may vary depending on yo...

How do I deposit BNB into my Trust Wallet?

How do I deposit BNB into my Trust Wallet?

Jun 15,2025 at 03:56pm

Understanding BNB and Trust Wallet CompatibilityBefore initiating a deposit, it’s crucial to understand what BNB is and how it interacts with Trust Wallet. BNB (Binance Coin) is a utility token created by the Binance exchange. It can be used for paying transaction fees, participating in token sales, and more. Trust Wallet, on the other hand, is a mobile...

How do I send USDT to my Ledger Nano X?

How do I send USDT to my Ledger Nano X?

Jun 15,2025 at 06:28am

What is USDT and Why Use Ledger Nano X?USDT, also known as Tether, is one of the most widely used stablecoins in the cryptocurrency ecosystem. It operates on various blockchain networks such as Ethereum (ERC-20), Tron (TRC-20), and others, offering users a digital asset pegged 1:1 to the US dollar. When it comes to storing USDT securely, hardware wallet...

How do I deposit Bitcoin into my Trezor hardware wallet?

How do I deposit Bitcoin into my Trezor hardware wallet?

Jun 14,2025 at 12:29pm

What is a Trezor Hardware Wallet?A Trezor hardware wallet is a secure device designed to store cryptocurrencies offline, protecting them from online threats. Unlike software wallets, which are vulnerable to hacking and malware, Trezor stores private keys on the physical device itself. This ensures that transactions can only be approved by physically int...

How to set the transaction limit of a wallet address?

How to set the transaction limit of a wallet address?

Jun 16,2025 at 04:08am

Understanding the Concept of Transaction Limits in Cryptocurrency WalletsIn the cryptocurrency ecosystem, transaction limits refer to predefined restrictions placed on the amount of digital assets that can be sent or received by a wallet address within a specified timeframe. These limits are typically enforced by platforms such as exchanges, custodial w...

How is the Gas fee of a wallet address calculated?

How is the Gas fee of a wallet address calculated?

Jun 14,2025 at 07:57pm

Understanding the Basics of Gas Fees in Blockchain TransactionsIn the cryptocurrency ecosystem, particularly within Ethereum-based networks, a Gas fee is an essential component of executing transactions or smart contract operations. The Gas fee serves as compensation for miners or validators who process and confirm transactions on the blockchain. It is ...

See all articles

User not found or password invalid

Your input is correct