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
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++)
164 strprintf(
"%s: inputs missing/spent", __func__));
168 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
176 strprintf(
"tried to spend coinbase at depth %d", nSpendHeight - coin.
nHeight));
187 if (nValueIn < value_out) {
193 const CAmount txfee_aux = nValueIn - value_out;
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
invalid by consensus rules
bool CheckTxInputs(const CTransaction &tx, TxValidationState &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...
static const int WITNESS_SCALE_FACTOR
CBlockIndex * pprev
pointer to the index of the predecessor of this block
size_t CountWitnessSigOps(const CScript &scriptSig, const CScript &scriptPubKey, const CScriptWitness *witness, unsigned int flags)
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...
transaction was missing some of its inputs
static const uint32_t SEQUENCE_FINAL
bool MoneyRange(const CAmount &nValue)
static const uint32_t SEQUENCE_LOCKTIME_DISABLE_FLAG
bool HaveInputs(const CTransaction &tx) const
Check whether all prevouts of the transaction are present in the UTXO set represented by this view...
CTxOut out
unspent transaction output
static const int COINBASE_MATURITY
Coinbase transaction outputs can only be spent after this number of new blocks (network rule) ...
static const int SEQUENCE_LOCKTIME_GRANULARITY
std::string FormatMoney(const CAmount &n)
Money parsing/formatting utilities.
transaction spends a coinbase too early, or violates locktime/sequence locks
const std::vector< CTxIn > vin
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 ...
bool Invalid(Result result, const std::string &reject_reason="", const std::string &debug_message="")
An input of a transaction.
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
CAmount GetValueOut() const
const std::vector< CTxOut > vout
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
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::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...
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 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...
static const unsigned int LOCKTIME_THRESHOLD
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.
int64_t GetMedianTimePast() const
int64_t GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, int flags)
Compute total signature operation cost of a transaction.