32 for (
const auto& txin : tx.
vin) {
41 assert(prevHeights.size() == tx.
vin.size());
49 int64_t nMinTime = -1;
54 bool fEnforceBIP68 =
static_cast<uint32_t
>(tx.
nVersion) >= 2
60 return std::make_pair(nMinHeight, nMinTime);
63 for (
size_t txinIndex = 0; txinIndex < tx.
vin.size(); txinIndex++) {
64 const CTxIn& txin = tx.
vin[txinIndex];
71 prevHeights[txinIndex] = 0;
75 int nCoinHeight = prevHeights[txinIndex];
98 return std::make_pair(nMinHeight, nMinTime);
105 if (lockPair.first >= block.
nHeight || lockPair.second >= nBlockTime)
118 unsigned int nSigOps = 0;
119 for (
const auto& txin : tx.
vin)
121 nSigOps += txin.scriptSig.GetSigOpCount(
false);
123 for (
const auto& txout : tx.
vout)
125 nSigOps += txout.scriptPubKey.GetSigOpCount(
false);
135 unsigned int nSigOps = 0;
136 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
141 if (prevout.scriptPubKey.IsPayToScriptHash())
158 for (
unsigned int i = 0; i < tx.
vin.size(); i++)
173 strprintf(
"%s: inputs missing/spent", __func__));
177 for (
unsigned int i = 0; i < tx.
vin.size(); ++i) {
185 strprintf(
"tried to spend coinbase at depth %d", nSpendHeight - coin.
nHeight));
196 if (nValueIn < value_out) {
202 const CAmount txfee_aux = nValueIn - value_out;
unsigned int GetSigOpCount(bool fAccurate) const
Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops.
bool IsSpent() const
Either this coin never existed (see e.g.
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
const Coin & AccessCoin(const COutPoint &output) const
Return a reference to Coin in the cache, or coinEmpty if not found.
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
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
transaction spends a coinbase too early, or violates locktime/sequence locks
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
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.
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::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...
int64_t GetMedianTimePast() const
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
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 GetTransactionSigOpCost(const CTransaction &tx, const CCoinsViewCache &inputs, int flags)
Compute total signature operation cost of a transaction.