diff --git a/src/script/script.cpp b/src/script/script.cpp --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -344,23 +344,38 @@ opcodetype lastOpcode = OP_INVALIDOPCODE; while (pc < end()) { opcodetype opcode; - if (!GetOp(pc, opcode)) break; - if (opcode == OP_CHECKSIG || opcode == OP_CHECKSIGVERIFY) - n++; - else if (opcode == OP_CHECKMULTISIG || - opcode == OP_CHECKMULTISIGVERIFY) { - if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) - n += DecodeOP_N(lastOpcode); - else - n += MAX_PUBKEYS_PER_MULTISIG; + if (!GetOp(pc, opcode)) { + break; } + + switch (opcode) { + case OP_CHECKSIG: + case OP_CHECKSIGVERIFY: + n++; + break; + + case OP_CHECKMULTISIG: + case OP_CHECKMULTISIGVERIFY: + if (fAccurate && lastOpcode >= OP_1 && lastOpcode <= OP_16) { + n += DecodeOP_N(lastOpcode); + } else { + n += MAX_PUBKEYS_PER_MULTISIG; + } + break; + default: + break; + } + lastOpcode = opcode; } + return n; } unsigned int CScript::GetSigOpCount(const CScript &scriptSig) const { - if (!IsPayToScriptHash()) return GetSigOpCount(true); + if (!IsPayToScriptHash()) { + return GetSigOpCount(true); + } // This is a pay-to-script-hash scriptPubKey; // get the last item that the scriptSig @@ -369,8 +384,12 @@ std::vector data; while (pc < scriptSig.end()) { opcodetype opcode; - if (!scriptSig.GetOp(pc, opcode, data)) return 0; - if (opcode > OP_16) return 0; + if (!scriptSig.GetOp(pc, opcode, data)) { + return 0; + } + if (opcode > OP_16) { + return 0; + } } /// ... and return its opcount: diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -366,11 +366,11 @@ // from CalculateSequenceLocks against tip+1. We know // EvaluateSequenceLocks will fail if there was a non-zero sequence // lock on a mempool input, so we can use the return value of - // CheckSequenceLocks to indicate the LockPoints validity + // CheckSequenceLocks to indicate the LockPoints validity. int maxInputHeight = 0; for (int height : prevheights) { // Can ignore mempool inputs since we'll fail if they had - // non-zero locks + // non-zero locks. if (height != tip->nHeight + 1) { maxInputHeight = std::max(maxInputHeight, height); }