Bitcoin ABC 0.30.5
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
10#include <feerate.h>
11#include <script/standard.h>
12
13#include <optional>
14#include <string>
15
16class CCoinsViewCache;
17class CTransaction;
18class CTxIn;
19class CTxOut;
20
25static constexpr uint64_t DEFAULT_MAX_GENERATED_BLOCK_SIZE{2 * ONE_MEGABYTE};
34static constexpr unsigned int MAX_STANDARD_TX_SIZE{100000};
35
44static constexpr unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE{1650};
45
54static constexpr unsigned int DEFAULT_BYTES_PER_SIGCHECK{50};
56static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
64static constexpr Amount DUST_RELAY_TX_FEE(1000 * SATOSHI);
65
68
74static constexpr uint32_t MANDATORY_SCRIPT_VERIFY_FLAGS{
79
91static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS{
97
101static constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS{
102 STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS};
103
108static constexpr uint32_t STANDARD_LOCKTIME_VERIFY_FLAGS{
110
111Amount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFee);
112
113bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFee);
114
116 const std::optional<unsigned> &max_datacarrier_bytes,
117 TxoutType &whichType);
118
124bool IsStandardTx(const CTransaction &tx,
125 const std::optional<unsigned> &max_datacarrier_bytes,
126 bool permit_bare_multisig, const CFeeRate &dust_relay_fee,
127 std::string &reason);
128
135bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs,
136 uint32_t flags);
137
142int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigChecks,
143 unsigned int bytes_per_sigCheck);
144int64_t GetVirtualTransactionSize(const CTransaction &tx, int64_t nSigChecks,
145 unsigned int bytes_per_sigCheck);
146int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigChecks,
147 unsigned int bytes_per_sigChecks);
148
149static inline int64_t GetVirtualTransactionSize(const CTransaction &tx) {
150 return GetVirtualTransactionSize(tx, 0, 0);
151}
152
153static inline int64_t GetVirtualTransactionInputSize(const CTxIn &tx) {
154 return GetVirtualTransactionInputSize(tx, 0, 0);
155}
156
157#endif // BITCOIN_POLICY_POLICY_H
static constexpr Amount SATOSHI
Definition: amount.h:143
int flags
Definition: bitcoin-tx.cpp:541
CCoinsView that adds a memory cache for transactions to another CCoinsView.
Definition: coins.h:221
Fee rate in satoshis per kilobyte: Amount / kB.
Definition: feerate.h:21
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:431
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:192
An input of a transaction.
Definition: transaction.h:59
An output of a transaction.
Definition: transaction.h:128
CScript scriptPubKey
Definition: transaction.h:131
static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE
Flags for nSequence and nLockTime locks.
Definition: consensus.h:38
static const uint64_t ONE_MEGABYTE
1MB
Definition: consensus.h:12
unsigned int nSigChecks
static constexpr CFeeRate MEMPOOL_FULL_FEE_INCREMENT(1000 *SATOSHI)
Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or BIP...
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 unsigned int MAX_STANDARD_TX_SIZE
The maximum size for transactions we're willing to relay/mine.
Definition: policy.h:34
static constexpr 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:44
static constexpr 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:25
bool IsStandard(const CScript &scriptPubKey, const std::optional< unsigned > &max_datacarrier_bytes, TxoutType &whichType)
Definition: policy.cpp:38
static constexpr Amount DUST_RELAY_TX_FEE(1000 *SATOSHI)
Min feerate for defining dust.
bool AreInputsStandard(const CTransaction &tx, const CCoinsViewCache &mapInputs, uint32_t flags)
Check for standard transaction types.
Definition: policy.cpp:145
static constexpr bool DEFAULT_PERMIT_BAREMULTISIG
Default for -permitbaremultisig.
Definition: policy.h:56
static constexpr Amount DEFAULT_MIN_RELAY_TX_FEE_PER_KB(1000 *SATOSHI)
Default for -minrelaytxfee, minimum relay fee for transactions.
static constexpr unsigned int DEFAULT_BYTES_PER_SIGCHECK
Default for -bytespersigcheck .
Definition: policy.h:54
int64_t GetVirtualTransactionInputSize(const CTxIn &txin, int64_t nSigChecks, unsigned int bytes_per_sigChecks)
Definition: policy.cpp:176
static constexpr uint32_t STANDARD_SCRIPT_VERIFY_FLAGS
Standard script verification flags that standard transactions will comply with.
Definition: policy.h:91
bool IsDust(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:34
bool IsStandardTx(const CTransaction &tx, const std::optional< unsigned > &max_datacarrier_bytes, bool permit_bare_multisig, const CFeeRate &dust_relay_fee, std::string &reason)
Check for standard transaction types.
Definition: policy.cpp:66
Amount GetDustThreshold(const CTxOut &txout, const CFeeRate &dustRelayFee)
Definition: policy.cpp:14
static constexpr 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...
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:108
static constexpr uint32_t STANDARD_NOT_MANDATORY_VERIFY_FLAGS
For convenience, standard but not mandatory verify flags.
Definition: policy.h:101
int64_t GetVirtualTransactionSize(int64_t nSize, int64_t nSigChecks, unsigned int bytes_per_sigCheck)
Compute the virtual transaction size (size, or more if sigChecks are too dense).
Definition: policy.cpp:165
@ SCRIPT_VERIFY_P2SH
Definition: script_flags.h:16
@ SCRIPT_VERIFY_SIGPUSHONLY
Definition: script_flags.h:35
@ SCRIPT_VERIFY_LOW_S
Definition: script_flags.h:31
@ SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY
Definition: script_flags.h:68
@ SCRIPT_ENABLE_SCHNORR_MULTISIG
Definition: script_flags.h:97
@ SCRIPT_VERIFY_STRICTENC
Definition: script_flags.h:22
@ SCRIPT_VERIFY_NULLFAIL
Definition: script_flags.h:81
@ SCRIPT_VERIFY_DERSIG
Definition: script_flags.h:26
@ SCRIPT_ENFORCE_SIGCHECKS
Definition: script_flags.h:106
@ SCRIPT_VERIFY_CLEANSTACK
Definition: script_flags.h:63
@ SCRIPT_VERIFY_MINIMALDATA
Definition: script_flags.h:43
@ SCRIPT_DISALLOW_SEGWIT_RECOVERY
Definition: script_flags.h:93
@ SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS
Definition: script_flags.h:53
@ SCRIPT_VERIFY_CHECKSEQUENCEVERIFY
Definition: script_flags.h:73
@ SCRIPT_ENABLE_SIGHASH_FORKID
Definition: script_flags.h:85
@ SCRIPT_VERIFY_INPUT_SIGCHECKS
Definition: script_flags.h:103
TxoutType
Definition: standard.h:38
Definition: amount.h:19