21     if ((int64_t)tx.
nLockTime < ((int64_t)tx.
nLockTime < LOCKTIME_THRESHOLD ? (int64_t)nBlockHeight : nBlockTime))
    23     for (
const auto& txin : tx.
vin) {
    32     assert(prevHeights->size() == tx.
vin.size());
    40     int64_t nMinTime = -1;
    45     bool fEnforceBIP68 = 
static_cast<uint32_t
>(tx.
nVersion) >= 2
    46                       && 
flags & LOCKTIME_VERIFY_SEQUENCE;
    51         return std::make_pair(nMinHeight, nMinTime);
    54     for (
size_t txinIndex = 0; txinIndex < tx.
vin.size(); txinIndex++) {
    55         const CTxIn& txin = tx.
vin[txinIndex];
    62             (*prevHeights)[txinIndex] = 0;
    66         int nCoinHeight = (*prevHeights)[txinIndex];
    89     return std::make_pair(nMinHeight, nMinTime);
    96     if (lockPair.first >= block.
nHeight || lockPair.second >= nBlockTime)
   109     unsigned int nSigOps = 0;
   110     for (
const auto& txin : tx.
vin)
   112         nSigOps += txin.scriptSig.GetSigOpCount(
false);
   114     for (
const auto& txout : tx.
vout)
   116         nSigOps += txout.scriptPubKey.GetSigOpCount(
false);
   126     unsigned int nSigOps = 0;
   127     for (
unsigned int i = 0; i < tx.
vin.size(); i++)
   132         if (prevout.scriptPubKey.IsPayToScriptHash())
   149     for (
unsigned int i = 0; i < tx.
vin.size(); i++)
   163         return state.
DoS(10, 
false, REJECT_INVALID, 
"bad-txns-vin-empty");
   165         return state.
DoS(10, 
false, REJECT_INVALID, 
"bad-txns-vout-empty");
   167     if (::
GetSerializeSize(tx, PROTOCOL_VERSION | SERIALIZE_TRANSACTION_NO_WITNESS) * WITNESS_SCALE_FACTOR > MAX_BLOCK_WEIGHT)
   168         return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-oversize");
   172     for (
const auto& txout : tx.
vout)
   174         if (txout.nValue < 0)
   175             return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-vout-negative");
   176         if (txout.nValue > MAX_MONEY)
   177             return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-vout-toolarge");
   178         nValueOut += txout.nValue;
   180             return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-txouttotal-toolarge");
   184     if (fCheckDuplicateInputs) {
   185         std::set<COutPoint> vInOutPoints;
   186         for (
const auto& txin : tx.
vin)
   188             if (!vInOutPoints.insert(txin.prevout).second)
   189                 return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-inputs-duplicate");
   195         if (tx.
vin[0].scriptSig.size() < 2 || tx.
vin[0].scriptSig.size() > 100)
   196             return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-cb-length");
   200         for (
const auto& txin : tx.
vin)
   201             if (txin.prevout.IsNull())
   202                 return state.
DoS(10, 
false, REJECT_INVALID, 
"bad-txns-prevout-null");
   212         return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-inputs-missingorspent", 
false,
   213                          strprintf(
"%s: inputs missing/spent", __func__));
   217     for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
   225                 REJECT_INVALID, 
"bad-txns-premature-spend-of-coinbase",
   226                 strprintf(
"tried to spend coinbase at depth %d", nSpendHeight - coin.
nHeight));
   232             return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-inputvalues-outofrange");
   237     if (nValueIn < value_out) {
   238         return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-in-belowout", 
false,
   243     const CAmount txfee_aux = nValueIn - value_out;
   245         return state.
DoS(100, 
false, REJECT_INVALID, 
"bad-txns-fee-outofrange");
 unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops. 
 
std::pair< int, int64_t > CalculateSequenceLocks(const CTransaction &tx, int flags, std::vector< int > *prevHeights, const CBlockIndex &block)
Calculates the block height and previous block's median time past at which the transaction will be co...
 
CBlockIndex * pprev
pointer to the index of the predecessor of this block 
 
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or a pruned one if not found. 
 
bool SequenceLocks(const CTransaction &tx, int flags, std::vector< int > *prevHeights, const CBlockIndex &block)
Check if transaction is final per BIP 68 sequence numbers and can be included in a block...
 
size_t CountWitnessSigOps(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags)
 
static const uint32_t SEQUENCE_FINAL
 
bool MoneyRange(const CAmount &nValue)
 
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG
 
CTxOut out
unspent transaction output 
 
static const int SEQUENCE_LOCKTIME_GRANULARITY
 
bool DoS(int level, bool ret=false, unsigned int chRejectCodeIn=0, const std::string &strRejectReasonIn="", bool corruptionIn=false, const std::string &strDebugMessageIn="")
 
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view...
 
const std::vector< CTxIn > vin
 
CAmount GetValueOut() const
 
size_t GetSerializeSize(const T &t, int nVersion=0)
 
int64_t CAmount
Amount in satoshis (Can be negative) 
 
uint32_t nHeight
at which height this containing transaction was included in the active block chain ...
 
An input of a transaction. 
 
bool CheckTxInputs(const CTransaction &tx, CValidationState &state, const CCoinsViewCache &inputs, int nSpendHeight, CAmount &txfee)
Check whether all inputs of this transaction are valid (no double spends and amounts) This does not m...
 
const std::vector< CTxOut > vout
 
bool EvaluateSequenceLocks(const CBlockIndex &block, std::pair< int, int64_t > lockPair)
 
An output of a transaction. 
 
static const uint32_t SEQUENCE_LOCKTIME_TYPE_FLAG
 
An outpoint - a combination of a transaction hash and an index n into its vout. 
 
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities. 
 
int64_t GetMedianTimePast() const
 
Capture information about block/transaction validation. 
 
static const uint32_t SEQUENCE_LOCKTIME_MASK
 
unsigned int GetLegacySigOpCount(const CTransaction &tx)
Auxiliary functions for transaction validation (ideally should not be exposed) 
 
The block chain is a tree shaped structure starting with the genesis block at the root...
 
unsigned int GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &inputs)
Count ECDSA signature operations in pay-to-script-hash inputs. 
 
bool CheckTransaction(const CTransaction &tx, CValidationState &state, bool fCheckDuplicateInputs)
Transaction validation functions. 
 
bool IsFinalTx(const CTransaction &tx, int nBlockHeight, int64_t nBlockTime)
Check if transaction is final and can be included in a block with the specified height and time...
 
The basic transaction that is broadcasted on the network and contained in blocks. ...
 
int nHeight
height of the entry in the chain. The genesis block has height 0 
 
CCoinsView that adds a memory cache for transactions to another CCoinsView. 
 
CBlockIndex * GetAncestor(int height)
Efficiently find an ancestor of this block. 
 
bool Invalid(bool ret=false, unsigned int _chRejectCode=0, const std::string &_strRejectReason="", const std::string &_strDebugMessage="")
 
int64_t GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, int flags)
Compute total signature operation cost of a transaction.