TeachMeBitcoin

How Bitcoin Outputs Work (Locking Scripts)

From TeachMeBitcoin, the free encyclopedia Reading time: 3 min

How Bitcoin Outputs Work (Locking Scripts)

While transaction inputs represent the past (destroying existing UTXOs), Outputs represent the future. An output creates a new unspent transaction output (UTXO) that sits in the global ledger waiting to be spent by its future owner.

An output is a combination of a currency value and a cryptographic lock.


️ The 2 Fields of a Transaction Output

A transaction output consists of exactly two fields serialized into binary:

Field Name Size (Bytes) Description
Value 8 The amount of satoshis being sent to this output.
scriptPubKey (Locking Script) Variable The cryptographic code that defines what conditions must be met to spend this output.
┌────────────────────────────────────────────────────────┐
│ TRANSACTION OUTPUT │
├───────────────────────────────┬────────────────────────┤
│ Value (8-Byte Uint64 satoshis)│ scriptPubKey │
│ (8 Bytes) │ (Variable) │
└───────────────────────────────┴────────────────────────┘

Understanding the Output Fields

1. The Value Field (8 Bytes)

Bitcoin's software is built entirely around integer math. There are no decimals in raw Bitcoin transactions.

2. scriptPubKey (Locking Script)

The scriptPubKey is the lock. It is a sequence of operation codes (Opcodes) written in Bitcoin’s programming language, Script.


Common Types of scriptPubKey Locking Scripts

The Bitcoin protocol supports several standardized locking script patterns:

1. P2PKH (Pay-to-Public-Key-Hash) — Legacy

This is the standard legacy address pattern (addresses starting with 1).

2. P2SH (Pay-to-Script-Hash) — Multisig / Escrows

Introduced in 2012 (addresses starting with 3), P2SH shifts the burden of complex scripts from the sender to the receiver.

3. P2WPKH (Pay-to-Witness-Public-Key-Hash) — Native SegWit

The standard modern SegWit address format (Bech32 addresses starting with bc1q).

4. OP_RETURN — The Null Data Output

OP_RETURN is a special output used to record arbitrary data on the blockchain.

☕ Help support TeachMeBitcoin

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:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!