MCPcopy Create free account
hub / github.com/ElementsProject/elements / IsFinalTx

Function IsFinalTx

src/consensus/tx_verify.cpp:18–38  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

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

Callers 5

CheckFinalTxFunction · 0.85
ContextualCheckBlockFunction · 0.85
BOOST_AUTO_TEST_CASEFunction · 0.85
FUZZ_TARGET_INITFunction · 0.85

Calls

no outgoing calls

Tested by 3

BOOST_AUTO_TEST_CASEFunction · 0.68
FUZZ_TARGET_INITFunction · 0.68