Locking Script

scriptPubKey

Locking Script

A locking script is a Script that you put on an output to prevent others from spending it.

Structure

You can use any combination of OP_CODES you want when creating a locking script, which allows you to lock up your outputs in different ways.

Examples

1. Pay To Pubkey

4104a9d6840fdd1497b3067b8066db783acf90bf42071a38fe2cf6d2d8a04835d0b5c45716d8d6012ab5d56c7824c39718f7bc7486d389cd0047f53785f9a63c0c9dac 04a9d6840fdd1497b3067b8066db783acf90bf42071a38fe2cf6d2d8a04835d0b5c45716d8d6012ab5d56c7824c39718f7bc7486d389cd0047f53785f9a63c0c9d OP_CHECKSIG
hex | opcodes

2. Pay To Pubkey Hash.

76a914fde0a08625e327ba400644ad62d5c571d2eec3de88ac OP_DUP OP_HASH160 fde0a08625e327ba400644ad62d5c571d2eec3de OP_EQUALVERIFY OP_CHECKSIG
hex | opcodes

Details This is the most common locking script. You can only unlock this if you have the private key that corresponds to the public key placed in to the script.

This is the default locking script used when you make a standard bitcoin transaction. In fact, this locking script is used so often you might think that various "locking scripts" weren't a thing.

3. Pay To Multisig

51210378ee11c3fb97054877a809ce083db292b16d971bcdc6aa4c8f92087133729d8b211283b5fbf5cc62d4399dfa1025c3e306295264494722c5085ceadadf1291f6812521a31752c9f17c628edc4c69c4c0846f8d814b21e046eabe06f9968a037ce0741c7453ae OP_1 0378ee11c3fb97054877a809ce083db292b16d971bcdc6aa4c8f92087133729d8b 1283b5fbf5cc62d4399dfa1025c3e306295264494722c5085ceadadf1291f68125 a31752c9f17c628edc4c69c4c0846f8d814b21e046eabe06f9968a037ce0741c74 OP_3 OP_CHECKMULTISIG
hex | opcodes

4. Pay To Script Hash.

a91410b0ed2d1698ff0f0ea151cf41988d05b728746a87 OP_HASH160 10b0ed2d1698ff0f0ea151cf41988d05b728746a OP_EQUAL
hex | opcodes

By Greg Walker,

Last Updated: May 25 2018
  • May 25 2018: glossary/scriptPubKey - updated title and script code styling
  • May 18 2018: browser/transaction/output - better highlighting of opcodes and data for: p2pk, p2pkh, p2ms, p2sh (incomplete)
  • May 18 2018: /glossary/p2pk - first draft
  • Apr 26 2018: Added link to Script page.
  • Mar 11 2018: Glossary | Public Key