P2SH

Genx Avatar

P2SH, or Pay-to-Script-Hash, is a type of Bitcoin address that has been in use since 2012. It was introduced by Bitcoin Improvement Proposal (BIP) 16.

In simple terms, a P2SH address enables you to send bitcoins to an address that is secured in various unusual ways without knowing anything about the details of how the security is set up. All you need to send to an address is the corresponding hash of a script defining the conditions to be met in order for these bitcoins to be spent.

The key idea is that instead of having to provide the recipients’ Bitcoin address (as you would with a traditional Bitcoin transaction), you provide a script, or a set of locking conditions that need to be met for the recipient to spend the coins. These conditions are hashed and the result is a Bitcoin address, starting with a ‘3’ instead of a ‘1’.

One common use of P2SH is for multi-signature addresses, where a transaction requires signatures from multiple private keys to be spent. The P2SH address will encode the conditions that m of n keys must sign the transaction. For example, a 2-of-3 multi-signature P2SH address will require two out of three associated private keys to sign a transaction.

The main advantage of P2SH transactions is that they simplify transactions and improve privacy. By using a hash of the script rather than the script itself, the complexity of the transaction is hidden and only revealed at the time the output is spent. This simplifies the transaction process and saves space in the blockchain.