MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / IsFinalTx

Function IsFinalTx

src/consensus/tx_verify.cpp:17–37  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15#include <util/moneystr.h>
16
17bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
18{
19 if (tx.nLockTime == 0)
20 return true;
21 if ((int64_t)tx.nLockTime < ((int64_t)tx.nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
22 return true;
23
24 // Even if tx.nLockTime isn't satisfied by nBlockHeight/nBlockTime, a
25 // transaction is still considered final if all inputs' nSequence ==
26 // SEQUENCE_FINAL (0xffffffff), in which case nLockTime is ignored.
27 //
28 // Because of this behavior OP_CHECKLOCKTIMEVERIFY/CheckLockTime() will
29 // also check that the spending input's nSequence != SEQUENCE_FINAL,
30 // ensuring that an unsatisfied nLockTime value will actually cause
31 // IsFinalTx() to return false here:
32 for (const auto& txin : tx.vin) {
33 if (!(txin.nSequence == CTxIn::SEQUENCE_FINAL))
34 return false;
35 }
36 return true;
37}
38
39std::pair<int, int64_t> CalculateSequenceLocks(const CTransaction &tx, int flags, std::vector<int>& prevHeights, const CBlockIndex& block)
40{

Callers 5

CheckFinalTxAtTipFunction · 0.85
ContextualCheckBlockFunction · 0.85
TestBasicMiningMethod · 0.85
transaction.cppFile · 0.85
TestChunkTransactionsMethod · 0.85

Calls

no outgoing calls

Tested by 2

TestBasicMiningMethod · 0.68
TestChunkTransactionsMethod · 0.68