Dash Core Source Documentation (0.16.0.1)

Find detailed information regarding the Dash Core source code.

policy.h File Reference
#include <consensus/consensus.h>
#include <policy/feerate.h>
#include <script/interpreter.h>
#include <script/standard.h>
#include <string>
+ Include dependency graph for policy.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

CAmount GetDustThreshold (const CTxOut &txout, const CFeeRate &dustRelayFee)
 
bool IsDust (const CTxOut &txout, const CFeeRate &dustRelayFee)
 
bool IsStandard (const CScript &scriptPubKey, txnouttype &whichType)
 
bool IsStandardTx (const CTransaction &tx, std::string &reason)
 Check for standard transaction types. More...
 
bool AreInputsStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs)
 Check for standard transaction types. More...
 

Variables

static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 2000000
 Default for -blockmaxsize, which controls the maximum size of block the mining code will create. More...
 
static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000
 Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code. More...
 
static const unsigned int MAX_STANDARD_TX_SIZE = 100000
 The maximum size for transactions we're willing to relay/mine. More...
 
static const unsigned int MAX_P2SH_SIGOPS = 15
 Maximum number of signature check operations in an IsStandard() P2SH script. More...
 
static const unsigned int MAX_STANDARD_TX_SIGOPS = 4000
 The maximum number of sigops we're willing to relay/mine in a single tx. More...
 
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300
 Default for -maxmempool, maximum megabytes of mempool memory usage. More...
 
static const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000
 Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement. More...
 
static const unsigned int DUST_RELAY_TX_FEE = 3000
 Min feerate for defining dust. More...
 
static const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
 Standard script verification flags that standard transactions will comply with. More...
 
static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS
 For convenience, standard but not mandatory verify flags. More...
 
static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS
 Used as the flags parameter to sequence and nLocktime checks in non-consensus code. More...
 
CFeeRate incrementalRelayFee
 
CFeeRate dustRelayFee
 

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

Check for standard transaction types.

  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

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 142 of file policy.cpp.

References CCoinsViewCache::AccessCoin(), EvalScript(), CTransaction::IsCoinBase(), MAX_P2SH_SIGOPS, Coin::out, SCRIPT_VERIFY_NONE, CTxOut::scriptPubKey, SIGVERSION_BASE, Solver(), TX_SCRIPTHASH, and CTransaction::vin.

Referenced by AcceptToMemoryPoolWorker(), and CCoinsCaching().

◆ GetDustThreshold()

CAmount GetDustThreshold ( const CTxOut txout,
const CFeeRate dustRelayFee 
)

Definition at line 17 of file policy.cpp.

References CFeeRate::GetFee(), GetSerializeSize(), CScript::IsUnspendable(), CTxOut::scriptPubKey, and SER_DISK.

Referenced by IsDust().

◆ IsDust()

◆ IsStandard()

bool IsStandard ( const CScript scriptPubKey,
txnouttype whichType 
)

◆ IsStandardTx()

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

Variable Documentation

◆ DEFAULT_BLOCK_MAX_SIZE

const unsigned int DEFAULT_BLOCK_MAX_SIZE = 2000000
static

Default for -blockmaxsize, which controls the maximum size of block the mining code will create.

Definition at line 20 of file policy.h.

Referenced by DefaultOptions(), HelpMessage(), and BlockAssembler::Options::Options().

◆ DEFAULT_BLOCK_MIN_TX_FEE

const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000
static

Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code.

Definition at line 22 of file policy.h.

Referenced by DefaultOptions(), HelpMessage(), and BlockAssembler::Options::Options().

◆ DEFAULT_INCREMENTAL_RELAY_FEE

const unsigned int DEFAULT_INCREMENTAL_RELAY_FEE = 1000
static

Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement.

Definition at line 32 of file policy.h.

Referenced by HelpMessage().

◆ DEFAULT_MAX_MEMPOOL_SIZE

const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300
static

Default for -maxmempool, maximum megabytes of mempool memory usage.

Definition at line 30 of file policy.h.

Referenced by AcceptToMemoryPoolWorker(), AppInitMain(), AppInitParameterInteraction(), FlushStateToDisk(), GetMinimumFee(), HelpMessage(), mempoolInfoToJSON(), and UpdateMempoolForReorg().

◆ DUST_RELAY_TX_FEE

const unsigned int DUST_RELAY_TX_FEE = 3000
static

Min feerate for defining dust.

Historically this has been based on the minRelayTxFee, however changing the dust limit changes which transactions are standard and should be done with care and ideally rarely. It makes sense to only increase the dust limit after prior releases were already not creating outputs below the new threshold

Definition at line 38 of file policy.h.

Referenced by HelpMessage().

◆ dustRelayFee

◆ incrementalRelayFee

CFeeRate incrementalRelayFee

◆ 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 26 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 28 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 24 of file policy.h.

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

◆ STANDARD_LOCKTIME_VERIFY_FLAGS

const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS
static
Initial value:
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
Definition: consensus.h:28
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST
Use GetMedianTimePast() instead of nTime for end point timestamp.
Definition: consensus.h:30

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

Definition at line 60 of file policy.h.

Referenced by AcceptToMemoryPoolWorker(), BlockAssembler::CreateNewBlock(), and UpdateMempoolForReorg().

◆ 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 57 of file policy.h.

Referenced by CheckInputs().

◆ STANDARD_SCRIPT_VERIFY_FLAGS

const unsigned int STANDARD_SCRIPT_VERIFY_FLAGS
static
Initial value:

Standard script verification flags that standard transactions will comply with.

However scripts violating these flags may still be present in valid blocks and we must accept those blocks.

Definition at line 44 of file policy.h.

Referenced by AcceptToMemoryPoolWorker(), MutateTxSign(), ProduceSignature(), and signrawtransaction().

Released under the MIT license