Locking Script

Also: scriptPubKey, output script

cryptography · intermediate

The script attached to a transaction output that defines what data a future spender must provide to unlock the coins.

Every transaction [output](/glossary/output) carries a locking script — formally called scriptPubKey in Bitcoin Core. This script doesn't *encrypt* anything; it specifies the predicate that a future [unlocking script](/glossary/unlocking-script) must satisfy.

The most common shape, P2PKH (pay-to-public-key-hash):

``
OP_DUP OP_HASH160 <pubKeyHash> OP_EQUALVERIFY OP_CHECKSIG
``

Read aloud: "duplicate whatever is on top, hash it with HASH160, check that the result equals this specific public-key-hash, then verify a signature against the public key still on the stack."

Different output types use different locking scripts. P2SH (OP_HASH160 <scriptHash> OP_EQUAL) defers the real script until spend time — the spender provides the full redeem script that hashes to scriptHash. P2WPKH and P2WSH use a stripped-down "version-0 witness program" form; the bulk of validation happens against the witness rather than the legacy script. P2TR uses a 32-byte schnorr public key.

Block explorers usually show two forms of a locking script: the raw hex bytes and the decoded ASM (human-readable). The Script Playground in this section lets you watch the interpreter walk through one step by step.

Related terms

Where you'll see this