Bitcoin ABC  0.24.7
P2P Digital Currency
policy.h
Go to the documentation of this file.
1 // Copyright (c) 2009-2010 Satoshi Nakamoto
2 // Copyright (c) 2009-2016 The Bitcoin Core developers
3 // Distributed under the MIT software license, see the accompanying
4 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
5 
6 #ifndef BITCOIN_POLICY_POLICY_H
7 #define BITCOIN_POLICY_POLICY_H
8 
9 #include <consensus/consensus.h>
10 #include <feerate.h>
11 #include <script/standard.h>
12 
13 #include <string>
14 
15 class CCoinsViewCache;
16 class CTransaction;
17 class CTxIn;
18 class CTxOut;
19 
24 static const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE = 2 * ONE_MEGABYTE;
33 static const unsigned int MAX_STANDARD_TX_SIZE = 100000;
34 
43 static const unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650;
44 
48 static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE = 300;
53 static const CFeeRate MEMPOOL_FULL_FEE_INCREMENT(1000 * SATOSHI);
57 static const unsigned int DEFAULT_BYTES_PER_SIGOP = 50;
59 static const bool DEFAULT_PERMIT_BAREMULTISIG = true;
67 static const Amount DUST_RELAY_TX_FEE(1000 * SATOSHI);
68 
74 static constexpr uint32_t MANDATORY_SCRIPT_VERIFY_FLAGS =
79 
91 static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS =
98 
102 static constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS =
104 
109 static constexpr uint32_t STANDARD_LOCKTIME_VERIFY_FLAGS =
111 
112 Amount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFee);
113 
114 bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFee);
115 
116 bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType);
117 
123 bool IsStandardTx(const CTransaction &tx, bool permit_bare_multisig,
124  const CFeeRate &dust_relay_fee, std::string &reason);
125 
132 bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs,
133  uint32_t flags);
134 
139 int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigOpCount,
140  unsigned int bytes_per_sigop);
141 int64_t GetVirtualTransactionSize(const CTransaction &tx, int64_t nSigOpCount,
142  unsigned int bytes_per_sigop);
143 int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigOpCount,
144  unsigned int bytes_per_sigop);
145 
146 static inline int64_t GetVirtualTransactionSize(const CTransaction &tx) {
147  return GetVirtualTransactionSize(tx, 0, 0);
148 }
149 
150 static inline int64_t GetVirtualTransactionInputSize(const CTxIn &tx) {
151  return GetVirtualTransactionInputSize(tx, 0, 0);
152 }
153 
154 #endif // BITCOIN_POLICY_POLICY_H
CTxIn
An input of a transaction.
Definition: transaction.h:61
SCRIPT_VERIFY_SIGPUSHONLY
@ SCRIPT_VERIFY_SIGPUSHONLY
Definition: script_flags.h:35
feerate.h
SCRIPT_VERIFY_CLEANSTACK
@ SCRIPT_VERIFY_CLEANSTACK
Definition: script_flags.h:63
DEFAULT_MAX_GENERATED_BLOCK_SIZE
static const uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE
Default for -blockmaxsize, which controls the maximum size of block the mining code will create.
Definition: policy.h:24
TxoutType
TxoutType
Definition: standard.h:85
flags
int flags
Definition: bitcoin-tx.cpp:532
SCRIPT_ENFORCE_SIGCHECKS
@ SCRIPT_ENFORCE_SIGCHECKS
Definition: script_flags.h:111
IsStandardTx
bool IsStandardTx(const CTransaction &tx, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
Definition: policy.cpp:69
SCRIPT_VERIFY_MINIMALDATA
@ SCRIPT_VERIFY_MINIMALDATA
Definition: script_flags.h:43
LOCKTIME_MEDIAN_TIME_PAST
static constexpr unsigned int LOCKTIME_MEDIAN_TIME_PAST
Use GetMedianTimePast() instead of nTime for end point timestamp.
Definition: consensus.h:40
DUST_RELAY_TX_FEE
static const Amount DUST_RELAY_TX_FEE(1000 *SATOSHI)
Min feerate for defining dust.
CFeeRate
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:194
IsDust
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:34
SCRIPT_DISALLOW_SEGWIT_RECOVERY
@ SCRIPT_DISALLOW_SEGWIT_RECOVERY
Definition: script_flags.h:98
LOCKTIME_VERIFY_SEQUENCE
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
Definition: consensus.h:38
SATOSHI
static constexpr Amount SATOSHI
Definition: amount.h:153
nSigOpCount
unsigned int nSigOpCount
Definition: mempool_eviction.cpp:15
STANDARD_LOCKTIME_VERIFY_FLAGS
static constexpr uint32_t STANDARD_LOCKTIME_VERIFY_FLAGS
Used as the flags parameter to sequence and nLocktime checks in non-consensus code.
Definition: policy.h:109
GetVirtualTransactionSize
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: policy.cpp:162
CTxOut
An output of a transaction.
Definition: transaction.h:130
SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
@ SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
Definition: script_flags.h:73
CTxOut::scriptPubKey
CScript scriptPubKey
Definition: transaction.h:133
consensus.h
MAX_TX_IN_SCRIPT_SIG_SIZE
static const unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE
Biggest 'standard' txin is a 15-of-15 P2SH multisig with compressed keys (remember the 520 byte limit...
Definition: policy.h:43
standard.h
SCRIPT_VERIFY_P2SH
@ SCRIPT_VERIFY_P2SH
Definition: script_flags.h:16
SCRIPT_VERIFY_LOW_S
@ SCRIPT_VERIFY_LOW_S
Definition: script_flags.h:31
STANDARD_NOT_MANDATORY_VERIFY_FLAGS
static constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS
For convenience, standard but not mandatory verify flags.
Definition: policy.h:102
DEFAULT_PERMIT_BAREMULTISIG
static const bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
Definition: policy.h:59
Amount
Definition: amount.h:19
IsStandard
bool IsStandard(const CScript &scriptPubKey, TxoutType &whichType)
Definition: policy.cpp:38
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:430
ONE_MEGABYTE
static const uint64_t ONE_MEGABYTE
1MB
Definition: consensus.h:12
DEFAULT_BLOCK_MIN_TX_FEE_PER_KB
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 min...
SCRIPT_ENABLE_SCHNORR_MULTISIG
@ SCRIPT_ENABLE_SCHNORR_MULTISIG
Definition: script_flags.h:102
AreInputsStandard
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs, uint32_t flags)
Check for standard transaction types.
Definition: policy.cpp:142
SCRIPT_VERIFY_CHECKDATASIG_SIGOPS
@ SCRIPT_VERIFY_CHECKDATASIG_SIGOPS
Definition: script_flags.h:94
STANDARD_SCRIPT_VERIFY_FLAGS
static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
Definition: policy.h:91
CCoinsViewCache
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:231
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
@ SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
Definition: script_flags.h:68
SCRIPT_VERIFY_INPUT_SIGCHECKS
@ SCRIPT_VERIFY_INPUT_SIGCHECKS
Definition: script_flags.h:108
MANDATORY_SCRIPT_VERIFY_FLAGS
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
MAX_STANDARD_TX_SIZE
static const unsigned int MAX_STANDARD_TX_SIZE
The maximum size for transactions we're willing to relay/mine.
Definition: policy.h:33
SCRIPT_VERIFY_NULLFAIL
@ SCRIPT_VERIFY_NULLFAIL
Definition: script_flags.h:81
SCRIPT_ENABLE_SIGHASH_FORKID
@ SCRIPT_ENABLE_SIGHASH_FORKID
Definition: script_flags.h:85
DEFAULT_BYTES_PER_SIGOP
static const unsigned int DEFAULT_BYTES_PER_SIGOP
Default for -bytespersigop .
Definition: policy.h:57
SCRIPT_VERIFY_STRICTENC
@ SCRIPT_VERIFY_STRICTENC
Definition: script_flags.h:22
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
Definition: script_flags.h:53
GetVirtualTransactionInputSize
int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigOpCount, unsigned int bytes_per_sigop)
Definition: policy.cpp:173
SCRIPT_VERIFY_DERSIG
@ SCRIPT_VERIFY_DERSIG
Definition: script_flags.h:26
dustRelayFee
CFeeRate dustRelayFee
Definition: settings.cpp:11
DEFAULT_MAX_MEMPOOL_SIZE
static const unsigned int DEFAULT_MAX_MEMPOOL_SIZE
Default for -maxmempool, maximum megabytes of mempool memory usage.
Definition: policy.h:48
GetDustThreshold
Amount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:14
MEMPOOL_FULL_FEE_INCREMENT
static const CFeeRate MEMPOOL_FULL_FEE_INCREMENT(1000 *SATOSHI)
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...