- [From BIP141] If the version is 0:
- If the program is not 20 or 32 bytes, fail.
- If the program is 20 bytes
hash
:- If
input
is not exactly 2 elements, fail. - Execute the script OP_DUP OP_HASH160
hash
OP_EQUALVERIFY OP_CHECKSIG, with initial stackinput
. If execution aborts, fail. - If the resulting stack is not exactly one element, or that element has numerical value 0, fail.
- If
- If the program is 32 bytes
hash
:- If
input
is empty, or its top element's SHA256 hash does not equalhash
, fail. - Execute the top element of
input
as script, with the other elements as input. If execution aborts, fail. - If the resulting stack is not exactly one element, or that element has numerical value 0, fail.
- If
- [From BIP341] If the version is 1, the program length is 32, and this is not operating inside a P2SH wrapping:
- If the
input
consists of 0 elements, fail. - If the last element of
input
starts with byte 0x50, call it theannex
and remove it from theinput
. - If the (remainder of)
input
consists of a single element, evaluate it as a Taproot key path spend:- The element is interpreted as a single BIP340 (Schnorr) signature for the transaction, using a message hashing scheme described in BIP341. If the signature is invalid, fail.
- If the (remainder of)
input
consists of two or more elements, evaluate it as a Taproot script path spend:- The last element of
input
is interpreted as a Taproot control block, encoding aleaf_version
, an internal x-only public key, and a Merkle path, and the penultimate element ofinput
is called thetaproot_script
. The control block andtaproot_script
are removed frominput
.- Recompute the Merkle root of the script tree, starting from the leaf (
leaf_version
andtaproot_script
), and then tweak the internal x-only key with that Merkle root. If the result does not match the 32-byte witness program, fail. - [From BIP342] If the
leaf_version
is 0xc0,taproot_script
is evaluated according to the Tapscript validation rules, with the remaining ofinput
as initial stack. See BIP342 for how this differs from normal script execution.
- Recompute the Merkle root of the script tree, starting from the leaf (
- The last element of
- If the
- If no failure occurred up to this point, return success.
Adding a check whether the witness data is exactly 2 items (https://github.com/bitcoin/bitcoin/blob/v25.0/src/script/interpreter.cpp#L1895)
dassd
- 1.1k
- 1
- 4
- 22