MCPcopy Create free account
hub / github.com/LUX-Core/lux / CountWitnessSigOps

Function CountWitnessSigOps

src/script/interpreter.cpp:1591–1620  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1589}
1590
1591size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags)
1592{
1593 static const CScriptWitness witnessEmpty;
1594
1595 if ((flags & SCRIPT_VERIFY_WITNESS) == 0) {
1596 return 0;
1597 }
1598 assert((flags & SCRIPT_VERIFY_P2SH) != 0);
1599
1600 int witnessversion;
1601 std::vector<unsigned char> witnessprogram;
1602 if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
1603 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags);
1604 }
1605
1606 if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
1607 CScript::const_iterator pc = scriptSig.begin();
1608 vector<unsigned char> data;
1609 while (pc < scriptSig.end()) {
1610 opcodetype opcode;
1611 scriptSig.GetOp(pc, opcode, data);
1612 }
1613 CScript subscript(data.begin(), data.end());
1614 if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
1615 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty, flags);
1616 }
1617 }
1618
1619 return 0;
1620}

Callers 1

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

no test coverage detected