Definition
Pay-to-Script-Hash, or P2SH, is a Bitcoin output type defined in BIP 16 that locks coins to the hash of a script rather than to the script itself. The full script — called the redeem script — is revealed only when the funds are spent. P2SH was activated as a soft fork on 1 April 2012 and uses addresses that begin with the digit 3.
How P2SH works
A P2SH locking script is compact and fixed-length: OP_HASH160, a 20-byte script hash, and OP_EQUAL. To spend, the redeemer provides, in the unlocking script, the data needed to satisfy the redeem script followed by the serialized redeem script itself. Validation runs in two phases: the network first confirms the supplied redeem script hashes to the committed 20-byte value, then executes that redeem script against the remaining stack items to verify the spend.
Why it was a breakthrough
Before P2SH, a sender wanting to pay into a complex contract (such as multisignature) had to embed the entire script in their output and pay for its size. P2SH moves that burden to the redeemer: the sender only needs a short hash, so paying into a 3-of-5 multisig is as simple as paying to a normal address. This made multisignature, timelocked vaults, and other custom scripts practical for everyday wallets, and the same wrapping pattern later enabled backward-compatible “nested SegWit” addresses.
The redeem script revealed at spend time is evaluated on the ordinary Script Stack, and frequently contains timelock opcodes such as OP_CHECKLOCKTIMEVERIFY (CLTV) to build refundable contracts.
In Simple Terms
Pay-to-Script-Hash, or P2SH, is a Bitcoin output type defined in BIP 16 that locks coins to the hash of a script rather than to the…
