diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index a5b6d139bbf3b..a5d082fcaa3c8 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -258,8 +258,9 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) // Taproot spend (non-P2SH-wrapped, version 1, witness program size 32; see BIP 341) 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. - return false; + const auto& annex_stack = SpanPopBack(stack); + if (!IsAnnexStandard(annex_stack)) + return false; } if (stack.size() >= 2) { // Script path spend (2 or more stack elements after removing optional annex) @@ -284,6 +285,12 @@ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) return true; } +bool IsAnnexStandard(const std::vector& annex_stack) { + //TODO: - annex should not be present but empty + // - no unknown tags present + return true; +} + int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop) { return (std::max(nWeight, nSigOpCost * bytes_per_sigop) + WITNESS_SCALE_FACTOR - 1) / WITNESS_SCALE_FACTOR; diff --git a/src/policy/policy.h b/src/policy/policy.h index e3129f204c406..add9b3e9b30dd 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -119,6 +119,8 @@ bool AreInputsStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs) */ bool IsWitnessStandard(const CTransaction& tx, const CCoinsViewCache& mapInputs); +bool IsAnnexStandard(const std::vector& annex_stack); + /** Compute the virtual transaction size (weight reinterpreted as bytes). */ int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop); int64_t GetVirtualTransactionSize(const CTransaction& tx, int64_t nSigOpCost, unsigned int bytes_per_sigop);