Pushes, arithmetic, and control flow
Terms used in this lesson
- OP_IF
- A Bitcoin Script conditional operation that executes one branch when the consumed condition is true.
- OP_VERIFY
- A Bitcoin Script operation that consumes a value and immediately fails if it is false.
- Witness
- Signatures, scripts, or other data supplied to satisfy a Bitcoin output’s spending condition.
- OP_ELSE
- The marker for the alternate branch of a Bitcoin Script conditional.
- OP_ENDIF
- The marker that ends a Bitcoin Script conditional block.
- OP_SUB
- A Bitcoin Script operation that removes two script numbers and pushes the first minus the second.
- OP_EQUALVERIFY
- A Bitcoin Script operation that compares two values and immediately fails if they differ.
- OP_EQUAL
- A Bitcoin Script operation that compares two byte strings and pushes true or false.
- UTXO
- Unspent transaction output: one discrete chunk of bitcoin that can be used as a transaction input.
Data pushes, numeric encodings, conditionals, and verification opcodes compose spending policies.
Loading lesson visuals...
Learn the idea
Script data pushes place byte strings on the stack. Script numbers use a signed-magnitude little-endian byte encoding with minimal-encoding rules in relevant contexts. Conditional opcodes OP_IF, OP_ELSE, and OP_ENDIF choose which branch executes based on a stack boolean, while skipped branches are parsed but most contained operations are not executed.
Push minimally encoded numbers
Small integer opcodes directly push values from negative one through sixteen. Larger script numbers are byte vectors whose sign uses the high bit of the final byte.
Inspect every idea above to open it.
It consumes a stack item supplied or computed during this spend. Script has no mutable variable store attached to an output.
The questions unlock after every required learning activity
Inspect every guided idea, open the worked example, rebuild its mechanism, and complete the deterministic lesson tool. Your progress is saved automatically.