Bare OP_TRUE Scripts (Anyone Can Spend)
13. Bare OP_TRUE Scripts (Anyone Can Spend)
Overview
A bare OP_TRUE (or equivalent OP_1) script creates a UTXO that anyone can spend with an empty unlocking script. These are also called "anyone-can-spend" outputs. They have legitimate uses in protocol design (ephemeral anchors, test environments) but also represent a dust-attack vector and a philosophical oddity in a system designed for ownership.
Script Construction
Locking script:
OP_TRUE
Which is simply the single byte:
51 <- OP_1 (pushes the number 1 onto the stack)
Or equivalently:
OP_1 <- same opcode
Unlocking script:
(empty)
Execution
Stack before: []
Execute OP_TRUE (OP_1):
Stack after: [1]
Non-zero, non-empty top element → VALID
Any node that sees this UTXO in the UTXO set can construct a spending transaction with an empty scriptSig and claim the funds. However:
Important: OP_TRUE scripts are NON-STANDARD
- Most nodes will not relay transactions creating OP_TRUE outputs
- Must be included directly by a miner
- Once on-chain, any node will RELAY the spending transaction
(spending a non-standard output is standard if the spending tx is standard)
Lightning Network Anchor Outputs
The Lightning Network's anchor output design (BOLT 3) uses a constrained form of anyone-can-spend:
Anchor output script (BOLT 3):
<local_funding_pubkey> OP_CHECKSIG
OP_IFDUP
OP_NOTIF
OP_16 OP_CHECKSEQUENCEVERIFY
OP_ENDIF
This allows:
- Immediate spend by the channel party (with their key)
- Spend by anyone after 16 blocks (to prevent UTXO bloat)
The "ephemeral anchor" proposal (BIP 330 / CPFP carve-out) defines a OP_TRUE output explicitly for fee bumping:
Proposed ephemeral anchor script:
OP_TRUE (1 byte output, 0 satoshis)
Purpose: Allows either channel party (or any third party)
to attach a child transaction for CPFP fee bumping.
Security Implications
Real-world race conditions:
- Once a OP_TRUE UTXO is confirmed, bots actively monitor the mempool
- Any spending transaction you broadcast is visible to all mempool participants
- A front-running bot can submit the same inputs with higher fees → takes funds
- This is not theoretical: "mempool sniping" bots operate continuously
Practical use cases where this is intentional:
- Dust outputs for testing
- Protocol anchors meant to be swept by infrastructure
- Mining fee donations (though OP_RETURN is cleaner for this)
- Puzzle outputs with no expected real value
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: