Unlocking Script Overview
The Unlocking Script (ScriptSig)
In the Bitcoin protocol, every Transaction Input must provide a proof of ownership to spend the referenced coins. This proof is contained in a field called ScriptSig.
1. The Purpose of ScriptSig
ScriptSig is known as the "Unlocking Script." Its job is to provide data that satisfies the mathematical puzzle (the ScriptPubKey) placed on the coins by the previous owner.
2. A Two-Part Puzzle
To spend bitcoin, two scripts are combined and executed by the network's nodes:
-
ScriptPubKey (The Lock): Stored in the previous transaction's output. It says: "To spend these coins, you must provide a signature from the owner of Address X."
-
ScriptSig (The Key): Provided in your new transaction's input. It contains your signature and public key.
If the "Key" fits the "Lock," the transaction is valid.
3. Data Pushes
Technically, ScriptSig is a sequence of data pushes. It doesn't usually contain "logic" or "operators" (like OP_CHECKSIG). Instead, it pushes the necessary credentials onto the execution stack.
-
Data Push 1: The Digital Signature.
-
Data Push 2: The Public Key.
4. The Stack Concept
Bitcoin uses a stack-based execution model (Last-In, First-Out).
-
The data in ScriptSig is pushed onto the stack first.
-
Then, the operators in ScriptPubKey are executed using that data.
| Property | Value |
|---|---|
| Role | Unlocking Script |
| Location | Transaction Input |
| Contents | Signature, Public Key, or Script |
| Nickname | The Key |
In the next section, we will deconstruct the Components found inside a standard ScriptSig.
TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation: