From 8c7746c4de503e699f4cc701daf21124b166b381 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Mon, 17 Dec 2018 09:36:05 -0500 Subject: [PATCH] Add CScript::IsPayToPubkeyHash convienience function --- src/script/script.cpp | 10 ++++++++++ src/script/script.h | 1 + 2 files changed, 11 insertions(+) diff --git a/src/script/script.cpp b/src/script/script.cpp index fba7745983..8814139b2c 100644 --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -234,6 +234,16 @@ bool CScript::IsPegoutScript(const uint256& genesis_hash_check) const return false; } +bool CScript::IsPayToPubkeyHash() const +{ + // Extra-fast test for pay-to-pubkey-hash CScripts: + return (this->size() == 25 && + (*this)[0] == OP_DUP && + (*this)[1] == OP_HASH160 && + (*this)[2] == 0x14 && + (*this)[23] == OP_EQUALVERIFY && + (*this)[24] == OP_CHECKSIG); +} // END ELEMENTS // diff --git a/src/script/script.h b/src/script/script.h index a66dbc9353..7e6fdcf1d8 100644 --- a/src/script/script.h +++ b/src/script/script.h @@ -537,6 +537,7 @@ public: */ unsigned int GetSigOpCount(const CScript& scriptSig) const; + bool IsPayToPubkeyHash() const; bool IsPayToScriptHash() const; bool IsPayToWitnessScriptHash() const; bool IsWitnessProgram(int& version, std::vector& program) const;