from src/interpreter.cpp - I'm seeking clarification on why OP_CHECKLOCKTIMEVERIFY will fail if the current txin sequence number is set to maxint. The code comments say it will be "bypassed", but it is my understanding that if the script fails to validate with SCRIPT_ERR_UNSATISFIED_LOCKTIME then the transaction will not go into the mempool, and thus will not be selected for mining into a block.
...
case OP_CHECKLOCKTIMEVERIFY:
{
...
// Actually compare the specified lock time with the transaction.
if (!checker.CheckLockTime(nLockTime))
return set_error(serror, SCRIPT_ERR_UNSATISFIED_LOCKTIME);
break;
}
...
bool TransactionSignatureChecker::CheckLockTime(const CScriptNum& nLockTime) const
{
...
// Finally the nLockTime feature can be disabled and thus
// CHECKLOCKTIMEVERIFY bypassed if every txin has been
// finalized by setting nSequence to maxint. The
// transaction would be allowed into the blockchain, making
// the opcode ineffective.
//
// Testing if this vin is not final is sufficient to
// prevent this condition. Alternatively we could test all
// inputs, but testing just this input minimizes the data
// required to prove correct CHECKLOCKTIMEVERIFY execution.
if (txTo->vin[nIn].IsFinal())
return false;
return true;
}
For starters I don't understand why only the current txin is tested. And secondly, I would have thought that if all txin sequence numbers were set to maxint then it should return true, not false. Maybe the if statement has a bug and should be negated there?
Can someone explain this code to me please.