Overview
Tapscript (BIP342) defines the scripting rules used within Taproot script-path spends. While building on the foundation of Bitcoin Script, Tapscript introduces important modifications that improve flexibility, efficiency, and future upgradeability. It applies exclusively to scripts executed via the script-path of a P2TR output.
Key Changes from Legacy Script
Tapscript makes several notable modifications to the scripting system:
- Schnorr-based signature validation: Replaces
OP_CHECKSIGandOP_CHECKMULTISIGsemantics with Schnorr-based equivalents. The newOP_CHECKSIGADDopcode replacesOP_CHECKMULTISIGwith a more efficient batch-verifiable design. - Signature size: All Schnorr signatures in Tapscript are exactly 64 bytes (or 65 with a sighash flag), simplifying fee estimation.
OP_SUCCESSxopcodes: Previously undefined opcodes are designated asOP_SUCCESS, making any script containing them automatically succeed. This provides a clean mechanism for future soft fork upgrades to assign new functionality to these opcodes.- Removed opcodes:
OP_CHECKMULTISIGandOP_CHECKMULTISIGVERIFYare disabled in Tapscript in favor ofOP_CHECKSIGADD.
Script-Path Execution
Taproot Output
|
Script-path spend:
|
┌───────────────────────────┐
│ 1. Reveal the script │
│ 2. Provide Merkle proof │
│ 3. Execute Tapscript │
│ 4. Validate against rules │
└───────────────────────────┘
When a script-path spend is used, the spender reveals the specific script leaf and provides a Merkle proof showing it is part of the committed script tree. The script is then executed under Tapscript rules rather than legacy Bitcoin Script rules.
Future Upgradeability
One of Tapscript's most important design features is the OP_SUCCESS mechanism. Because any script containing an OP_SUCCESS opcode unconditionally succeeds, a future soft fork can redefine these opcodes to add new conditions. This provides a much cleaner upgrade path than the legacy OP_NOP extension mechanism, which could only add new restrictions.
Common Misconceptions
Tapscript is not a completely new scripting language — it is a modified version of Bitcoin Script with specific rule changes for the Taproot context. Most existing opcodes behave identically in both systems.