What is a Bitcoin Pay-to-Script-Hash (P2SH)?

Started by xonasa, Jun 03, 2024, 06:36 AM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

xonasa

What is a Bitcoin Pay-to-Script-Hash (P2SH)?

SEO

Bitcoin Pay-to-Script-Hash (P2SH) is a type of transaction output script used in the Bitcoin protocol to enable the spending of bitcoins. It allows users to create more complex and flexible spending conditions, often referred to as "smart contracts," by using custom scripts without revealing the script details on the blockchain. P2SH was introduced to the Bitcoin protocol in 2012.

Here's how P2SH transactions work:

1. **Redeem Script**: A redeem script is a custom script that specifies the spending conditions for the bitcoins locked in a P2SH address. It can contain various conditions, such as multi-signature requirements, time locks, or other custom conditions.

2. **Script Hash**: The redeem script is hashed to generate a unique script hash, which is used as the identifier for the spending conditions. This hash is known as the Script Hash (SH).

3. **Transaction Output**: A P2SH transaction output contains the Script Hash (SH) as the locking condition, indicating that the bitcoins can only be spent if the spending transaction provides the corresponding redeem script that matches the script hash.

4. **Redeem Script and Signatures**: When spending bitcoins from a P2SH output, the spending transaction must include the redeem script and any additional data required to satisfy the spending conditions specified in the redeem script. This typically includes signatures from the authorized parties if the script requires them.

P2SH transactions offer several benefits over traditional Pay-to-Public-Key-Hash (P2PKH) transactions:

- **Flexibility**: P2SH allows users to create more complex spending conditions using custom scripts, enabling a wide range of use cases, including multi-signature wallets, escrow services, and time-locked transactions.

- **Privacy**: P2SH transactions do not reveal the details of the redeem script on the blockchain, providing privacy for the script logic and spending conditions.

- **Reduced Transaction Sizes**: P2SH transactions can be more space-efficient compared to embedding the entire script directly in the transaction, as only the script hash is included in the transaction output, resulting in smaller transaction sizes and lower fees.

P2SH has become a widely used feature in the Bitcoin ecosystem, enabling advanced scripting capabilities and supporting the development of innovative applications and services built on top of the Bitcoin protocol.

Didn't find what you were looking for? Search Below