Bitcoin ABC  0.22.13
P2P Digital Currency
Functions | Variables
policy.h File Reference
#include <consensus/consensus.h>
#include <feerate.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

static const Amount DEFAULT_BLOCK_MIN_TX_FEE_PER_KB (1000 *SATOSHI)
 Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code. More...
 
static const CFeeRate MEMPOOL_FULL_FEE_INCREMENT (1000 *SATOSHI)
 Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP 125 replacement. More...
 
static const Amount DUST_RELAY_TX_FEE (1000 *SATOSHI)
 Min feerate for defining dust. More...
 
Amount 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, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
 Check for standard transaction types. More...
 
bool AreInputsStandard (const CTransaction &tx, const CCoinsViewCache &mapInputs, uint32_t flags)
 Check for standard transaction types. More...
 
int64_t GetVirtualTransactionSize (int64_t nSize, int64_t nSigOpCount, unsigned int bytes_per_sigop)
 Compute the virtual transaction size (size, or more if sigops are too dense). More...
 
int64_t GetVirtualTransactionSize (const CTransaction &tx, int64_t nSigOpCount, unsigned int bytes_per_sigop)
 
int64_t GetVirtualTransactionInputSize (const CTxIn &txin, int64_t nSigOpCount, unsigned int bytes_per_sigop)
 
static int64_t GetVirtualTransactionSize (const CTransaction &tx)
 
static int64_t GetVirtualTransactionInputSize (const CTxIn &tx)
 

Variables

static const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE = 2 * ONE_MEGABYTE
 Default for -blockmaxsize, which controls the maximum size of block the mining code will create. 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_TX_IN_SCRIPT_SIG_SIZE = 1650
 Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed keys (remember the 520 byte limit on redeemScript size). 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_BYTES_PER_SIGOP = 50
 Default for -bytespersigop . More...
 
static const bool DEFAULT_PERMIT_BAREMULTISIG = true
 Default for -permitbaremultisig. More...
 
static constexpr uint32_t MANDATORY_SCRIPT_VERIFY_FLAGS
 When transactions fail script evaluations under standard flags, this flagset influences the decision of whether to drop them or to also ban the originator (see CheckInputScripts). More...
 
static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS
 Standard script verification flags that standard transactions will comply with. More...
 
static constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS
 For convenience, standard but not mandatory verify flags. More...
 
static constexpr uint32_t STANDARD_LOCKTIME_VERIFY_FLAGS
 Used as the flags parameter to sequence and nLocktime checks in non-consensus code. More...
 

Function Documentation

◆ AreInputsStandard()

bool AreInputsStandard ( const CTransaction tx,
const CCoinsViewCache mapInputs,
uint32_t  flags 
)

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

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

◆ DEFAULT_BLOCK_MIN_TX_FEE_PER_KB()

static const Amount DEFAULT_BLOCK_MIN_TX_FEE_PER_KB ( 1000 *  SATOSHI)
static

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

Here is the caller graph for this function:

◆ DUST_RELAY_TX_FEE()

static const Amount DUST_RELAY_TX_FEE ( 1000 *  SATOSHI)
static

Min feerate for defining dust.

Historically this has been the same as 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.

Here is the caller graph for this function:

◆ GetDustThreshold()

Amount GetDustThreshold ( const CTxOut txout,
const CFeeRate dustRelayFee 
)

"Dust" is defined in terms of dustRelayFee, which has units satoshis-per-kilobyte. If you'd pay more than 1/3 in fees to spend something, then we consider it dust. A typical spendable txout is 34 bytes big, and will need a CTxIn of at least 148 bytes to spend: so dust is a spendable txout less than 546*dustRelayFee/1000 (in satoshis).

Definition at line 14 of file policy.cpp.

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

◆ GetVirtualTransactionInputSize() [1/2]

int64_t GetVirtualTransactionInputSize ( const CTxIn txin,
int64_t  nSigOpCount,
unsigned int  bytes_per_sigop 
)

Definition at line 172 of file policy.cpp.

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

◆ GetVirtualTransactionInputSize() [2/2]

static int64_t GetVirtualTransactionInputSize ( const CTxIn tx)
inlinestatic

Definition at line 150 of file policy.h.

Here is the call graph for this function:

◆ GetVirtualTransactionSize() [1/3]

int64_t GetVirtualTransactionSize ( int64_t  nSize,
int64_t  nSigOpCount,
unsigned int  bytes_per_sigop 
)

Compute the virtual transaction size (size, or more if sigops are too dense).

Definition at line 161 of file policy.cpp.

Here is the caller graph for this function:

◆ GetVirtualTransactionSize() [2/3]

int64_t GetVirtualTransactionSize ( const CTransaction tx,
int64_t  nSigOpCount,
unsigned int  bytes_per_sigop 
)

Definition at line 166 of file policy.cpp.

Here is the call graph for this function:

◆ GetVirtualTransactionSize() [3/3]

static int64_t GetVirtualTransactionSize ( const CTransaction tx)
inlinestatic

Definition at line 146 of file policy.h.

Here is the call graph for this function:

◆ IsDust()

bool IsDust ( const CTxOut txout,
const CFeeRate dustRelayFee 
)

Definition at line 34 of file policy.cpp.

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

◆ IsStandard()

bool IsStandard ( const CScript scriptPubKey,
txnouttype whichType 
)

Definition at line 38 of file policy.cpp.

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

◆ IsStandardTx()

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

Check for standard transaction types.

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

Definition at line 69 of file policy.cpp.

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

◆ MEMPOOL_FULL_FEE_INCREMENT()

static const CFeeRate MEMPOOL_FULL_FEE_INCREMENT ( 1000 *  SATOSHI)
static

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

Here is the caller graph for this function:

Variable Documentation

◆ DEFAULT_BYTES_PER_SIGOP

const unsigned int DEFAULT_BYTES_PER_SIGOP = 50
static

Default for -bytespersigop .

Definition at line 57 of file policy.h.

◆ DEFAULT_MAX_GENERATED_BLOCK_SIZE

const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE = 2 * ONE_MEGABYTE
static

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

Definition at line 24 of file policy.h.

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

◆ DEFAULT_PERMIT_BAREMULTISIG

const bool DEFAULT_PERMIT_BAREMULTISIG = true
static

Default for -permitbaremultisig.

Definition at line 59 of file policy.h.

◆ MANDATORY_SCRIPT_VERIFY_FLAGS

constexpr uint32_t MANDATORY_SCRIPT_VERIFY_FLAGS
static
Initial value:

When transactions fail script evaluations under standard flags, this flagset influences the decision of whether to drop them or to also ban the originator (see CheckInputScripts).

Definition at line 74 of file policy.h.

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

◆ MAX_TX_IN_SCRIPT_SIG_SIZE

const unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650
static

Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed keys (remember the 520 byte limit on redeemScript size).

That works out to a (15*(33+1))+3=513 byte redeemScript, 513+1+15*(73+1)+3=1627 bytes of scriptSig, which we round off to 1650 bytes for some minor future-proofing. That's also enough to spend a 20-of-20 CHECKMULTISIG scriptPubKey, though such a scriptPubKey is not considered standard.

Definition at line 43 of file policy.h.

◆ STANDARD_LOCKTIME_VERIFY_FLAGS

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

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

Definition at line 109 of file policy.h.

◆ STANDARD_NOT_MANDATORY_VERIFY_FLAGS

constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS
static
Initial value:
=
static constexpr uint32_t MANDATORY_SCRIPT_VERIFY_FLAGS
When transactions fail script evaluations under standard flags, this flagset influences the decision ...
Definition: policy.h:74
static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
Definition: policy.h:91

For convenience, standard but not mandatory verify flags.

Definition at line 102 of file policy.h.

◆ STANDARD_SCRIPT_VERIFY_FLAGS

constexpr uint32_t 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.

Note that the actual mempool validation flags may be slightly different (see GetStandardScriptFlags), however this constant should be set to the most restrictive flag set that applies in the current / next upgrade, since it is used in numerous parts of the codebase that are unable to access the contextual information of which upgrades are currently active.

Definition at line 91 of file policy.h.