MCPcopy Create free account
hub / github.com/ElementsProject/elements / CountWitnessSigOps

Function CountWitnessSigOps

src/script/interpreter.cpp:3519–3548  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3517}
3518
3519size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags)
3520{
3521 static const CScriptWitness witnessEmpty;
3522
3523 if ((flags & SCRIPT_VERIFY_WITNESS) == 0) {
3524 return 0;
3525 }
3526 assert((flags & SCRIPT_VERIFY_P2SH) != 0);
3527
3528 int witnessversion;
3529 std::vector<unsigned char> witnessprogram;
3530 if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
3531 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
3532 }
3533
3534 if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
3535 CScript::const_iterator pc = scriptSig.begin();
3536 std::vector<unsigned char> data;
3537 while (pc < scriptSig.end()) {
3538 opcodetype opcode;
3539 scriptSig.GetOp(pc, opcode, data);
3540 }
3541 CScript subscript(data.begin(), data.end());
3542 if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
3543 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
3544 }
3545 }
3546
3547 return 0;
3548}

Callers 2

FUZZ_TARGET_INITFunction · 0.85
GetTransactionSigOpCostFunction · 0.85

Calls 7

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

Tested by 1

FUZZ_TARGET_INITFunction · 0.68