Changeset View
Changeset View
Standalone View
Standalone View
src/script/script.cpp
Show First 20 Lines • Show All 365 Lines • ▼ Show 20 Lines | bool CScriptNum::MinimallyEncode(std::vector<uint8_t> &data) { | ||||
} | } | ||||
// If we the whole thing is zeros, then we have a zero. | // If we the whole thing is zeros, then we have a zero. | ||||
data = {}; | data = {}; | ||||
return true; | return true; | ||||
} | } | ||||
uint32_t CScript::GetSigOpCount(uint32_t flags, bool fAccurate) const { | uint32_t CScript::GetSigOpCount(uint32_t flags, bool fAccurate) const { | ||||
if (flags & SCRIPT_ZERO_SIGOPS) { | |||||
return 0; | return 0; | ||||
} | } | ||||
uint32_t n = 0; | |||||
const_iterator pc = begin(); | |||||
opcodetype lastOpcode = OP_INVALIDOPCODE; | |||||
while (pc < end()) { | |||||
opcodetype opcode; | |||||
if (!GetOp(pc, opcode)) { | |||||
break; | |||||
} | |||||
switch (opcode) { | |||||
case OP_CHECKSIG: | |||||
case OP_CHECKSIGVERIFY: | |||||
n++; | |||||
break; | |||||
case OP_CHECKDATASIG: | |||||
case OP_CHECKDATASIGVERIFY: | |||||
if (flags & SCRIPT_VERIFY_CHECKDATASIG_SIGOPS) { | |||||
n++; | |||||
} | |||||
break; | |||||
case OP_CHECKMULTISIG: | |||||
case OP_CHECKMULTISIGVERIFY: | |||||
if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) { | |||||
n += DecodeOP_N(lastOpcode); | |||||
} else { | |||||
n += MAX_PUBKEYS_PER_MULTISIG; | |||||
} | |||||
break; | |||||
default: | |||||
break; | |||||
} | |||||
lastOpcode = opcode; | |||||
} | |||||
return n; | |||||
} | |||||
uint32_t CScript::GetSigOpCount(uint32_t flags, | uint32_t CScript::GetSigOpCount(uint32_t flags, | ||||
const CScript &scriptSig) const { | const CScript &scriptSig) const { | ||||
if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { | if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { | ||||
return GetSigOpCount(flags, true); | return GetSigOpCount(flags, true); | ||||
} | } | ||||
// This is a pay-to-script-hash scriptPubKey; | // This is a pay-to-script-hash scriptPubKey; | ||||
▲ Show 20 Lines • Show All 159 Lines • Show Last 20 Lines |