bitcoin-script

scriptPubKey (“output script”)
pay2pubkey tx: OP_CHECKSIG
Pay2PubKeyHash Tx: OP_DUP OP_HASH160 OP_EQUALVERIFY OP_CHECKSIG
Pay2ScriptHash Tx: OP_HASH160 OP_EQUAL

When technical docs refer to the redeemScript, it is referring to the script in the ScriptSig (yet another poorly named element) of the input of a transactions. There is only a redeemScript when redeeming a P2SH.

scriptSig (“input script”)
Pay2PubKeyHash:
Pay2ScriptHash:

P2SH BIP16

scriptSig: [signature] {[pubkey] OP_CHECKSIG}
scriptPubKey: OP_HASH160 [20-byte-hash of {[pubkey] OP_CHECKSIG} ] OP_EQUAL

  1. [signature] and {[pubkey] OP_CHECKSIG} are pushed onto the stack
  2. OP_HASH160 hashes {[pubkey] OP_CHECKSIG}
  3. The same hash comes from the scriptPubKey onto the stack
  4. Consequently OP_EQUAL gives True
  5. The script is popped off the stack, leaving only [signature] on the stack.
  6. The deserialized script is added, leaving [signature] [pubkey] OP_CHECKSIG
  7. The transaction is validated again, that is, a normal signature verification occurs against the specified public key.

Provably Unspendable/Prunable Outputs

The standard way to mark a transaction as provably unspendable is with a scriptPubKey of the following form:

scriptPubKey: OP_RETURN {zero or more ops}

OP_RETURN tx
https://bchain.info/BTC/tx/1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc

txid 1a2e22a717d626fc5db363582007c46924ae6b28319f07cb1b907776bd8293fc
01000000015db413e8393e51026b492cb0547e5910afe81c72ea6008a357075a3ff1584075010000006a473044022055bcb36c829a614451787fe8c9bfb3798b683809b65b92037a015eccb5ff659702202461d2c708a4fd57c839e43634e8c02935d7b7d1db5b978432b0674c44645ed10121032c1ea520c25c4e66831cd395a3cd26f0e0a1472a3103fc8a4a63ef10e92d123cffffffff010000000000000000166a14215477656e74792062797465206469676573742e00000000

“!Twenty byte digest.”

Freezing funds until a time in the future

Using OP_CHECKLOCKTIMEVERIFY it is possible to make funds provably unspendable until a certain point in the future.

scriptPubKey: <expiry time> OP_CHECKLOCKTIMEVERIFY OP_DROP OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
scriptSig: <sig> <pubKey>