mirror of
https://github.com/ElementsProject/elements.git
synced 2026-08-14 12:43:40 +02:00
Recognize pegout scripts
This commit is contained in:
parent
4688e3eb8e
commit
7bb9380260
2 changed files with 53 additions and 0 deletions
|
|
@ -194,6 +194,49 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
|
|||
return subscript.GetSigOpCount(true);
|
||||
}
|
||||
|
||||
//
|
||||
// ELEMENTS:
|
||||
|
||||
bool CScript::IsPegoutScript(uint256& genesis_hash, CScript& pegout_scriptpubkey) const
|
||||
{
|
||||
const_iterator pc = begin();
|
||||
std::vector<unsigned char> data;
|
||||
opcodetype opcode;
|
||||
|
||||
// OP_RETURN
|
||||
if (!GetOp(pc, opcode, data) || opcode != OP_RETURN) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GetOp(pc, opcode, data) || data.size() != 32 ) {
|
||||
return false;
|
||||
}
|
||||
genesis_hash = uint256(data);
|
||||
|
||||
// Read in parent chain destination scriptpubkey
|
||||
if (!GetOp(pc, opcode, data) || data.size() == 0 ) {
|
||||
return false;
|
||||
}
|
||||
pegout_scriptpubkey = CScript(data.begin(), data.end());
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CScript::IsPegoutScript(const uint256& genesis_hash_check) const
|
||||
{
|
||||
uint256 genesis_hash;
|
||||
CScript pegout_scriptpubkey;
|
||||
// Ensure hash matches parent chain genesis block
|
||||
if (this->IsPegoutScript(genesis_hash, pegout_scriptpubkey) &&
|
||||
genesis_hash_check == genesis_hash) {
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
// END ELEMENTS
|
||||
//
|
||||
|
||||
bool CScript::IsPayToScriptHash() const
|
||||
{
|
||||
// Extra-fast test for pay-to-script-hash CScripts:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue