TYPE 0x0907 · LEGACY FAMILY
P2TR_SCRIPT_LEGACY
Legacy P2TR script-path (Taproot) wrapped as a typed Ladder Script block. This is the critical block — taproot script-path is the primary inscription/data-embedding vector today. The revealed script leaf must be valid Ladder Script conditions.
Legacy Non-InvertibleLadder Diagram
Fields
| Field | Data Type | Size | Side | Description |
|---|---|---|---|---|
| hash256 | HASH256 | 32 B | Conditions | Merkle root of the script tree. Node-computed — the node derives this from the PREIMAGE (script leaf). Raw hash input is rejected. |
| preimage | PREIMAGE | var | Witness | Revealed script leaf (serialised Ladder Script conditions) — provided by the user. The node derives HASH256 from this data at creation time. |
| [inner witness] | var | var | Witness | Witness fields required to satisfy the revealed leaf conditions |
Public key folded into Merkle leaf via merkle_pub_key (PubkeyCountForBlock = 1). No key field in conditions.
Wire Format Breakdown
Conditions side (committed in the rung leaf):
0x0907
0
1
HASH256 · 32B
= 38 bytes
Witness side (in input witness):
0x0907
0
n
PREIMAGE · varB
[inner witness fields]
= variable
Total (conditions + witness)
variable
Witness size depends on the revealed script leaf and its witness fields.
Evaluation Logic
1.
Locate HASH256 and PREIMAGE (or SCRIPT_BODY as a fallback). Either missing → ERROR. HASH256 not exactly 32 B → ERROR
2.
Single-leaf model: compute SHA256(PREIMAGE) directly and
memcmp against the committed HASH256. Mismatch → UNSATISFIED. (For deeper script trees the user must commit a structure that hashes down to a single leaf at this layer; multi-leaf taproot expansion is not implemented in the wrapper.)
3.
Recurse into EvalInnerConditions(PREIMAGE, depth+1): deserialize, enforce
MAX_LEGACY_INNER_DEPTH = 2, audit-E-020 witness-stack exact-count guard, evaluate inner rungs with OR logic.
Return Values
| Condition | Result |
|---|---|
| Missing HASH256 or PREIMAGE | ERROR |
| SHA256(PREIMAGE) != HASH256 (Merkle root) | UNSATISFIED |
| PREIMAGE fails to deserialize as Ladder conditions | ERROR |
| Inner conditions evaluation fails | UNSATISFIED |
| Recursion depth > 2 | ERROR |
| Inner conditions satisfied | SATISFIED |
JSON Wire Format
Conditions (committed in the rung leaf)
{
"type": "P2TR_SCRIPT_LEGACY",
"inverted": false,
"fields": [
{ "type": "HASH256", "hex": "e3b0c4...32 bytes (Merkle root)" }
]
}Witness (input)
{
"type": "P2TR_SCRIPT_LEGACY",
"inverted": false,
"fields": [
{ "type": "PREIMAGE", "hex": "01020304...serialised Ladder conditions (revealed leaf)" },
{ "type": "PUBKEY", "hex": "02abc1...33 bytes" },
{ "type": "SIGNATURE", "hex": "e5f6a7...64 bytes" }
]
}Notes
- Closes the taproot inscription vector — the primary data-embedding surface in Bitcoin today.
- Revealed script leaf must deserialize as valid Ladder Script conditions. Arbitrary data is rejected.
- HASH256 is node-computed: the user provides PREIMAGE (script leaf) and the node derives the hash automatically. PUBKEY (internal key) is folded into the Merkle leaf via merkle_pub_key. Submitting raw hash values directly is rejected.
- Recursion depth limited to 2.
- The internal key is folded into the Merkle leaf, used for key-path/script-path binding.
- For key-path-only spending, see P2TR_LEGACY (0x0906).
Use Cases
Anti-Inscription Protection
The primary inscription/data-embedding vector (taproot script-path) is closed. Revealed script leaf MUST be valid Ladder conditions.
Script Tree Migration
Taproot script tree with typed Ladder leaves instead of arbitrary scripts. Full anti-spam coverage.