Skip to content

Commit dea30c7

Browse files
committed
[Script] Define IsPayToColdStaking() fast test
1 parent e8abd21 commit dea30c7

File tree

2 files changed

+13
-0
lines changed

2 files changed

+13
-0
lines changed

src/script/script.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -251,6 +251,18 @@ bool CScript::IsPayToScriptHash() const
251251
this->at(22) == OP_EQUAL);
252252
}
253253

254+
bool CScript::IsPayToColdStaking() const
255+
{
256+
// Extra-fast test for pay-to-cold-staking CScripts:
257+
return (this->size() == 51 &&
258+
this->at(2) == OP_ROT &&
259+
this->at(4) == OP_CHECKCOLDSTAKEVERIFY &&
260+
this->at(5) == 0x14 &&
261+
this->at(27) == 0x14 &&
262+
this->at(49) == OP_EQUALVERIFY &&
263+
this->at(50) == OP_CHECKSIG);
264+
}
265+
254266
bool CScript::StartsWithOpcode(const opcodetype opcode) const
255267
{
256268
return (!this->empty() && this->at(0) == opcode);

src/script/script.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -605,6 +605,7 @@ class CScript : public std::vector<unsigned char>
605605

606606
bool IsNormalPaymentScript() const;
607607
bool IsPayToScriptHash() const;
608+
bool IsPayToColdStaking() const;
608609
bool StartsWithOpcode(const opcodetype opcode) const;
609610
bool IsZerocoinMint() const;
610611
bool IsZerocoinSpend() const;

0 commit comments

Comments
 (0)