Changeset View
Changeset View
Standalone View
Standalone View
src/validation.h
Show First 20 Lines • Show All 444 Lines • ▼ Show 20 Lines | bool AcceptToMemoryPool(const Config &config, CTxMemPool &pool, | ||||
bool fLimitFree, bool *pfMissingInputs, | bool fLimitFree, bool *pfMissingInputs, | ||||
bool fOverrideMempoolLimit = false, | bool fOverrideMempoolLimit = false, | ||||
const Amount nAbsurdFee = Amount::zero()); | const Amount nAbsurdFee = Amount::zero()); | ||||
/** Convert CValidationState to a human-readable message for logging */ | /** Convert CValidationState to a human-readable message for logging */ | ||||
std::string FormatStateMessage(const CValidationState &state); | std::string FormatStateMessage(const CValidationState &state); | ||||
/** | /** | ||||
* Count ECDSA signature operations the old-fashioned (pre-0.6) way | |||||
* @return number of sigops this transaction's outputs will produce when spent | |||||
* @see CTransaction::FetchInputs | |||||
*/ | |||||
uint64_t GetSigOpCountWithoutP2SH(const CTransaction &tx, uint32_t flags); | |||||
/** | |||||
* Count ECDSA signature operations in pay-to-script-hash inputs. | |||||
* | |||||
* @param[in] mapInputs Map of previous transactions that have outputs we're | |||||
* spending | |||||
* @return maximum number of sigops required to validate this transaction's | |||||
* inputs | |||||
* @see CTransaction::FetchInputs | |||||
*/ | |||||
uint64_t GetP2SHSigOpCount(const CTransaction &tx, | |||||
const CCoinsViewCache &mapInputs, uint32_t flags); | |||||
/** | |||||
* Compute total signature operation of a transaction. | |||||
* @param[in] tx Transaction for which we are computing the cost | |||||
* @param[in] inputs Map of previous transactions that have outputs we're | |||||
* spending | |||||
* @param[in] flags Script verification flags | |||||
* @return Total signature operation cost of tx | |||||
*/ | |||||
uint64_t GetTransactionSigOpCount(const CTransaction &tx, | |||||
const CCoinsViewCache &inputs, | |||||
uint32_t flags); | |||||
/** | |||||
* Check whether all inputs of this transaction are valid (no double spends, | * Check whether all inputs of this transaction are valid (no double spends, | ||||
* scripts & sigs, amounts). This does not modify the UTXO set. | * scripts & sigs, amounts). This does not modify the UTXO set. | ||||
* | * | ||||
* If pvChecks is not nullptr, script checks are pushed onto it instead of being | * If pvChecks is not nullptr, script checks are pushed onto it instead of being | ||||
* performed inline. Any script checks which are not necessary (eg due to script | * performed inline. Any script checks which are not necessary (eg due to script | ||||
* execution cache hits) are, obviously, not pushed onto pvChecks/run. | * execution cache hits) are, obviously, not pushed onto pvChecks/run. | ||||
* | * | ||||
* Setting sigCacheStore/scriptCacheStore to false will remove elements from the | * Setting sigCacheStore/scriptCacheStore to false will remove elements from the | ||||
Show All 15 Lines | |||||
/** | /** | ||||
* Apply the effects of this transaction on the UTXO set represented by view. | * Apply the effects of this transaction on the UTXO set represented by view. | ||||
*/ | */ | ||||
void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight); | void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, int nHeight); | ||||
void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, | void UpdateCoins(CCoinsViewCache &view, const CTransaction &tx, CTxUndo &txundo, | ||||
int nHeight); | int nHeight); | ||||
/** Transaction validation functions */ | |||||
/** | |||||
* Context-independent validity checks for coinbase and non-coinbase | |||||
* transactions. | |||||
*/ | |||||
bool CheckRegularTransaction(const CTransaction &tx, CValidationState &state, | |||||
bool fCheckDuplicateInputs = true); | |||||
bool CheckCoinbase(const CTransaction &tx, CValidationState &state, | |||||
bool fCheckDuplicateInputs = true); | |||||
namespace Consensus { | |||||
/** | |||||
* Check whether all inputs of this transaction are valid (no double spends and | |||||
* amounts). This does not modify the UTXO set. This does not check scripts and | |||||
* sigs. Preconditions: tx.IsCoinBase() is false. | |||||
*/ | |||||
bool CheckTxInputs(const CTransaction &tx, CValidationState &state, | |||||
const CCoinsViewCache &inputs, int nSpendHeight); | |||||
} // namespace Consensus | |||||
/** | /** | ||||
* Test whether the LockPoints height and time are still valid on the current | * Test whether the LockPoints height and time are still valid on the current | ||||
* chain. | * chain. | ||||
*/ | */ | ||||
bool TestLockPointValidity(const LockPoints *lp); | bool TestLockPointValidity(const LockPoints *lp); | ||||
/** | /** | ||||
* Check if transaction is final per BIP 68 sequence numbers and can be included | |||||
* in a block. Consensus critical. Takes as input a list of heights at which | |||||
* tx's inputs (in order) confirmed. | |||||
*/ | |||||
bool SequenceLocks(const CTransaction &tx, int flags, | |||||
std::vector<int> *prevHeights, const CBlockIndex &block); | |||||
/** | |||||
* Check if transaction will be BIP 68 final in the next block to be created. | * Check if transaction will be BIP 68 final in the next block to be created. | ||||
* | * | ||||
* Simulates calling SequenceLocks() with data from the tip of the current | * Simulates calling SequenceLocks() with data from the tip of the current | ||||
* active chain. Optionally stores in LockPoints the resulting height and time | * active chain. Optionally stores in LockPoints the resulting height and time | ||||
* calculated and the hash of the block needed for calculation or skips the | * calculated and the hash of the block needed for calculation or skips the | ||||
* calculation and uses the LockPoints passed in for evaluation. The LockPoints | * calculation and uses the LockPoints passed in for evaluation. The LockPoints | ||||
* should not be considered valid if CheckSequenceLocks returns false. | * should not be considered valid if CheckSequenceLocks returns false. | ||||
* | * | ||||
▲ Show 20 Lines • Show All 61 Lines • ▼ Show 20 Lines | |||||
* Returns true if the provided block is valid (has valid header, | * Returns true if the provided block is valid (has valid header, | ||||
* transactions are valid, block is a valid size, etc.) | * transactions are valid, block is a valid size, etc.) | ||||
*/ | */ | ||||
bool CheckBlock( | bool CheckBlock( | ||||
const Config &Config, const CBlock &block, CValidationState &state, | const Config &Config, const CBlock &block, CValidationState &state, | ||||
BlockValidationOptions validationOptions = BlockValidationOptions()); | BlockValidationOptions validationOptions = BlockValidationOptions()); | ||||
/** | /** | ||||
* Context dependent validity checks for non coinbase transactions. This | |||||
* doesn't check the validity of the transaction against the UTXO set, but | |||||
* simply characteristic that are suceptible to change over time such as feature | |||||
* activation/deactivation and CLTV. | |||||
*/ | |||||
bool ContextualCheckTransaction(const Config &config, const CTransaction &tx, | |||||
CValidationState &state, int nHeight, | |||||
int64_t nLockTimeCutoff, | |||||
int64_t nMedianTimePast); | |||||
/** | |||||
* This is a variant of ContextualCheckTransaction which computes the contextual | * This is a variant of ContextualCheckTransaction which computes the contextual | ||||
* check for a transaction based on the chain tip. | * check for a transaction based on the chain tip. | ||||
* | * | ||||
* See consensus/consensus.h for flag definitions. | * See consensus/consensus.h for flag definitions. | ||||
*/ | */ | ||||
bool ContextualCheckTransactionForCurrentBlock(const Config &config, | bool ContextualCheckTransactionForCurrentBlock(const Config &config, | ||||
const CTransaction &tx, | const CTransaction &tx, | ||||
CValidationState &state, | CValidationState &state, | ||||
▲ Show 20 Lines • Show All 104 Lines • Show Last 20 Lines |