MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / CountWitnessSigOps

Function CountWitnessSigOps

src/script/interpreter.cpp:2149–2176  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

2147}
2148
2149size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness& witness, script_verify_flags flags)
2150{
2151 if ((flags & SCRIPT_VERIFY_WITNESS) == 0) {
2152 return 0;
2153 }
2154 assert((flags & SCRIPT_VERIFY_P2SH) != 0);
2155
2156 int witnessversion;
2157 std::vector<unsigned char> witnessprogram;
2158 if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
2159 return WitnessSigOps(witnessversion, witnessprogram, witness);
2160 }
2161
2162 if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
2163 CScript::const_iterator pc = scriptSig.begin();
2164 std::vector<unsigned char> data;
2165 while (pc < scriptSig.end()) {
2166 opcodetype opcode;
2167 scriptSig.GetOp(pc, opcode, data);
2168 }
2169 CScript subscript(data.begin(), data.end());
2170 if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
2171 return WitnessSigOps(witnessversion, witnessprogram, witness);
2172 }
2173 }
2174
2175 return 0;
2176}
2177
2178const std::map<std::string, script_verify_flag_name>& ScriptFlagNamesToEnum()
2179{

Callers 2

script.cppFile · 0.85
GetTransactionSigOpCostFunction · 0.85

Calls 7

WitnessSigOpsFunction · 0.85
IsPayToScriptHashMethod · 0.80
IsPushOnlyMethod · 0.80
GetOpMethod · 0.80
IsWitnessProgramMethod · 0.45
beginMethod · 0.45
endMethod · 0.45

Tested by

no test coverage detected