Skip to main content

MAX_DECODE_DEPTH

Constant MAX_DECODE_DEPTH 

Source
pub const MAX_DECODE_DEPTH: u8 = 128;
Expand description

Hard cap on read_node recursion depth. Shared across all recursive tags (Sh, AndV, AndOr, TapTree, Multi, Tr, …) as a generic anti-DOS hardening bound — not a spec-mandated value for non-taproot sites. The value 128 happens to coincide with BIP-341 TAPROOT_CONTROL_MAX_NODE_COUNT, but its role here is just “any depth a real miniscript expression could plausibly reach + headroom”; P2WSH script-size limits cap practical miniscript depth at well under 50.