mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-03-05 12:39:23 +01:00
refactor: remove dead code in CountWitnessSigOps
Found while reviewing #32840 The `nullptr` witness path was dead in normal code paths: removing it deletes unreachable logic. Code coverage proof: https://maflcko.github.io/b-c-cov/total.coverage/src/script/interpreter.cpp.gcov.html#L2135
This commit is contained in:
@@ -2132,10 +2132,8 @@ size_t static WitnessSigOps(int witversion, const std::vector<unsigned char>& wi
|
||||
return 0;
|
||||
}
|
||||
|
||||
size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness* witness, script_verify_flags flags)
|
||||
size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey, const CScriptWitness& witness, script_verify_flags flags)
|
||||
{
|
||||
static const CScriptWitness witnessEmpty;
|
||||
|
||||
if ((flags & SCRIPT_VERIFY_WITNESS) == 0) {
|
||||
return 0;
|
||||
}
|
||||
@@ -2144,7 +2142,7 @@ size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey,
|
||||
int witnessversion;
|
||||
std::vector<unsigned char> witnessprogram;
|
||||
if (scriptPubKey.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||
return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
|
||||
return WitnessSigOps(witnessversion, witnessprogram, witness);
|
||||
}
|
||||
|
||||
if (scriptPubKey.IsPayToScriptHash() && scriptSig.IsPushOnly()) {
|
||||
@@ -2156,7 +2154,7 @@ size_t CountWitnessSigOps(const CScript& scriptSig, const CScript& scriptPubKey,
|
||||
}
|
||||
CScript subscript(data.begin(), data.end());
|
||||
if (subscript.IsWitnessProgram(witnessversion, witnessprogram)) {
|
||||
return WitnessSigOps(witnessversion, witnessprogram, witness ? *witness : witnessEmpty);
|
||||
return WitnessSigOps(witnessversion, witnessprogram, witness);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user