diff options
author | Yuval Kogman <nothingmuch@woobling.org> | 2020-02-07 19:10:31 +0000 |
---|---|---|
committer | Yuval Kogman <nothingmuch@woobling.org> | 2021-04-27 11:52:13 +0000 |
commit | f9e37f33ce2d8b463a0bcbe7189c9bc5b36530b7 (patch) | |
tree | dc3c1c76f20cf7fed82c36a5e66a5e74e6482a37 /src/consensus/tx_verify.cpp | |
parent | c6d6bc8abb721be68a3d2cdba11ceb5e9814c9b1 (diff) | |
download | bitcoin-f9e37f33ce2d8b463a0bcbe7189c9bc5b36530b7.tar.xz |
doc: IsFinalTx comment about nSequence & OP_CLTV
It's somewhat surprising that a transaction's nLockTime field is ignored
when all nSequence fields are final, so this change aims to clarify this
behavior and cross reference relevant details of OP_CHECKLOCKTIMEVERIFY.
Diffstat (limited to 'src/consensus/tx_verify.cpp')
-rw-r--r-- | src/consensus/tx_verify.cpp | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp index f595f16eab..88d8da6ed5 100644 --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -20,6 +20,15 @@ bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime) return true; if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime)) return true; + + // Even if tx.nLockTime isn't satisfied by nBlockHeight/nBlockTime, a + // transaction is still considered final if all inputs' nSequence == + // SEQUENCE_FINAL (0xffffffff), in which case nLockTime is ignored. + // + // Because of this behavior OP_CHECKLOCKTIMEVERIFY/CheckLockTime() will + // also check that the spending input's nSequence != SEQUENCE_FINAL, + // ensuring that an unsatisfied nLockTime value will actually cause + // IsFinalTx() to return false here: for (const auto& txin : tx.vin) { if (!(txin.nSequence == CTxIn::SEQUENCE_FINAL)) return false; |