Dash Core  0.12.2.1
P2P Digital Currency
policy.h File Reference
#include "consensus/consensus.h"
#include "script/interpreter.h"
#include "script/standard.h"
#include <string>

Go to the source code of this file.

Functions

bool IsStandard (const CScript &scriptPubKey, txnouttype &whichType)
 
bool IsStandardTx (const CTransaction &tx, std::string &reason)
 
bool AreInputsStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs)
 

Variables

static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000
 
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0
 
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 10000
 
static const unsigned int MAX_STANDARD_TX_SIZE = 100000
 
static const unsigned int MAX_P2SH_SIGOPS = 15
 
static const unsigned int MAX_STANDARD_TX_SIGOPS = 4000
 
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300
 
static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
 
static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS
 
static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS
 

Function Documentation

◆ AreInputsStandard()

bool AreInputsStandard ( const CTransaction tx,
const CCoinsViewCache mapInputs 
)

Check for standard transaction types

Parameters
[in]mapInputsMap of previous transactions that have outputs we're spending
Returns
True if all inputs (scriptSigs) use only standard transaction forms

Definition at line 123 of file policy.cpp.

Referenced by AcceptToMemoryPoolWorker().

◆ IsStandard()

bool IsStandard ( const CScript scriptPubKey,
txnouttype whichType 
)

Check transaction inputs to mitigate two potential denial-of-service attacks:

  1. scriptSigs with extra data stuffed into them, not consumed by scriptPubKey (or P2SH script)
  2. P2SH scripts with a crazy number of expensive CHECKSIG/CHECKMULTISIG operations

Check transaction inputs, and make sure any pay-to-script-hash transactions are evaluating IsStandard scripts

Why bother? To avoid denial-of-service attacks; an attacker can submit a standard HASH... OP_EQUAL transaction, which will get accepted into blocks. The redemption script can be anything; an attacker could use a very expensive-to-check-upon-redemption script like: DUP CHECKSIG DROP ... repeated 100 times... OP_1

Definition at line 37 of file policy.cpp.

Referenced by IsStandardTx().

◆ IsStandardTx()

bool IsStandardTx ( const CTransaction tx,
std::string &  reason 
)

Check for standard transaction types

Returns
True if all outputs (scriptPubKeys) use only standard transaction forms

Definition at line 59 of file policy.cpp.

Referenced by AcceptToMemoryPoolWorker().

Variable Documentation

◆ DEFAULT_BLOCK_MAX_SIZE

const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000
static

Default for -blockmaxsize and -blockminsize, which control the range of sizes the mining code will create

Definition at line 18 of file policy.h.

Referenced by CreateNewBlock(), and HelpMessage().

◆ DEFAULT_BLOCK_MIN_SIZE

const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0
static

Definition at line 19 of file policy.h.

Referenced by CreateNewBlock(), and HelpMessage().

◆ DEFAULT_BLOCK_PRIORITY_SIZE

const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 10000
static

Default for -blockprioritysize, maximum space for zero/low-fee transactions

Definition at line 21 of file policy.h.

Referenced by CreateNewBlock(), and HelpMessage().

◆ DEFAULT_MAX_MEMPOOL_SIZE

const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300
static

◆ MAX_P2SH_SIGOPS

const unsigned int MAX_P2SH_SIGOPS = 15
static

Maximum number of signature check operations in an IsStandard() P2SH script

Definition at line 25 of file policy.h.

Referenced by AreInputsStandard().

◆ MAX_STANDARD_TX_SIGOPS

const unsigned int MAX_STANDARD_TX_SIGOPS = 4000
static

The maximum number of sigops we're willing to relay/mine in a single tx

Definition at line 27 of file policy.h.

Referenced by AcceptToMemoryPoolWorker().

◆ MAX_STANDARD_TX_SIZE

const unsigned int MAX_STANDARD_TX_SIZE = 100000
static

The maximum size for transactions we're willing to relay/mine

Definition at line 23 of file policy.h.

Referenced by ContextualCheckBlock(), ContextualCheckTransaction(), CWallet::CreateTransaction(), and IsStandardTx().

◆ STANDARD_LOCKTIME_VERIFY_FLAGS

const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS
static
Initial value:

Used as the flags parameter to sequence and nLocktime checks in non-consensus code.

Definition at line 50 of file policy.h.

Referenced by AcceptToMemoryPoolWorker(), ActivateBestChainStep(), CreateNewBlock(), and InvalidateBlock().

◆ STANDARD_NOT_MANDATORY_VERIFY_FLAGS

const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS
static

For convenience, standard but not mandatory verify flags.

Definition at line 47 of file policy.h.

Referenced by CheckInputs().

◆ STANDARD_SCRIPT_VERIFY_FLAGS

const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
static