Bitcoin Core  0.18.99
P2P Digital Currency
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>
Include dependency graph for validation.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

class  CValidationState
 Capture information about block/transaction validation. More...
 

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
}
 A "reason" why something was invalid, suitable for determining whether the provider of the object should be banned/ignored/disconnected/etc. More...
 

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
 "reject" message codes More...
 
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

Definition at line 30 of file validation.h.

Function Documentation

◆ GetBlockWeight()

static int64_t GetBlockWeight ( const CBlock block)
inlinestatic

Definition at line 152 of file validation.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTransactionInputWeight()

static int64_t GetTransactionInputWeight ( const CTxIn txin)
inlinestatic

Definition at line 156 of file validation.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetTransactionWeight()

static int64_t GetTransactionWeight ( const CTransaction tx)
inlinestatic

Definition at line 148 of file validation.h.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ IsBlockReason()

bool IsBlockReason ( ValidationInvalidReason  r)
inline

Definition at line 83 of file validation.h.

Here is the caller graph for this function:

◆ IsTransactionReason()

bool IsTransactionReason ( ValidationInvalidReason  r)
inline

Definition at line 70 of file validation.h.

Here is the caller graph for this function:

Variable Documentation

◆ REJECT_CHECKPOINT

const unsigned char REJECT_CHECKPOINT = 0x43
static

Definition at line 23 of file validation.h.

◆ REJECT_DUPLICATE

const unsigned char REJECT_DUPLICATE = 0x12
static

Definition at line 19 of file validation.h.

◆ REJECT_INSUFFICIENTFEE

const unsigned char REJECT_INSUFFICIENTFEE = 0x42
static

Definition at line 22 of file validation.h.

◆ REJECT_INVALID

const unsigned char REJECT_INVALID = 0x10
static

Definition at line 17 of file validation.h.

◆ REJECT_MALFORMED

const unsigned char REJECT_MALFORMED = 0x01
static

"reject" message codes

Definition at line 16 of file validation.h.

◆ REJECT_NONSTANDARD

const unsigned char REJECT_NONSTANDARD = 0x40
static

Definition at line 20 of file validation.h.

◆ REJECT_OBSOLETE

const unsigned char REJECT_OBSOLETE = 0x11
static

Definition at line 18 of file validation.h.