Skip to content

Commit 8e7dd0a

Browse files
SjorstheStack
andcommitted
Add CScript::IsPayToTaproot()
Co-authored-by: Sebastian Falbesoner <[email protected]>
1 parent 51b6e00 commit 8e7dd0a

File tree

2 files changed

+9
-0
lines changed

2 files changed

+9
-0
lines changed

src/script/script.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,13 @@ bool CScript::IsPayToWitnessScriptHash() const
238238
(*this)[1] == 0x20);
239239
}
240240

241+
bool CScript::IsPayToTaproot() const
242+
{
243+
return (this->size() == 34 &&
244+
(*this)[0] == OP_1 &&
245+
(*this)[1] == 0x20);
246+
}
247+
241248
// A witness program is any valid CScript that consists of a 1-byte push opcode
242249
// followed by a data push between 2 and 40 bytes.
243250
bool CScript::IsWitnessProgram(int& version, std::vector<unsigned char>& program) const

src/script/script.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -554,6 +554,8 @@ class CScript : public CScriptBase
554554

555555
bool IsPayToScriptHash() const;
556556
bool IsPayToWitnessScriptHash() const;
557+
// Extra-fast test for pay-to-taproot CScripts
558+
bool IsPayToTaproot() const;
557559
bool IsWitnessProgram(int& version, std::vector<unsigned char>& program) const;
558560

559561
/** Called by IsStandardTx and P2SH/BIP62 VerifyScript (which makes it consensus-critical). */

0 commit comments

Comments
 (0)