diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 7e9ae8e99a8b..61e3b9104f71 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -340,12 +340,12 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) } } - // Check policy limits for P2MR spends: + // Check policy limits for native P2MR spends: // - MAX_STANDARD_P2MR_STACK_ITEM_SIZE limit for stack item size // - Script path only (no key path spending) // - No annexes - if (witnessversion == 2 && witnessprogram.size() == WITNESS_V2_P2MR_SIZE) { - // P2MR spend (non-P2SH-wrapped, version 3, witness program size 32) + if (witnessversion == 2 && witnessprogram.size() == WITNESS_V2_P2MR_SIZE && !p2sh) { + // P2MR spend (native witness v2, witness program size 32) std::span stack{tx.vin[i].scriptWitness.stack}; if (stack.size() >= 2 && !stack.back().empty() && stack.back()[0] == ANNEX_TAG) { // Annexes are nonstandard as long as no semantics are defined for them. @@ -359,13 +359,7 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) if ((control_block[0] & TAPROOT_LEAF_MASK) == TAPROOT_LEAF_TAPSCRIPT) { // Leaf version 0xc0 (aka Tapscript, see BIP 342) for (const auto& item : stack) { - // Allow larger items for SLH-DSA signatures (OP_SUCCESS127) - if (item.size() > MAX_STANDARD_P2MR_STACK_ITEM_SIZE) { - // Check if this is an SLH-DSA signature by looking at the script - // You'd need to parse the script to see if it contains OP_SUCCESS127 - // For now, we could allow larger items when OP_SUCCESS127 is present - return false; // Keep existing behavior until SLH-DSA is implemented - } + if (item.size() > MAX_STANDARD_P2MR_STACK_ITEM_SIZE) return false; } } } else { diff --git a/src/policy/policy.h b/src/policy/policy.h index 78a21ef81e7c..421905615693 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -52,8 +52,8 @@ static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100}; static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0) */ static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80}; -/** The maximum size in bytes of each witness stack item in a standard P2MR script */ -static constexpr unsigned int MAX_STANDARD_P2MR_STACK_ITEM_SIZE{8000}; +/** The maximum size in bytes of each witness stack item in a standard BIP 360 script */ +static constexpr unsigned int MAX_STANDARD_P2MR_STACK_ITEM_SIZE{80}; /** The maximum size in bytes of a standard witnessScript */ static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600}; /** The maximum size of a standard ScriptSig */ diff --git a/src/script/descriptor.cpp b/src/script/descriptor.cpp index 7e6588b216d0..96fe35af1925 100644 --- a/src/script/descriptor.cpp +++ b/src/script/descriptor.cpp @@ -1631,7 +1631,7 @@ class P2MRDescriptor final : public DescriptorImpl uint256 merkle_root = builder.GetSpendData().merkle_root; CScript output_script; - output_script << OP_3 << ToByteVector(merkle_root); + output_script << OP_2 << ToByteVector(merkle_root); return {output_script}; } diff --git a/src/script/interpreter.cpp b/src/script/interpreter.cpp index 9b88d4a8ab18..da13ecc1aa35 100644 --- a/src/script/interpreter.cpp +++ b/src/script/interpreter.cpp @@ -9,13 +9,9 @@ #include #include #include -#include #include #include