Bitcoin
Classes | Enumerations | Functions | Variables
validation.h File Reference
#include <string>
#include <version.h>
#include <consensus/consensus.h>
#include <primitives/transaction.h>
#include <primitives/block.h>

Go to the source code of this file.

Classes

class  CValidationState
 

Enumerations

enum  ValidationInvalidReason {
  ValidationInvalidReason::NONE, ValidationInvalidReason::CONSENSUS, ValidationInvalidReason::RECENT_CONSENSUS_CHANGE, ValidationInvalidReason::CACHED_INVALID,
  ValidationInvalidReason::BLOCK_INVALID_HEADER, ValidationInvalidReason::BLOCK_MUTATED, ValidationInvalidReason::BLOCK_MISSING_PREV, ValidationInvalidReason::BLOCK_INVALID_PREV,
  ValidationInvalidReason::BLOCK_TIME_FUTURE, ValidationInvalidReason::BLOCK_CHECKPOINT, ValidationInvalidReason::TX_NOT_STANDARD, ValidationInvalidReason::TX_MISSING_INPUTS,
  ValidationInvalidReason::TX_PREMATURE_SPEND, ValidationInvalidReason::TX_WITNESS_MUTATED, ValidationInvalidReason::TX_CONFLICT, ValidationInvalidReason::TX_MEMPOOL_POLICY
}
 

Functions

bool IsTransactionReason (ValidationInvalidReason r)
 
bool IsBlockReason (ValidationInvalidReason r)
 
static int64_t GetTransactionWeight (const CTransaction &tx)
 
static int64_t GetBlockWeight (const CBlock &block)
 
static int64_t GetTransactionInputWeight (const CTxIn &txin)
 

Variables

static const unsigned char REJECT_MALFORMED = 0x01
 
static const unsigned char REJECT_INVALID = 0x10
 
static const unsigned char REJECT_OBSOLETE = 0x11
 
static const unsigned char REJECT_DUPLICATE = 0x12
 
static const unsigned char REJECT_NONSTANDARD = 0x40
 
static const unsigned char REJECT_INSUFFICIENTFEE = 0x42
 
static const unsigned char REJECT_CHECKPOINT = 0x43
 

Enumeration Type Documentation

◆ ValidationInvalidReason

A "reason" why something was invalid, suitable for determining whether the provider of the object should be banned/ignored/disconnected/etc. These are much more granular than the rejection codes, which may be more useful for some other use-cases.

Enumerator
NONE 

not actually invalid

CONSENSUS 

invalid by consensus rules (excluding any below reasons)

RECENT_CONSENSUS_CHANGE 

Invalid by a change to consensus rules more recent than SegWit. Currently unused as there are no such consensus rule changes, and any download sources realistically need to support SegWit in order to provide useful data, so differentiating between always-invalid and invalid-by-pre-SegWit-soft-fork is uninteresting.

CACHED_INVALID 

this object was cached as being invalid, but we don't know why

BLOCK_INVALID_HEADER 

invalid proof of work or time too old

BLOCK_MUTATED 

the block's data didn't match the data committed to by the PoW

BLOCK_MISSING_PREV 

We don't have the previous block the checked one is built on.

BLOCK_INVALID_PREV 

A block this one builds on is invalid.

BLOCK_TIME_FUTURE 

block timestamp was > 2 hours in the future (or our clock is bad)

BLOCK_CHECKPOINT 

the block failed to meet one of our checkpoints

TX_NOT_STANDARD 

didn't meet our local policy rules

TX_MISSING_INPUTS 

a transaction was missing some of its inputs

TX_PREMATURE_SPEND 

transaction spends a coinbase too early, or violates locktime/sequence locks

TX_WITNESS_MUTATED 

Transaction might be missing a witness, have a witness prior to SegWit activation, or witness may have been malleated (which includes non-standard witnesses).

TX_CONFLICT 

Tx already in mempool or conflicts with a tx in the chain (if it conflicts with another tx in mempool, we use MEMPOOL_POLICY as it failed to reach the RBF threshold) TODO: Currently this is only used if the transaction already exists in the mempool or on chain, TODO: ATMP's fMissingInputs and a valid CValidationState being used to indicate missing inputs

TX_MEMPOOL_POLICY 

violated mempool's fee/size/descendant/RBF/etc limits

Function Documentation

◆ GetBlockWeight()

static int64_t GetBlockWeight ( const CBlock block)
inlinestatic

◆ GetTransactionInputWeight()

static int64_t GetTransactionInputWeight ( const CTxIn txin)
inlinestatic

◆ GetTransactionWeight()

static int64_t GetTransactionWeight ( const CTransaction tx)
inlinestatic

◆ IsBlockReason()

bool IsBlockReason ( ValidationInvalidReason  r)
inline

◆ IsTransactionReason()

bool IsTransactionReason ( ValidationInvalidReason  r)
inline

Variable Documentation

◆ REJECT_CHECKPOINT

const unsigned char REJECT_CHECKPOINT = 0x43
static

◆ REJECT_DUPLICATE

const unsigned char REJECT_DUPLICATE = 0x12
static

◆ REJECT_INSUFFICIENTFEE

const unsigned char REJECT_INSUFFICIENTFEE = 0x42
static

◆ REJECT_INVALID

const unsigned char REJECT_INVALID = 0x10
static

◆ REJECT_MALFORMED

const unsigned char REJECT_MALFORMED = 0x01
static

"reject" message codes

◆ REJECT_NONSTANDARD

const unsigned char REJECT_NONSTANDARD = 0x40
static

◆ REJECT_OBSOLETE

const unsigned char REJECT_OBSOLETE = 0x11
static