How P2SH Works

As a refresher, here’s how everything works in Pay to Pub Key Hash.

If Bob wants to receive bitcoin from Alice, Alice has to have access to Bob’s public key hash.

She can then send a transaction paying to Bob’s public key hash.

In order for Bob to redeem the bitcoin that Alice just sent him, he must provide a signature and full public key, proving his identity and allowing him to spend from this transaction output.

Now let’s say that Bob wants to introduce some more functionality into his transaction with Alice.

Say he wants to use multisig or a time-lock — two types of scripts that we’ll introduce later.

Instead of providing Alice a public key hash, Bob first creates a script, takes the hash of it, and sends it off to Alice.

Alice can then send a transaction paying to Bob’s script hash.

In order for Bob to redeem the bitcoin that Alice just sent him, he must provide a signature and the full script that he had written.

Why use P2SH?