mirror of
https://github.com/dashpay/dash.git
synced 2024-12-25 20:12:57 +01:00
Drop IsNormalPaymentScript
, use IsPayToPublicKeyHash
(#1761)
This commit is contained in:
parent
442325b072
commit
c5ec2f82a8
@ -541,7 +541,7 @@ bool CGovernanceObject::IsCollateralValid(std::string& strError, bool& fMissingC
|
|||||||
<< ", o.nValue = " << o.nValue
|
<< ", o.nValue = " << o.nValue
|
||||||
<< ", o.scriptPubKey = " << ScriptToAsmStr( o.scriptPubKey, false )
|
<< ", o.scriptPubKey = " << ScriptToAsmStr( o.scriptPubKey, false )
|
||||||
<< endl; );
|
<< endl; );
|
||||||
if(!o.scriptPubKey.IsNormalPaymentScript() && !o.scriptPubKey.IsUnspendable()){
|
if(!o.scriptPubKey.IsPayToPublicKeyHash() && !o.scriptPubKey.IsUnspendable()) {
|
||||||
strError = strprintf("Invalid Script %s", txCollateral.ToString());
|
strError = strprintf("Invalid Script %s", txCollateral.ToString());
|
||||||
LogPrintf ("CGovernanceObject::IsCollateralValid -- %s\n", strError);
|
LogPrintf ("CGovernanceObject::IsCollateralValid -- %s\n", strError);
|
||||||
return false;
|
return false;
|
||||||
|
@ -946,7 +946,7 @@ bool CTxLockRequest::IsValid() const
|
|||||||
BOOST_FOREACH(const CTxOut& txout, vout) {
|
BOOST_FOREACH(const CTxOut& txout, vout) {
|
||||||
// InstantSend supports normal scripts and unspendable (i.e. data) scripts.
|
// InstantSend supports normal scripts and unspendable (i.e. data) scripts.
|
||||||
// TODO: Look into other script types that are normal and can be included
|
// TODO: Look into other script types that are normal and can be included
|
||||||
if(!txout.scriptPubKey.IsNormalPaymentScript() && !txout.scriptPubKey.IsUnspendable()) {
|
if(!txout.scriptPubKey.IsPayToPublicKeyHash() && !txout.scriptPubKey.IsUnspendable()) {
|
||||||
LogPrint("instantsend", "CTxLockRequest::IsValid -- Invalid Script %s", ToString());
|
LogPrint("instantsend", "CTxLockRequest::IsValid -- Invalid Script %s", ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -182,7 +182,7 @@ void CPrivateSendServer::ProcessMessage(CNode* pfrom, std::string& strCommand, C
|
|||||||
PushStatus(pfrom, STATUS_REJECTED, ERR_NON_STANDARD_PUBKEY, connman);
|
PushStatus(pfrom, STATUS_REJECTED, ERR_NON_STANDARD_PUBKEY, connman);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if(!txout.scriptPubKey.IsNormalPaymentScript()) {
|
if(!txout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
LogPrintf("DSVIN -- invalid script! scriptPubKey=%s\n", ScriptToAsmStr(txout.scriptPubKey));
|
LogPrintf("DSVIN -- invalid script! scriptPubKey=%s\n", ScriptToAsmStr(txout.scriptPubKey));
|
||||||
PushStatus(pfrom, STATUS_REJECTED, ERR_INVALID_SCRIPT, connman);
|
PushStatus(pfrom, STATUS_REJECTED, ERR_INVALID_SCRIPT, connman);
|
||||||
return;
|
return;
|
||||||
|
@ -187,7 +187,7 @@ bool CPrivateSend::IsCollateralValid(const CTransaction& txCollateral)
|
|||||||
BOOST_FOREACH(const CTxOut txout, txCollateral.vout) {
|
BOOST_FOREACH(const CTxOut txout, txCollateral.vout) {
|
||||||
nValueOut += txout.nValue;
|
nValueOut += txout.nValue;
|
||||||
|
|
||||||
if(!txout.scriptPubKey.IsNormalPaymentScript()) {
|
if(!txout.scriptPubKey.IsPayToPublicKeyHash()) {
|
||||||
LogPrintf ("CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString());
|
LogPrintf ("CPrivateSend::IsCollateralValid -- Invalid Script, txCollateral=%s", txCollateral.ToString());
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -200,39 +200,15 @@ unsigned int CScript::GetSigOpCount(const CScript& scriptSig) const
|
|||||||
return subscript.GetSigOpCount(true);
|
return subscript.GetSigOpCount(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScript::IsNormalPaymentScript() const
|
|
||||||
{
|
|
||||||
if(this->size() != 25) return false;
|
|
||||||
|
|
||||||
std::string str;
|
|
||||||
opcodetype opcode;
|
|
||||||
const_iterator pc = begin();
|
|
||||||
int i = 0;
|
|
||||||
while (pc < end())
|
|
||||||
{
|
|
||||||
GetOp(pc, opcode);
|
|
||||||
|
|
||||||
if( i == 0 && opcode != OP_DUP) return false;
|
|
||||||
else if(i == 1 && opcode != OP_HASH160) return false;
|
|
||||||
else if(i == 3 && opcode != OP_EQUALVERIFY) return false;
|
|
||||||
else if(i == 4 && opcode != OP_CHECKSIG) return false;
|
|
||||||
else if(i == 5) return false;
|
|
||||||
|
|
||||||
i++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
bool CScript::IsPayToPublicKeyHash() const
|
bool CScript::IsPayToPublicKeyHash() const
|
||||||
{
|
{
|
||||||
// Extra-fast test for pay-to-pubkey-hash CScripts:
|
// Extra-fast test for pay-to-pubkey-hash CScripts:
|
||||||
return (this->size() == 25 &&
|
return (this->size() == 25 &&
|
||||||
(*this)[0] == OP_DUP &&
|
(*this)[0] == OP_DUP &&
|
||||||
(*this)[1] == OP_HASH160 &&
|
(*this)[1] == OP_HASH160 &&
|
||||||
(*this)[2] == 0x14 &&
|
(*this)[2] == 0x14 &&
|
||||||
(*this)[23] == OP_EQUALVERIFY &&
|
(*this)[23] == OP_EQUALVERIFY &&
|
||||||
(*this)[24] == OP_CHECKSIG);
|
(*this)[24] == OP_CHECKSIG);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool CScript::IsPayToScriptHash() const
|
bool CScript::IsPayToScriptHash() const
|
||||||
|
@ -620,7 +620,6 @@ public:
|
|||||||
*/
|
*/
|
||||||
unsigned int GetSigOpCount(const CScript& scriptSig) const;
|
unsigned int GetSigOpCount(const CScript& scriptSig) const;
|
||||||
|
|
||||||
bool IsNormalPaymentScript() const;
|
|
||||||
bool IsPayToPublicKeyHash() const;
|
bool IsPayToPublicKeyHash() const;
|
||||||
|
|
||||||
bool IsPayToScriptHash() const;
|
bool IsPayToScriptHash() const;
|
||||||
|
Loading…
Reference in New Issue
Block a user