From e7fa65d01e795a0166b534e76db2a201828f8c95 Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Wed, 8 Jan 2025 17:33:32 -0500 Subject: [PATCH] script: Add IsPayToTaproot() --- src/script/script.cpp | 7 +++++++ src/script/script.h | 2 ++ 2 files changed, 9 insertions(+) diff --git a/src/script/script.cpp b/src/script/script.cpp index d650db9a0d6..829e351be69 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -238,6 +238,13 @@ bool CScript::IsPayToWitnessScriptHash() const (*this)[1] == 0x20); } +bool CScript::IsPayToTaproot() const +{ + return (this->size() == 34 && + (*this)[0] == OP_1 && + (*this)[1] == 0x20); +} + // A witness program is any valid CScript that consists of a 1-byte push opcode // followed by a data push between 2 and 40 bytes. bool CScript::IsWitnessProgram(int& version, std::vector& program) const diff --git a/src/script/script.h b/src/script/script.h index f4579849803..6104630a1ee 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -556,6 +556,8 @@ public: bool IsPayToWitnessScriptHash() const; bool IsWitnessProgram(int& version, std::vector& program) const; + bool IsPayToTaproot() const; + /** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */ bool IsPushOnly(const_iterator pc) const; bool IsPushOnly() const;