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

Function CountWitnessSigOps

src/script/interpreter.cpp:1650–1679  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1648}
1649
1650size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, unsigned int flags)
1651{
1652 static const CScriptWitness witnessEmpty;
1653
1654 if ((flags & SCRIPT_VERIFY_WITNESS) == 0) {
1655 return 0;
1656 }
1657 assert((flags & SCRIPT_VERIFY_P2SH) != 0);
1658
1659 int witnessversion;
1660 std::vector<unsigned char> witnessprogram;
1661 if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
1662 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
1663 }
1664
1665 if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
1666 CScript::const_iterator pc = scriptSig.begin();
1667 std::vector<unsigned char> data;
1668 while (pc < scriptSig.end()) {
1669 opcodetype opcode;
1670 scriptSig.GetOp(pc, opcode, data);
1671 }
1672 CScript subscript(data.begin(), data.end());
1673 if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
1674 return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
1675 }
1676 }
1677
1678 return 0;
1679}

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