Merge bitcoin/bitcoin#35852: scripted-diff: Use inline const(expr) over static constexpr in headers
What changed, and why it matters
This is a large but purely mechanical code cleanup in Bitcoin Core. It changes how constants are declared in header files from older C++ styles (static const, static constexpr) to the modern C++17 inline constexpr/inline const form. The pull request author explicitly states this is a refactor that does not change behavior, only makes the release binary slightly smaller by ensuring each constant has a single address across the program. No security vulnerability is present.
No security action needed. Treat as a normal maintainability refactor. Standard CI/build verification is sufficient.
Security signals we found
No strong security signals were identified.
Evidence from the diff
The merge commit applies a scripted diff across 102 source files, replacing static const, static constexpr, and plain constexpr variable declarations in headers with inline constexpr or inline const. It also updates the seed-generation Python script and makes the CFeeRate integral constructor constexpr. These are C++17 best-practice changes that avoid duplicate symbol definitions across translation units and can reduce binary size. The diff contains no logic changes, no new functionality, no boundary/overflow changes, and no changes to consensus, networking, or cryptographic behavior. Numeric literals were also reformatted with C++14 digit separators (e.g., 100000000 -> 100‘000‘000) without changing values.
Changed components
C++ header constants across src/ (consensus, net, wallet, script, policy, RPC, GUI, etc.)contrib/seeds/generate-seeds.pysrc/policy/feerate.h (CFeeRate constexpr constructor)Inspect captured patch +440 / −440
### contrib/seeds/generate-seeds.py
@@ -22,9 +22,9 @@
The output will be several data structures with the peers in binary format:
- static const uint8_t chainparams_seed_{main,signet,test,testnet4}[]={
- ...
- }
+ inline constexpr uint8_t chainparams_seed_{main,signet,test,testnet4}[]{
+ ...
+ };
These should be pasted into `src/chainparamsseeds.h`.
'''
@@ -137,7 +137,7 @@ def bip155_serialize(spec):
return r
def process_nodes(g, f, structname):
- g.write('static const uint8_t %s[] = {\n' % structname)
+ g.write("inline constexpr uint8_t %s[]{\n" % structname)
for line in f:
comment = line.find('#')
if comment != -1:
### src/addresstype.h
@@ -118,7 +118,7 @@ struct WitnessUnknown
};
/** Witness program for Pay-to-Anchor output script type */
-static const std::vector<unsigned char> ANCHOR_BYTES{0x4e, 0x73};
+inline const std::vector<unsigned char> ANCHOR_BYTES{0x4e, 0x73};
struct PayToAnchor : public WitnessUnknown
{
### src/addrman.h
@@ -23,25 +23,25 @@
class NetGroupManager;
/** Over how many buckets entries with tried addresses from a single group (/16 for IPv4) are spread */
-static constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8};
+inline constexpr uint32_t ADDRMAN_TRIED_BUCKETS_PER_GROUP{8};
/** Over how many buckets entries with new addresses originating from a single group are spread */
-static constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
+inline constexpr uint32_t ADDRMAN_NEW_BUCKETS_PER_SOURCE_GROUP{64};
/** Maximum number of times an address can occur in the new table */
-static constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
+inline constexpr int32_t ADDRMAN_NEW_BUCKETS_PER_ADDRESS{8};
/** How old addresses can maximally be */
-static constexpr auto ADDRMAN_HORIZON{30 * 24h};
+inline constexpr auto ADDRMAN_HORIZON{30 * 24h};
/** After how many failed attempts we give up on a new node */
-static constexpr int32_t ADDRMAN_RETRIES{3};
+inline constexpr int32_t ADDRMAN_RETRIES{3};
/** How many successive failures are allowed ... */
-static constexpr int32_t ADDRMAN_MAX_FAILURES{10};
+inline constexpr int32_t ADDRMAN_MAX_FAILURES{10};
/** ... in at least this duration */
-static constexpr auto ADDRMAN_MIN_FAIL{7 * 24h};
+inline constexpr auto ADDRMAN_MIN_FAIL{7 * 24h};
/** How recent a successful connection should be before we allow an address to be evicted from tried */
-static constexpr auto ADDRMAN_REPLACEMENT{4h};
+inline constexpr auto ADDRMAN_REPLACEMENT{4h};
/** The maximum number of tried addr collisions to store */
-static constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10};
+inline constexpr size_t ADDRMAN_SET_TRIED_COLLISION_SIZE{10};
/** The maximum time we'll spend trying to resolve a tried table collision */
-static constexpr auto ADDRMAN_TEST_WINDOW{40min};
+inline constexpr auto ADDRMAN_TEST_WINDOW{40min};
class InvalidAddrManVersionError : public std::ios_base::failure
{
@@ -53,7 +53,7 @@ class AddrManImpl;
class AddrInfo;
/** Default for -checkaddrman */
-static constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0};
+inline constexpr int32_t DEFAULT_ADDRMAN_CONSISTENCY_CHECKS{0};
/** Location information for an address in AddrMan */
struct AddressPosition {
### src/addrman_impl.h
@@ -23,14 +23,14 @@
#include <vector>
/** Total number of buckets for tried addresses */
-static constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8};
-static constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2};
+inline constexpr int32_t ADDRMAN_TRIED_BUCKET_COUNT_LOG2{8};
+inline constexpr int ADDRMAN_TRIED_BUCKET_COUNT{1 << ADDRMAN_TRIED_BUCKET_COUNT_LOG2};
/** Total number of buckets for new addresses */
-static constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10};
-static constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2};
+inline constexpr int32_t ADDRMAN_NEW_BUCKET_COUNT_LOG2{10};
+inline constexpr int ADDRMAN_NEW_BUCKET_COUNT{1 << ADDRMAN_NEW_BUCKET_COUNT_LOG2};
/** Maximum allowed number of entries in buckets for new and tried addresses */
-static constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6};
-static constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2};
+inline constexpr int32_t ADDRMAN_BUCKET_SIZE_LOG2{6};
+inline constexpr int ADDRMAN_BUCKET_SIZE{1 << ADDRMAN_BUCKET_SIZE_LOG2};
/**
* User-defined type for the internally used nIds
### src/banman.h
@@ -16,10 +16,10 @@
#include <memory>
// NOTE: When adjusting this, update rpcnet:setban's help ("24h")
-static constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
+inline constexpr unsigned int DEFAULT_MISBEHAVING_BANTIME = 60 * 60 * 24; // Default 24-hour ban
/// How often to dump banned addresses/subnets to disk.
-static constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15};
+inline constexpr std::chrono::minutes DUMP_BANS_INTERVAL{15};
class CClientUIInterface;
class CNetAddr;
### src/bech32.h
@@ -23,8 +23,8 @@
namespace bech32
{
-static constexpr size_t CHECKSUM_SIZE = 6;
-static constexpr char SEPARATOR = '1';
+inline constexpr size_t CHECKSUM_SIZE = 6;
+inline constexpr char SEPARATOR = '1';
enum class Encoding {
INVALID, //!< Failed decoding
### src/bip324.h
@@ -15,7 +15,7 @@
#include <pubkey.h>
#include <span.h>
-static constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38};
+inline constexpr unsigned BIP324_SHORTIDS_IMPLEMENTED{38};
/** The BIP324 packet cipher, encapsulating its key derivation, stream cipher, and AEAD. */
class BIP324Cipher
### src/blockfilter.h
@@ -87,8 +87,8 @@ class GCSFilter
bool MatchAny(const ElementSet& elements) const;
};
-constexpr uint8_t BASIC_FILTER_P = 19;
-constexpr uint32_t BASIC_FILTER_M = 784931;
+inline constexpr uint8_t BASIC_FILTER_P = 19;
+inline constexpr uint32_t BASIC_FILTER_M = 784931;
enum class BlockFilterType : uint8_t
{
### src/chain.h
@@ -26,18 +26,18 @@
* Maximum amount of time that a block timestamp is allowed to exceed the
* current time before the block will be accepted.
*/
-static constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
+inline constexpr int64_t MAX_FUTURE_BLOCK_TIME = 2 * 60 * 60;
/**
* Timestamp window used as a grace period by code that compares external
* timestamps (such as timestamps passed to RPCs, or wallet key creation times)
* to block timestamps. This should be set at least as high as
* MAX_FUTURE_BLOCK_TIME.
*/
-static constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME;
+inline constexpr int64_t TIMESTAMP_WINDOW = MAX_FUTURE_BLOCK_TIME;
//! Init values for CBlockIndex nSequenceId when loaded from disk
-static constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0;
-static constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1;
+inline constexpr int32_t SEQ_ID_BEST_CHAIN_FROM_DISK = 0;
+inline constexpr int32_t SEQ_ID_INIT_FROM_DISK = 1;
enum BlockStatus : uint32_t {
//! Unused.
### src/chainparamsseeds.h
@@ -10,7 +10,7 @@
*
* Each line contains a BIP155 serialized (networkID, addr, port) tuple.
*/
-static const uint8_t chainparams_seed_main[] = {
+inline constexpr uint8_t chainparams_seed_main[] = {
0x06,0x10,0xfc,0x11,0xf7,0x69,0x16,0xe6,0x36,0x11,0x58,0xae,0x1d,0x4a,0xfc,0xf7,0x57,0xa4,0x20,0x8d,
0x06,0x10,0xfc,0x17,0x43,0x69,0x54,0x14,0x4b,0x1f,0x56,0x89,0xd3,0xed,0x40,0x39,0x33,0x5c,0x20,0x8d,
0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x20,0x8d,
@@ -2072,7 +2072,7 @@ static const uint8_t chainparams_seed_main[] = {
0x04,0x20,0xce,0x07,0x95,0xf3,0xa5,0xc1,0x90,0xc4,0x50,0xd5,0x22,0x86,0xa7,0x26,0x37,0x08,0xa2,0x31,0x1e,0x0d,0x77,0x48,0x0d,0x46,0xe0,0xfb,0x3d,0x71,0x60,0xe7,0x1d,0xce,0x20,0x8d,
};
-static const uint8_t chainparams_seed_signet[] = {
+inline constexpr uint8_t chainparams_seed_signet[] = {
0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x95,0xbd,
0x05,0x20,0xd7,0x4d,0xd9,0xc4,0x7c,0x80,0x24,0x1d,0x48,0x2f,0x52,0xba,0x2a,0xaf,0x5d,0xf2,0xfc,0x04,0x58,0x56,0x4a,0x61,0x0f,0xde,0x4e,0xd8,0x13,0x55,0x98,0x55,0x53,0xc1,0x00,0x00,
0x05,0x20,0xd8,0xaf,0x32,0x40,0x0d,0x25,0x72,0x91,0xf5,0x14,0x2a,0xa7,0x7b,0x9f,0x6b,0xe8,0x02,0x9f,0x16,0x5e,0xa0,0xe0,0x6d,0x85,0xcc,0x79,0xf2,0xe2,0xc1,0x2b,0xe0,0x20,0x00,0x00,
@@ -2245,7 +2245,7 @@ static const uint8_t chainparams_seed_signet[] = {
0x04,0x20,0xc9,0x95,0x5a,0xf7,0x9a,0x27,0x09,0x6a,0xa2,0x24,0x65,0xb7,0x07,0xf0,0x28,0xee,0x8b,0xa9,0x5e,0x7c,0x37,0x19,0x14,0xc4,0x36,0x73,0x42,0xd2,0x87,0xae,0xa2,0x47,0x95,0xbd,
};
-static const uint8_t chainparams_seed_test[] = {
+inline constexpr uint8_t chainparams_seed_test[] = {
0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0x47,0x9d,
0x05,0x20,0x39,0x06,0xc0,0x95,0x12,0xe1,0xf8,0x86,0xc2,0x36,0x76,0xa9,0x96,0x2a,0x9d,0xbd,0x3d,0x70,0x43,0xfc,0x99,0xbf,0x27,0x15,0xa4,0x9c,0x10,0xa1,0xd5,0xa3,0x9d,0x52,0x00,0x00,
0x05,0x20,0x40,0x81,0xae,0x55,0xb2,0x9d,0xd0,0xff,0x99,0x51,0xd8,0xbc,0x35,0xb2,0x06,0xb7,0x1c,0xf6,0x16,0x35,0xae,0xc6,0xf7,0xa4,0x72,0xf8,0x37,0x41,0x8e,0x91,0x7b,0x2e,0x00,0x00,
@@ -2429,7 +2429,7 @@ static const uint8_t chainparams_seed_test[] = {
0x04,0x20,0xcc,0x99,0x76,0x52,0x43,0xcc,0x45,0x0a,0x49,0x5d,0x3f,0xa5,0x82,0xc3,0xc0,0xdb,0xcf,0xe5,0xda,0xfb,0xb3,0xd0,0xb9,0xd1,0xbc,0x1b,0x15,0x19,0xed,0xe0,0xd1,0x5f,0x47,0x9d,
};
-static const uint8_t chainparams_seed_testnet4[] = {
+inline constexpr uint8_t chainparams_seed_testnet4[] = {
0x06,0x10,0xfc,0x1f,0x22,0xc3,0x95,0xdc,0xa3,0xaf,0x4a,0x93,0x82,0x51,0xbe,0xb9,0x18,0x58,0xbc,0xcd,
0x05,0x20,0xd3,0xbc,0x25,0x95,0x63,0x7f,0x34,0x02,0x18,0x69,0x91,0x9a,0x79,0x57,0x10,0xc0,0xe0,0xf5,0xcd,0x84,0x56,0x95,0xec,0x43,0xa4,0x9d,0xba,0x1b,0xb3,0xea,0x34,0x60,0x00,0x00,
0x05,0x20,0xd8,0xee,0x64,0x35,0x6c,0x53,0xe7,0x40,0xb8,0xc3,0x15,0x60,0x5b,0x9c,0x66,0x3d,0xbb,0xd9,0x7c,0x99,0xcc,0x3a,0x3a,0xf6,0xcb,0xd5,0xd4,0x51,0x98,0x04,0x68,0xad,0x00,0x00,
### src/clientversion.h
@@ -23,7 +23,7 @@
#include <string>
#include <vector>
-static const int CLIENT_VERSION =
+inline constexpr int CLIENT_VERSION =
10000 * CLIENT_VERSION_MAJOR
+ 100 * CLIENT_VERSION_MINOR
+ 1 * CLIENT_VERSION_BUILD;
### src/common/bloom.h
@@ -15,8 +15,8 @@ class COutPoint;
class CTransaction;
//! 20,000 items with fp rate < 0.1% or 10,000 items and <0.0001%
-static constexpr unsigned int MAX_BLOOM_FILTER_SIZE = 36000; // bytes
-static constexpr unsigned int MAX_HASH_FUNCS = 50;
+inline constexpr unsigned int MAX_BLOOM_FILTER_SIZE{36'000}; // bytes
+inline constexpr unsigned int MAX_HASH_FUNCS = 50;
/**
* First two bits of nFlags control how much IsRelevantAndUpdate actually updates
### src/common/pcp.h
@@ -20,7 +20,7 @@ class CThreadInterrupt;
// NAT-PMP and PCP use network byte order (big-endian).
//! Mapping nonce size in bytes (see RFC6887 section 11.1).
-constexpr size_t PCP_MAP_NONCE_SIZE = 12;
+inline constexpr size_t PCP_MAP_NONCE_SIZE = 12;
//! PCP mapping nonce. Arbitrary data chosen by the client to identify a mapping.
typedef std::array<uint8_t, PCP_MAP_NONCE_SIZE> PCPMappingNonce;
### src/consensus/amount.h
@@ -12,7 +12,7 @@
typedef int64_t CAmount;
/** The amount of satoshis in one BTC. */
-static constexpr CAmount COIN = 100000000;
+inline constexpr CAmount COIN{100'000'000};
/** No amount larger than this (in satoshi) is valid.
*
@@ -23,7 +23,7 @@ static constexpr CAmount COIN = 100000000;
* critical; in unusual circumstances like a(nother) overflow bug that allowed
* for the creation of coins out of thin air modification could lead to a fork.
* */
-static constexpr CAmount MAX_MONEY = 21000000 * COIN;
+inline constexpr CAmount MAX_MONEY{21'000'000 * COIN};
inline bool MoneyRange(const CAmount& nValue) { return (nValue >= 0 && nValue <= MAX_MONEY); }
#endif // BITCOIN_CONSENSUS_AMOUNT_H
### src/consensus/consensus.h
@@ -10,28 +10,28 @@
#include <cstdint>
/** The maximum allowed size for a serialized block, in bytes (only for buffer size limits) */
-static const unsigned int MAX_BLOCK_SERIALIZED_SIZE = 4000000;
+inline constexpr unsigned int MAX_BLOCK_SERIALIZED_SIZE{4'000'000};
/** The maximum allowed weight for a block, see BIP 141 (network rule) */
-static const unsigned int MAX_BLOCK_WEIGHT = 4000000;
+inline constexpr unsigned int MAX_BLOCK_WEIGHT{4'000'000};
/** The maximum allowed number of signature check operations in a block (network rule) */
-static const int64_t MAX_BLOCK_SIGOPS_COST = 80000;
+inline constexpr int64_t MAX_BLOCK_SIGOPS_COST{80'000};
/** Coinbase transaction outputs can only be spent after this number of new blocks (network rule) */
-static const int COINBASE_MATURITY = 100;
+inline constexpr int COINBASE_MATURITY = 100;
-static const int WITNESS_SCALE_FACTOR = 4;
+inline constexpr int WITNESS_SCALE_FACTOR = 4;
-static const size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction
-static const size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 10; // 10 is the lower bound for the size of a serialized CTransaction
+inline constexpr size_t MIN_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 60; // 60 is the lower bound for the size of a valid serialized CTransaction
+inline constexpr size_t MIN_SERIALIZABLE_TRANSACTION_WEIGHT = WITNESS_SCALE_FACTOR * 10; // 10 is the lower bound for the size of a serialized CTransaction
/** Flags for nSequence and nLockTime locks */
/** Interpret sequence numbers as relative lock-time constraints. */
-static constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
+inline constexpr unsigned int LOCKTIME_VERIFY_SEQUENCE = (1 << 0);
/**
* Maximum number of seconds that the timestamp of the first
* block of a difficulty adjustment period is allowed to
* be earlier than the last block of the previous period (BIP94).
*/
-static constexpr int64_t MAX_TIMEWARP = 600;
+inline constexpr int64_t MAX_TIMEWARP = 600;
#endif // BITCOIN_CONSENSUS_CONSENSUS_H
### src/consensus/validation.h
@@ -20,10 +20,10 @@
/** Index marker for when no witness commitment is present in a coinbase transaction. */
-static constexpr int NO_WITNESS_COMMITMENT{-1};
+inline constexpr int NO_WITNESS_COMMITMENT{-1};
/** Minimum size of a witness commitment structure. Defined in BIP 141. **/
-static constexpr size_t MINIMUM_WITNESS_COMMITMENT{38};
+inline constexpr size_t MINIMUM_WITNESS_COMMITMENT{38};
/** A "reason" why a transaction was invalid, suitable for determining whether the
* provider of the transaction should be banned/ignored/disconnected/etc.
### src/crypto/aes.h
@@ -12,8 +12,8 @@ extern "C" {
#include <crypto/ctaes/ctaes.h>
}
-static const int AES_BLOCKSIZE = 16;
-static const int AES256_KEYSIZE = 32;
+inline constexpr int AES_BLOCKSIZE = 16;
+inline constexpr int AES256_KEYSIZE = 32;
/** An encryption class for AES-256. */
class AES256Encrypt
### src/dbwrapper.h
@@ -27,9 +27,9 @@ namespace leveldb {
class Env;
} // namespace leveldb
-static const size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64;
-static const size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024;
-static const size_t DBWRAPPER_MAX_FILE_SIZE{32_MiB};
+inline constexpr size_t DBWRAPPER_PREALLOC_KEY_SIZE = 64;
+inline constexpr size_t DBWRAPPER_PREALLOC_VALUE_SIZE = 1024;
+inline constexpr size_t DBWRAPPER_MAX_FILE_SIZE{32_MiB};
//! User-controlled performance and debug options.
struct DBOptions {
### src/httpserver.h
@@ -32,15 +32,15 @@ class SignalInterrupt;
/**
* The default value for `-rpcthreads`. This number of threads will be created at startup.
*/
-static const int DEFAULT_HTTP_THREADS=16;
+inline constexpr int DEFAULT_HTTP_THREADS=16;
/**
* The default value for `-rpcworkqueue`. This is the maximum depth of the work queue,
* we don't allocate this number of work queue items upfront.
*/
-static const int DEFAULT_HTTP_WORKQUEUE=64;
+inline constexpr int DEFAULT_HTTP_WORKQUEUE=64;
-static const int DEFAULT_HTTP_SERVER_TIMEOUT=30;
+inline constexpr int DEFAULT_HTTP_SERVER_TIMEOUT=30;
enum class HTTPRequestMethod {
UNKNOWN,
@@ -68,16 +68,16 @@ namespace http_bitcoin {
using util::LineReader;
//! Shortest valid request line, used by libevent in evhttp_parse_request_line()
-constexpr size_t MIN_REQUEST_LINE_LENGTH = std::string_view("GET / HTTP/1.0").size();
+inline constexpr size_t MIN_REQUEST_LINE_LENGTH = std::string_view("GET / HTTP/1.0").size();
//! Maximum size of each headers line in an HTTP request,
//! also the maximum size of all headers total.
//! See https://github.com/bitcoin/bitcoin/pull/6859
//! And libevent http.c evhttp_parse_headers_()
-constexpr size_t MAX_HEADERS_SIZE{8192};
+inline constexpr size_t MAX_HEADERS_SIZE{8192};
//! Maximum size of an HTTP request body
-constexpr uint64_t MAX_BODY_SIZE{32_MiB};
+inline constexpr uint64_t MAX_BODY_SIZE{32_MiB};
//! Thrown when a request body exceeds MAX_BODY_SIZE (or *will* exceed, in chunked transfer)
//! so the server can reply with more specific code 413 (content too large) vs general 400 (bad request)
### src/i2p.h
@@ -48,7 +48,7 @@ namespace sam {
* The longest known message is ~1400 bytes, so this is high enough not to be triggered during
* normal operation, yet low enough to avoid a malicious proxy from filling our memory.
*/
-static constexpr size_t MAX_MSG_SIZE{65536};
+inline constexpr size_t MAX_MSG_SIZE{65'536};
/**
* I2P SAM session.
### src/index/blockfilterindex.h
@@ -25,10 +25,10 @@ class BlockFilter;
class CBlockIndex;
enum class BlockFilterType : uint8_t;
-static const char* const DEFAULT_BLOCKFILTERINDEX = "0";
+inline constexpr const char* DEFAULT_BLOCKFILTERINDEX{"0"};
/** Interval between compact filter checkpoints. See BIP 157. */
-static constexpr int CFCHECKPT_INTERVAL = 1000;
+inline constexpr int CFCHECKPT_INTERVAL = 1000;
/**
* BlockFilterIndex is used to store and retrieve block filters, hashes, and headers for a range of
### src/index/coinstatsindex.h
@@ -22,7 +22,7 @@ namespace kernel {
struct CCoinsStats;
}
-static constexpr bool DEFAULT_COINSTATSINDEX{false};
+inline constexpr bool DEFAULT_COINSTATSINDEX{false};
/**
* CoinStatsIndex maintains statistics on the UTXO set.
### src/index/db_key.h
@@ -26,8 +26,8 @@ namespace index_util {
* Keys for the hash index have the type [DB_BLOCK_HASH, uint256].
*/
-static constexpr uint8_t DB_BLOCK_HASH{'s'};
-static constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
+inline constexpr uint8_t DB_BLOCK_HASH{'s'};
+inline constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
struct DBHeightKey {
int height;
### src/index/txindex.h
@@ -16,7 +16,7 @@ namespace interfaces {
class Chain;
}
-static constexpr bool DEFAULT_TXINDEX{false};
+inline constexpr bool DEFAULT_TXINDEX{false};
/**
* TxIndex is used to look up transactions included in the blockchain by hash.
### src/index/txospenderindex.h
@@ -21,7 +21,7 @@
struct CDiskTxPos;
-static constexpr bool DEFAULT_TXOSPENDERINDEX{false};
+inline constexpr bool DEFAULT_TXOSPENDERINDEX{false};
struct TxoSpender {
CTransactionRef tx;
### src/init.h
@@ -9,9 +9,9 @@
#include <atomic>
//! Default value for -daemon option
-static constexpr bool DEFAULT_DAEMON = false;
+inline constexpr bool DEFAULT_DAEMON = false;
//! Default value for -daemonwait option
-static constexpr bool DEFAULT_DAEMONWAIT = false;
+inline constexpr bool DEFAULT_DAEMONWAIT = false;
class ArgsManager;
namespace interfaces {
### src/ipc/util.h
@@ -25,7 +25,7 @@ namespace mp {
class EventLoop;
using ProcessId = int;
using SocketId = int;
-constexpr SocketId SocketError{-1};
+inline constexpr SocketId SocketError{-1};
using Stream = SocketId;
inline Stream MakeStream(EventLoop&, SocketId socket)
### src/kernel/blockmanager_opts.h
@@ -15,7 +15,7 @@ class CChainParams;
namespace kernel {
-static constexpr bool DEFAULT_XOR_BLOCKSDIR{true};
+inline constexpr bool DEFAULT_XOR_BLOCKSDIR{true};
/**
* An options struct for `BlockManager`, more ergonomically referred to as
### src/kernel/caches.h
@@ -12,18 +12,18 @@
#include <limits>
//! Minimum total database cache (bytes)
-static constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB};
+inline constexpr uint64_t MIN_DBCACHE_BYTES{4_MiB};
//! Maximum total database cache on current architecture (bytes)
-static constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits<uint64_t>::max()};
+inline constexpr uint64_t MAX_DBCACHE_BYTES{sizeof(void*) == 4 ? 1_GiB : std::numeric_limits<uint64_t>::max()};
//! Suggested default amount of cache reserved for the kernel (bytes)
-static constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB};
+inline constexpr uint64_t DEFAULT_KERNEL_CACHE{450_MiB};
//! Default LevelDB write batch size
-static constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB};
+inline constexpr uint64_t DEFAULT_DB_CACHE_BATCH{32_MiB};
//! Max memory allocated to block tree DB specific cache (bytes)
-static constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB};
+inline constexpr uint64_t MAX_BLOCK_DB_CACHE{2_MiB};
//! Max memory allocated to coin DB specific cache (bytes)
-static constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB};
+inline constexpr uint64_t MAX_COINS_DB_CACHE{8_MiB};
namespace kernel {
struct CacheSizes {
### src/kernel/chainstatemanager_opts.h
@@ -21,8 +21,8 @@
class CChainParams;
class ValidationSignals;
-static constexpr auto DEFAULT_MAX_TIP_AGE{24h};
-static constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8};
+inline constexpr auto DEFAULT_MAX_TIP_AGE{24h};
+inline constexpr int32_t DEFAULT_PREVOUTFETCH_THREADS{8};
namespace kernel {
### src/kernel/disconnected_transactions.h
@@ -15,7 +15,7 @@
#include <vector>
/** Maximum bytes for transactions to store for processing during reorg */
-static const unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000};
+inline constexpr unsigned int MAX_DISCONNECTED_TX_POOL_BYTES{20'000'000};
/**
* DisconnectedBlockTransactions
### src/kernel/mempool_options.h
@@ -16,15 +16,15 @@
class ValidationSignals;
/** Default for -maxmempool, maximum megabytes of mempool memory usage */
-static constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300};
+inline constexpr unsigned int DEFAULT_MAX_MEMPOOL_SIZE_MB{300};
/** Default for -maxmempool when blocksonly is set */
-static constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
+inline constexpr unsigned int DEFAULT_BLOCKSONLY_MAX_MEMPOOL_SIZE_MB{5};
/** Default for -mempoolexpiry, expiration time for mempool transactions in hours */
-static constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
+inline constexpr unsigned int DEFAULT_MEMPOOL_EXPIRY_HOURS{336};
/** Whether to fall back to legacy V1 serialization when writing mempool.dat */
-static constexpr bool DEFAULT_PERSIST_V1_DAT{false};
+inline constexpr bool DEFAULT_PERSIST_V1_DAT{false};
/** Default for -acceptnonstdtxn */
-static constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
+inline constexpr bool DEFAULT_ACCEPT_NON_STD_TXN{false};
namespace kernel {
/**
### src/key.h
@@ -25,7 +25,7 @@ typedef struct secp256k1_context_struct secp256k1_context;
typedef std::vector<unsigned char, secure_allocator<unsigned char> > CPrivKey;
/** Size of ECDH shared secrets. */
-constexpr static size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE;
+inline constexpr size_t ECDH_SECRET_SIZE = CSHA256::OUTPUT_SIZE;
// Used to represent ECDH shared secret (ECDH_SECRET_SIZE bytes)
using ECDHSecret = std::array<std::byte, ECDH_SECRET_SIZE>;
### src/logging.h
@@ -27,12 +27,12 @@
#include <unordered_map>
#include <vector>
-static const bool DEFAULT_LOGTIMEMICROS = false;
-static const bool DEFAULT_LOGIPS = false;
-static const bool DEFAULT_LOGTIMESTAMPS = true;
-static const bool DEFAULT_LOGTHREADNAMES = false;
-static const bool DEFAULT_LOGSOURCELOCATIONS = false;
-static constexpr bool DEFAULT_LOGLEVELALWAYS = false;
+inline constexpr bool DEFAULT_LOGTIMEMICROS = false;
+inline constexpr bool DEFAULT_LOGIPS = false;
+inline constexpr bool DEFAULT_LOGTIMESTAMPS = true;
+inline constexpr bool DEFAULT_LOGTHREADNAMES = false;
+inline constexpr bool DEFAULT_LOGSOURCELOCATIONS = false;
+inline constexpr bool DEFAULT_LOGLEVELALWAYS = false;
extern const char * const DEFAULT_DEBUGLOGFILE;
extern bool fLogIPs;
### src/mapport.h
@@ -5,7 +5,7 @@
#ifndef BITCOIN_MAPPORT_H
#define BITCOIN_MAPPORT_H
-static constexpr bool DEFAULT_NATPMP = true;
+inline constexpr bool DEFAULT_NATPMP = true;
void StartMapPort(bool enable);
void InterruptMapPort();
### src/musig.h
@@ -15,7 +15,7 @@ struct secp256k1_musig_keyagg_cache;
class MuSig2SecNonceImpl;
struct secp256k1_musig_secnonce;
-constexpr size_t MUSIG2_PUBNONCE_SIZE{66};
+inline constexpr size_t MUSIG2_PUBNONCE_SIZE{66};
//! Compute the full aggregate pubkey from the given participant pubkeys in their current order.
//! Outputs the secp256k1_musig_keyagg_cache and validates that the computed aggregate pubkey matches an expected aggregate pubkey.
### src/net.h
@@ -56,51 +56,51 @@ class CScheduler;
struct bilingual_str;
/** Time after which to disconnect, after waiting for a ping response (or inactivity). */
-static constexpr std::chrono::minutes TIMEOUT_INTERVAL{20};
+inline constexpr std::chrono::minutes TIMEOUT_INTERVAL{20};
/** Run the feeler connection loop once every 2 minutes. **/
-static constexpr auto FEELER_INTERVAL = 2min;
+inline constexpr auto FEELER_INTERVAL = 2min;
/** Run the extra block-relay-only connection loop once every 5 minutes. **/
-static constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min;
+inline constexpr auto EXTRA_BLOCK_RELAY_ONLY_PEER_INTERVAL = 5min;
/** Maximum length of incoming protocol messages (no message over 4 MB is currently acceptable). */
-static const unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000;
+inline constexpr unsigned int MAX_PROTOCOL_MESSAGE_LENGTH = 4 * 1000 * 1000;
/** Maximum length of the user agent string in `version` message */
-static const unsigned int MAX_SUBVERSION_LENGTH = 256;
+inline constexpr unsigned int MAX_SUBVERSION_LENGTH = 256;
/** Maximum number of automatic outgoing nodes over which we'll relay everything (blocks, tx, addrs, etc) */
-static const int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8;
+inline constexpr int MAX_OUTBOUND_FULL_RELAY_CONNECTIONS = 8;
/** Maximum number of addnode outgoing nodes */
-static const int MAX_ADDNODE_CONNECTIONS = 8;
+inline constexpr int MAX_ADDNODE_CONNECTIONS = 8;
/** Maximum number of block-relay-only outgoing connections */
-static const int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2;
+inline constexpr int MAX_BLOCK_RELAY_ONLY_CONNECTIONS = 2;
/** Maximum number of feeler connections */
-static const int MAX_FEELER_CONNECTIONS = 1;
+inline constexpr int MAX_FEELER_CONNECTIONS = 1;
/** Maximum number of private broadcast connections */
-static constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64};
+inline constexpr size_t MAX_PRIVATE_BROADCAST_CONNECTIONS{64};
/** -listen default */
-static const bool DEFAULT_LISTEN = true;
+inline constexpr bool DEFAULT_LISTEN = true;
/** The maximum number of peer connections to maintain. */
-static const unsigned int DEFAULT_MAX_PEER_CONNECTIONS{200};
+inline constexpr unsigned int DEFAULT_MAX_PEER_CONNECTIONS{200};
/** Default percentage of inbound connection slots that tx-relaying peers can use */
-static const int DEFAULT_FULL_RELAY_INBOUND_PCT{50};
+inline constexpr int DEFAULT_FULL_RELAY_INBOUND_PCT{50};
/** The default for -maxuploadtarget. 0 = Unlimited */
-static const std::string DEFAULT_MAX_UPLOAD_TARGET{"0M"};
+inline const std::string DEFAULT_MAX_UPLOAD_TARGET{"0M"};
/** Default for blocks only*/
-static const bool DEFAULT_BLOCKSONLY = false;
+inline constexpr bool DEFAULT_BLOCKSONLY = false;
/** -peertimeout default */
-static const int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60;
+inline constexpr int64_t DEFAULT_PEER_CONNECT_TIMEOUT = 60;
/** Default for -privatebroadcast. */
-static constexpr bool DEFAULT_PRIVATE_BROADCAST{false};
+inline constexpr bool DEFAULT_PRIVATE_BROADCAST{false};
/** Number of file descriptors required for message capture **/
-static const int NUM_FDS_MESSAGE_CAPTURE = 1;
+inline constexpr int NUM_FDS_MESSAGE_CAPTURE = 1;
/** Interval for ASMap Health Check **/
-static constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24};
+inline constexpr std::chrono::hours ASMAP_HEALTH_CHECK_INTERVAL{24};
-static constexpr bool DEFAULT_FORCEDNSSEED{false};
-static constexpr bool DEFAULT_DNSSEED{true};
-static constexpr bool DEFAULT_FIXEDSEEDS{true};
-static const size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
-static const size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
+inline constexpr bool DEFAULT_FORCEDNSSEED{false};
+inline constexpr bool DEFAULT_DNSSEED{true};
+inline constexpr bool DEFAULT_FIXEDSEEDS{true};
+inline constexpr size_t DEFAULT_MAXRECEIVEBUFFER = 5 * 1000;
+inline constexpr size_t DEFAULT_MAXSENDBUFFER = 1 * 1000;
-static constexpr bool DEFAULT_V2_TRANSPORT{true};
+inline constexpr bool DEFAULT_V2_TRANSPORT{true};
typedef int64_t NodeId;
### src/net_permissions.h
@@ -17,9 +17,9 @@ struct bilingual_str;
extern const std::vector<std::string> NET_PERMISSIONS_DOC;
/** Default for -whitelistrelay. */
-constexpr bool DEFAULT_WHITELISTRELAY = true;
+inline constexpr bool DEFAULT_WHITELISTRELAY = true;
/** Default for -whitelistforcerelay. */
-constexpr bool DEFAULT_WHITELISTFORCERELAY = false;
+inline constexpr bool DEFAULT_WHITELISTFORCERELAY = false;
enum class NetPermissionFlags : uint32_t {
None = 0,
@@ -46,7 +46,7 @@ enum class NetPermissionFlags : uint32_t {
Implicit = (1U << 31),
All = BloomFilter | ForceRelay | Relay | NoBan | Mempool | Download | Addr,
};
-static inline constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPermissionFlags b)
+constexpr NetPermissionFlags operator|(NetPermissionFlags a, NetPermissionFlags b)
{
using t = std::underlying_type_t<NetPermissionFlags>;
return static_cast<NetPermissionFlags>(static_cast<t>(a) | static_cast<t>(b));
### src/net_processing.h
@@ -38,21 +38,21 @@ class Warnings;
} // namespace node
/** Whether transaction reconciliation protocol should be enabled by default. */
-static constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
+inline constexpr bool DEFAULT_TXRECONCILIATION_ENABLE{false};
/** Default number of non-mempool transactions to keep around for block reconstruction. Includes
orphan, replaced, and rejected transactions. */
-static const uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100};
+inline constexpr uint32_t DEFAULT_BLOCK_RECONSTRUCTION_EXTRA_TXN{100};
/** Default maximum per-second rate for sending transaction inventory to peers. */
-static constexpr unsigned int DEFAULT_TX_SEND_RATE{14};
-static const bool DEFAULT_PEERBLOOMFILTERS = false;
-static const bool DEFAULT_PEERBLOCKFILTERS = false;
+inline constexpr unsigned int DEFAULT_TX_SEND_RATE{14};
+inline constexpr bool DEFAULT_PEERBLOOMFILTERS = false;
+inline constexpr bool DEFAULT_PEERBLOCKFILTERS = false;
/** Maximum number of outstanding CMPCTBLOCK requests for the same block. */
-static const unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3;
+inline constexpr unsigned int MAX_CMPCTBLOCKS_INFLIGHT_PER_BLOCK = 3;
/** Number of headers sent in one getheaders result. We rely on the assumption that if a peer sends
* less than this number, we reached its tip. Changing this value is a protocol upgrade. */
-static const unsigned int MAX_HEADERS_RESULTS = 2000;
+inline constexpr unsigned int MAX_HEADERS_RESULTS = 2000;
/** The compactblocks version we support. See BIP 152. */
-static constexpr uint64_t CMPCTBLOCKS_VERSION{2};
+inline constexpr uint64_t CMPCTBLOCKS_VERSION{2};
struct CNodeStateStats {
int nSyncHeight = -1;
### src/netaddress.h
@@ -59,50 +59,50 @@ enum Network {
/// Prefix of an IPv6 address when it contains an embedded IPv4 address.
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
-static const std::array<uint8_t, 12> IPV4_IN_IPV6_PREFIX{
+inline constexpr std::array<uint8_t, 12> IPV4_IN_IPV6_PREFIX{
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0xFF, 0xFF};
/// Prefix of an IPv6 address when it contains an embedded TORv2 address.
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
/// Such dummy IPv6 addresses are guaranteed to not be publicly routable as they
/// fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses.
-static const std::array<uint8_t, 6> TORV2_IN_IPV6_PREFIX{
+inline constexpr std::array<uint8_t, 6> TORV2_IN_IPV6_PREFIX{
0xFD, 0x87, 0xD8, 0x7E, 0xEB, 0x43};
/// Prefix of an IPv6 address when it contains an embedded "internal" address.
/// Used when (un)serializing addresses in ADDRv1 format (pre-BIP155).
/// The prefix comes from 0xFD + SHA256("bitcoin")[0:5].
/// Such dummy IPv6 addresses are guaranteed to not be publicly routable as they
/// fall under RFC4193's fc00::/7 subnet allocated to unique-local addresses.
-static const std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX{
+inline constexpr std::array<uint8_t, 6> INTERNAL_IN_IPV6_PREFIX{
0xFD, 0x6B, 0x88, 0xC0, 0x87, 0x24 // 0xFD + sha256("bitcoin")[0:5].
};
/// All CJDNS addresses start with 0xFC. See
/// https://github.com/cjdelisle/cjdns/blob/master/doc/Whitepaper.md#pulling-it-all-together
-static constexpr uint8_t CJDNS_PREFIX{0xFC};
+inline constexpr uint8_t CJDNS_PREFIX{0xFC};
/// Size of IPv4 address (in bytes).
-static constexpr size_t ADDR_IPV4_SIZE = 4;
+inline constexpr size_t ADDR_IPV4_SIZE = 4;
/// Size of IPv6 address (in bytes).
-static constexpr size_t ADDR_IPV6_SIZE = 16;
+inline constexpr size_t ADDR_IPV6_SIZE = 16;
/// Size of TORv3 address (in bytes). This is the length of just the address
/// as used in BIP155, without the checksum and the version byte.
-static constexpr size_t ADDR_TORV3_SIZE = 32;
+inline constexpr size_t ADDR_TORV3_SIZE = 32;
/// Size of I2P address (in bytes).
-static constexpr size_t ADDR_I2P_SIZE = 32;
+inline constexpr size_t ADDR_I2P_SIZE = 32;
/// Size of CJDNS address (in bytes).
-static constexpr size_t ADDR_CJDNS_SIZE = 16;
+inline constexpr size_t ADDR_CJDNS_SIZE = 16;
/// Size of "internal" (NET_INTERNAL) address (in bytes).
-static constexpr size_t ADDR_INTERNAL_SIZE = 10;
+inline constexpr size_t ADDR_INTERNAL_SIZE = 10;
/// SAM 3.1 and earlier do not support specifying ports and force the port to 0.
-static constexpr uint16_t I2P_SAM31_PORT{0};
+inline constexpr uint16_t I2P_SAM31_PORT{0};
std::string OnionToString(std::span<const uint8_t> addr);
### src/netbase.h
@@ -25,12 +25,12 @@ extern int nConnectTimeout;
extern bool fNameLookup;
//! -timeout default
-static const int DEFAULT_CONNECT_TIMEOUT = 5000;
+inline constexpr int DEFAULT_CONNECT_TIMEOUT = 5000;
//! -dns default
-static const int DEFAULT_NAME_LOOKUP = true;
+inline constexpr int DEFAULT_NAME_LOOKUP = true;
/** Prefix for unix domain socket addresses (which are local filesystem paths) */
-const std::string ADDR_PREFIX_UNIX = "unix:";
+inline const std::string ADDR_PREFIX_UNIX = "unix:";
enum class ConnectionDirection {
None = 0,
### src/node/blockstorage.h
@@ -119,17 +119,17 @@ using kernel::CBlockFileInfo;
using kernel::BlockTreeDB;
/** The pre-allocation chunk size for blk?????.dat files (since 0.8) */
-static const unsigned int BLOCKFILE_CHUNK_SIZE{16_MiB};
+inline constexpr unsigned int BLOCKFILE_CHUNK_SIZE{16_MiB};
/** The pre-allocation chunk size for rev?????.dat files (since 0.8) */
-static const unsigned int UNDOFILE_CHUNK_SIZE{1_MiB};
+inline constexpr unsigned int UNDOFILE_CHUNK_SIZE{1_MiB};
/** The maximum size of a blk?????.dat file (since 0.8) */
-static const unsigned int MAX_BLOCKFILE_SIZE{128_MiB};
+inline constexpr unsigned int MAX_BLOCKFILE_SIZE{128_MiB};
/** Size of header written by WriteBlock before a serialized CBlock (8 bytes) */
-static constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v<MessageStartChars> + sizeof(unsigned int)};
+inline constexpr uint32_t STORAGE_HEADER_BYTES{std::tuple_size_v<MessageStartChars> + sizeof(unsigned int)};
/** Total overhead when writing undo data: header (8 bytes) plus checksum (32 bytes) */
-static constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()};
+inline constexpr uint32_t UNDO_DATA_DISK_OVERHEAD{STORAGE_HEADER_BYTES + uint256::size()};
// Because validation code takes pointers to the map's CBlockIndex objects, if
// we ever switch to another associative container, we need to either use a
### src/node/caches.h
@@ -15,7 +15,7 @@
class ArgsManager;
//! Reserved non-dbcache memory usage.
-static constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB};
+inline constexpr uint64_t DBCACHE_WARNING_RESERVED_RAM{2_GiB};
namespace node {
uint64_t GetDefaultDBCache();
### src/node/chainstatemanager_args.h
@@ -11,7 +11,7 @@
class ArgsManager;
/** -par default (number of script-checking threads, 0 = auto) */
-static constexpr int DEFAULT_SCRIPTCHECK_THREADS{0};
+inline constexpr int DEFAULT_SCRIPTCHECK_THREADS{0};
namespace node {
[[nodiscard]] util::Result<void> ApplyArgsManOptions(const ArgsManager& args, ChainstateManager::Options& opts);
### src/node/kernel_notifications.h
@@ -26,7 +26,7 @@ enum class Warning;
namespace node {
class Warnings;
-static constexpr int DEFAULT_STOPATHEIGHT{0};
+inline constexpr int DEFAULT_STOPATHEIGHT{0};
//! State tracked by the KernelNotifications interface meant to be used by
//! mining code, index code, RPCs, and other code sitting above the validation
### src/node/mempool_persist_args.h
@@ -15,7 +15,7 @@ namespace node {
* Default for -persistmempool, indicating whether the node should attempt to
* automatically load the mempool on start and save to disk on shutdown
*/
-static constexpr bool DEFAULT_PERSIST_MEMPOOL{true};
+inline constexpr bool DEFAULT_PERSIST_MEMPOOL{true};
bool ShouldPersistMempool(const ArgsManager& argsman);
fs::path MempoolPath(const ArgsManager& argsman);
### src/node/mining_args.h
@@ -12,7 +12,7 @@ class ArgsManager;
namespace node {
-static const bool DEFAULT_PRINT_MODIFIED_FEE = false;
+inline constexpr bool DEFAULT_PRINT_MODIFIED_FEE = false;
/**
* Read the mining options set in \p args. Returns an error if one was
### src/node/protocol_version.h
@@ -9,33 +9,33 @@
* network protocol versioning
*/
-static const int PROTOCOL_VERSION = 70017;
+inline constexpr int PROTOCOL_VERSION = 70017;
//! initial proto version, to be increased after version/verack negotiation
-static const int INIT_PROTO_VERSION = 209;
+inline constexpr int INIT_PROTO_VERSION = 209;
//! disconnect from peers older than this proto version
-static const int MIN_PEER_PROTO_VERSION = 31800;
+inline constexpr int MIN_PEER_PROTO_VERSION = 31800;
//! BIP 0031, pong message, is enabled for all versions AFTER this one
-static const int BIP0031_VERSION = 60000;
+inline constexpr int BIP0031_VERSION = 60000;
//! "sendheaders" message type and announcing blocks with headers starts with this version
-static const int SENDHEADERS_VERSION = 70012;
+inline constexpr int SENDHEADERS_VERSION = 70012;
//! "feefilter" tells peers to filter invs to you by fee starts with this version
-static const int FEEFILTER_VERSION = 70013;
+inline constexpr int FEEFILTER_VERSION = 70013;
//! short-id-based block download starts with this version
-static const int SHORT_IDS_BLOCKS_VERSION = 70014;
+inline constexpr int SHORT_IDS_BLOCKS_VERSION = 70014;
//! not banning for invalid compact blocks starts with this version
-static const int INVALID_CB_NO_BAN_VERSION = 70015;
+inline constexpr int INVALID_CB_NO_BAN_VERSION = 70015;
//! "wtxidrelay" message type for wtxid-based relay starts with this version
-static const int WTXID_RELAY_VERSION = 70016;
+inline constexpr int WTXID_RELAY_VERSION = 70016;
//! "feature" message type for feature negotiation starts with this version
-static const int FEATURE_VERSION = 70017;
+inline constexpr int FEATURE_VERSION = 70017;
#endif // BITCOIN_NODE_PROTOCOL_VERSION_H
### src/node/transaction.h
@@ -25,13 +25,13 @@ struct NodeContext;
* By default, a transaction with a fee rate higher than this will be rejected
* by these RPCs and the GUI. This can be overridden with the maxfeerate argument.
*/
-static const CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
+inline constexpr CFeeRate DEFAULT_MAX_RAW_TX_FEE_RATE{COIN / 10};
/** Maximum burn value for sendrawtransaction, submitpackage, and testmempoolaccept RPC calls.
* By default, a transaction with a burn value higher than this will be rejected
* by these RPCs and the GUI. This can be overridden with the maxburnamount argument.
*/
-static const CAmount DEFAULT_MAX_BURN_AMOUNT{0};
+inline constexpr CAmount DEFAULT_MAX_BURN_AMOUNT{0};
/**
* Submit a transaction to the mempool and (optionally) relay it to all P2P peers.
### src/node/txdownloadman.h
@@ -22,20 +22,20 @@ class TxDownloadManagerImpl;
/** Maximum number of in-flight transaction requests from a peer. It is not a hard limit, but the threshold at which
* point the OVERLOADED_PEER_TX_DELAY kicks in. */
-static constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100;
+inline constexpr int32_t MAX_PEER_TX_REQUEST_IN_FLIGHT = 100;
/** Maximum number of transactions to consider for requesting, per peer. It provides a reasonable DoS limit to
* per-peer memory usage spent on announcements, while covering peers continuously sending INVs at the maximum
* rate (by our own policy, see DEFAULT_TX_SEND_RATE) for several minutes, while not receiving
* the actual transaction (from any peer) in response to requests for them. */
-static constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000;
+inline constexpr int32_t MAX_PEER_TX_ANNOUNCEMENTS = 5000;
/** How long to delay requesting transactions via txids, if we have wtxid-relaying peers */
-static constexpr auto TXID_RELAY_DELAY{2s};
+inline constexpr auto TXID_RELAY_DELAY{2s};
/** How long to delay requesting transactions from non-preferred peers */
-static constexpr auto NONPREF_PEER_TX_DELAY{2s};
+inline constexpr auto NONPREF_PEER_TX_DELAY{2s};
/** How long to delay requesting transactions from overloaded peers (see MAX_PEER_TX_REQUEST_IN_FLIGHT). */
-static constexpr auto OVERLOADED_PEER_TX_DELAY{2s};
+inline constexpr auto OVERLOADED_PEER_TX_DELAY{2s};
/** How long to wait before downloading a transaction from an additional peer */
-static constexpr auto GETDATA_TX_INTERVAL{60s};
+inline constexpr auto GETDATA_TX_INTERVAL{60s};
struct TxDownloadOptions {
/** Read-only reference to mempool. */
const CTxMemPool& m_mempool;
### src/node/txorphanage.h
@@ -17,10 +17,10 @@
namespace node {
/** Default value for TxOrphanage::m_reserved_usage_per_peer. Helps limit the total amount of memory used by the orphanage. */
-static constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000};
+inline constexpr int64_t DEFAULT_RESERVED_ORPHAN_WEIGHT_PER_PEER{404'000};
/** Default value for TxOrphanage::m_max_global_latency_score. Helps limit the maximum latency for operations like
* EraseForBlock and LimitOrphans. */
-static constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000};
+inline constexpr unsigned int DEFAULT_MAX_ORPHANAGE_LATENCY_SCORE{3000};
/** A class to track orphan transactions (failed on TX_MISSING_INPUTS)
* Since we cannot distinguish orphans from bad transactions with non-existent inputs, we heavily limit the amount of
### src/node/txreconciliation.h
@@ -12,7 +12,7 @@
#include <tuple>
/** Supported transaction reconciliation protocol version */
-static constexpr uint32_t TXRECONCILIATION_VERSION{1};
+inline constexpr uint32_t TXRECONCILIATION_VERSION{1};
enum class ReconciliationRegisterResult {
NOT_FOUND,
### src/node/utxo_snapshot.h
@@ -25,7 +25,7 @@
#include <string_view>
// UTXO set snapshot magic bytes
-static constexpr std::array<uint8_t, 5> SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff};
+inline constexpr std::array<uint8_t, 5> SNAPSHOT_MAGIC_BYTES = {'u', 't', 'x', 'o', 0xff};
class Chainstate;
@@ -110,7 +110,7 @@ class SnapshotMetadata
//!
//! Because we only allow loading a single snapshot at a time, there will only be one
//! chainstate directory with this filename present within it.
-const fs::path SNAPSHOT_BLOCKHASH_FILENAME{"base_blockhash"};
+inline const fs::path SNAPSHOT_BLOCKHASH_FILENAME{"base_blockhash"};
//! Write out the blockhash of the snapshot base block that was used to construct
//! this chainstate. This value is read in during subsequent initializations and
@@ -125,7 +125,7 @@ std::optional<uint256> ReadSnapshotBaseBlockhash(fs::path chaindir)
//! Suffix appended to the chainstate (leveldb) dir when created based upon
//! a snapshot.
-constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot";
+inline constexpr std::string_view SNAPSHOT_CHAINSTATE_SUFFIX = "_snapshot";
//! Return a path to the snapshot-based chainstate dir, if one exists.
### src/outputtype.h
@@ -23,7 +23,7 @@ enum class OutputType {
UNKNOWN,
};
-static constexpr auto OUTPUT_TYPES = std::array{
+inline constexpr auto OUTPUT_TYPES = std::array{
OutputType::LEGACY,
OutputType::P2SH_SEGWIT,
OutputType::BECH32,
### src/policy/feerate.h
@@ -16,8 +16,8 @@
#include <string>
#include <type_traits>
-const std::string CURRENCY_UNIT = "BTC"; // One formatted unit
-const std::string CURRENCY_ATOM = "sat"; // One indivisible minimum value unit
+inline const std::string CURRENCY_UNIT = "BTC"; // One formatted unit
+inline const std::string CURRENCY_ATOM = "sat"; // One indivisible minimum value unit
enum class FeeRateFormat {
BTC_KVB, //!< Use BTC/kvB fee rate unit
@@ -38,7 +38,7 @@ class CFeeRate
/** Fee rate of 0 satoshis per 0 vB */
CFeeRate() = default;
template<std::integral I> // Disallow silent float -> int conversion
- explicit CFeeRate(const I m_feerate_kvb) : m_feerate(FeePerVSize(m_feerate_kvb, 1000)) {}
+ explicit constexpr CFeeRate(const I m_feerate_kvb) : m_feerate(FeePerVSize(m_feerate_kvb, 1000)) {}
/**
* Construct a fee rate from a fee in satoshis and a vsize in vB.
### src/policy/fees/block_policy_estimator.h
@@ -23,16 +23,16 @@
// How often to flush fee estimates to fee_estimates.dat.
-static constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1};
+inline constexpr std::chrono::hours FEE_FLUSH_INTERVAL{1};
/** fee_estimates.dat that are more than 60 hours (2.5 days) old will not be read,
* as fee estimates are based on historical data and may be inaccurate if
* network activity has changed.
*/
-static constexpr std::chrono::hours MAX_FILE_AGE{60};
+inline constexpr std::chrono::hours MAX_FILE_AGE{60};
// Whether we allow importing a fee_estimates file older than MAX_FILE_AGE.
-static constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false};
+inline constexpr bool DEFAULT_ACCEPT_STALE_FEE_ESTIMATES{false};
class AutoFile;
class TxConfirmStats;
@@ -47,7 +47,7 @@ enum class FeeEstimateHorizon {
LONG_HALFLIFE,
};
-static constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{
+inline constexpr auto ALL_FEE_ESTIMATE_HORIZONS = std::array{
FeeEstimateHorizon::SHORT_HALFLIFE,
FeeEstimateHorizon::MED_HALFLIFE,
FeeEstimateHorizon::LONG_HALFLIFE,
### src/policy/packages.h
@@ -16,12 +16,12 @@
#include <vector>
/** Default maximum number of transactions in a package. */
-static constexpr uint32_t MAX_PACKAGE_COUNT{25};
+inline constexpr uint32_t MAX_PACKAGE_COUNT{25};
/** Default maximum total weight of transactions in a package in weight
to allow for context-less checks. This must allow a superset of sigops
weighted vsize limited transactions to not disallow transactions we would
have otherwise accepted individually. */
-static constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000;
+inline constexpr uint32_t MAX_PACKAGE_WEIGHT = 404'000;
static_assert(MAX_PACKAGE_WEIGHT >= MAX_STANDARD_TX_WEIGHT);
// Packages are part of a single cluster, so ensure that the package limits are
### src/policy/policy.h
@@ -22,77 +22,77 @@ class CFeeRate;
class CScript;
/** Default for -blockmaxweight, which controls the range of block weights the mining code will create **/
-static constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT};
+inline constexpr unsigned int DEFAULT_BLOCK_MAX_WEIGHT{MAX_BLOCK_WEIGHT};
/** Default for -blockreservedweight **/
-static constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000};
+inline constexpr unsigned int DEFAULT_BLOCK_RESERVED_WEIGHT{8000};
/** Default sigops cost to reserve for coinbase transaction outputs when creating block templates. */
-static constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400};
+inline constexpr unsigned int DEFAULT_COINBASE_OUTPUT_MAX_ADDITIONAL_SIGOPS{400};
/** This accounts for the block header, var_int encoding of the transaction count and a minimally viable
* coinbase transaction. It adds an additional safety margin, because even with a thorough understanding
* of block serialization, it's easy to make a costly mistake when trying to squeeze every last byte.
* Setting a lower value is prevented at startup. */
-static constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000};
+inline constexpr unsigned int MINIMUM_BLOCK_RESERVED_WEIGHT{2000};
/** Default for -blockmintxfee, which sets the minimum feerate for a transaction in blocks created by mining code **/
-static constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1};
+inline constexpr unsigned int DEFAULT_BLOCK_MIN_TX_FEE{1};
/** The maximum weight for transactions we're willing to relay/mine */
-static constexpr int32_t MAX_STANDARD_TX_WEIGHT{400000};
+inline constexpr int32_t MAX_STANDARD_TX_WEIGHT{400'000};
/** The minimum non-witness size for transactions we're willing to relay/mine: one larger than 64 */
-static constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65};
+inline constexpr unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE{65};
/** Maximum number of signature check operations in an IsStandard() P2SH script */
-static constexpr unsigned int MAX_P2SH_SIGOPS{15};
+inline constexpr unsigned int MAX_P2SH_SIGOPS{15};
/** The maximum number of sigops we're willing to relay/mine in a single tx */
-static constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5};
+inline constexpr unsigned int MAX_STANDARD_TX_SIGOPS_COST{MAX_BLOCK_SIGOPS_COST/5};
/** The maximum number of potentially executed legacy signature operations in a single standard tx */
-static constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500};
+inline constexpr unsigned int MAX_TX_LEGACY_SIGOPS{2'500};
/** Default for -incrementalrelayfee, which sets the minimum feerate increase for mempool limiting or replacement **/
-static constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100};
+inline constexpr unsigned int DEFAULT_INCREMENTAL_RELAY_FEE{100};
/** Default for -bytespersigop */
-static constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
+inline constexpr unsigned int DEFAULT_BYTES_PER_SIGOP{20};
/** Default for -permitbaremultisig */
-static constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
+inline constexpr bool DEFAULT_PERMIT_BAREMULTISIG{true};
/** The maximum number of witness stack items in a standard P2WSH script */
-static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
+inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEMS{100};
/** The maximum size in bytes of each witness stack item in a standard P2WSH script */
-static constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80};
+inline constexpr unsigned int MAX_STANDARD_P2WSH_STACK_ITEM_SIZE{80};
/** The maximum size in bytes of each witness stack item in a standard BIP 342 script (Taproot, leaf version 0xc0) */
-static constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80};
+inline constexpr unsigned int MAX_STANDARD_TAPSCRIPT_STACK_ITEM_SIZE{80};
/** The maximum size in bytes of a standard witnessScript */
-static constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600};
+inline constexpr unsigned int MAX_STANDARD_P2WSH_SCRIPT_SIZE{3600};
/** The maximum size of a standard ScriptSig */
-static constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650};
+inline constexpr unsigned int MAX_STANDARD_SCRIPTSIG_SIZE{1650};
/** Min feerate for defining dust.
* 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 */
-static constexpr unsigned int DUST_RELAY_TX_FEE{3000};
+inline constexpr unsigned int DUST_RELAY_TX_FEE{3000};
/** Default for -minrelaytxfee, minimum relay fee for transactions */
-static constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100};
+inline constexpr unsigned int DEFAULT_MIN_RELAY_TX_FEE{100};
/** Maximum number of transactions per cluster (default) */
-static constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64};
+inline constexpr unsigned int DEFAULT_CLUSTER_LIMIT{64};
/** Maximum size of cluster in virtual kilobytes */
-static constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101};
+inline constexpr unsigned int DEFAULT_CLUSTER_SIZE_LIMIT_KVB{101};
/** Default for -limitancestorcount, max number of in-mempool ancestors */
-static constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25};
+inline constexpr unsigned int DEFAULT_ANCESTOR_LIMIT{25};
/** Default for -limitdescendantcount, max number of in-mempool descendants */
-static constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25};
+inline constexpr unsigned int DEFAULT_DESCENDANT_LIMIT{25};
/** Default for -datacarrier */
-static const bool DEFAULT_ACCEPT_DATACARRIER = true;
+inline constexpr bool DEFAULT_ACCEPT_DATACARRIER = true;
/**
* Default setting for -datacarriersize in vbytes.
*/
-static const unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR;
+inline constexpr unsigned int MAX_OP_RETURN_RELAY = MAX_STANDARD_TX_WEIGHT / WITNESS_SCALE_FACTOR;
/**
* An extra transaction can be added to a package, as long as it only has one
* ancestor and is no larger than this. Not really any reason to make this
* configurable as it doesn't materially change DoS parameters.
*/
-static constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10000};
+inline constexpr unsigned int EXTRA_DESCENDANT_TX_SIZE_LIMIT{10'000};
/**
* Maximum number of ephemeral dust outputs allowed.
*/
-static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1};
+inline constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1};
/**
* Mandatory script verification flags that all new transactions must comply with for
@@ -101,7 +101,7 @@ static constexpr unsigned int MAX_DUST_OUTPUTS_PER_TX{1};
* Note that this does not affect consensus validity; see GetBlockScriptFlags()
* for that.
*/
-static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH |
+inline constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY_P2SH |
SCRIPT_VERIFY_DERSIG |
SCRIPT_VERIFY_NULLDUMMY |
SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY |
@@ -115,7 +115,7 @@ static constexpr script_verify_flags MANDATORY_SCRIPT_VERIFY_FLAGS{SCRIPT_VERIFY
* the additional (non-mandatory) rules here, to improve forwards and
* backwards compatibility.
*/
-static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS |
+inline constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRIPT_VERIFY_FLAGS |
SCRIPT_VERIFY_STRICTENC |
SCRIPT_VERIFY_MINIMALDATA |
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS |
@@ -131,10 +131,10 @@ static constexpr script_verify_flags STANDARD_SCRIPT_VERIFY_FLAGS{MANDATORY_SCRI
SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_PUBKEYTYPE};
/** For convenience, standard but not mandatory verify flags. */
-static constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS};
+inline constexpr script_verify_flags STANDARD_NOT_MANDATORY_VERIFY_FLAGS{STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS};
/** Used as the flags parameter to sequence and nLocktime checks in non-consensus code. */
-static constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE};
+inline constexpr unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS{LOCKTIME_VERIFY_SEQUENCE};
CAmount GetDustThreshold(const CTxOut& txout, const CFeeRate& dustRelayFee);
@@ -148,8 +148,8 @@ std::vector<uint32_t> GetDust(const CTransaction& tx, CFeeRate dust_relay_rate);
// Changing the default transaction version requires a two step process: first
// adapting relay policy by bumping TX_MAX_STANDARD_VERSION, and then later
// allowing the new transaction version in the wallet/RPC.
-static constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1};
-static constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
+inline constexpr decltype(CTransaction::version) TX_MIN_STANDARD_VERSION{1};
+inline constexpr decltype(CTransaction::version) TX_MAX_STANDARD_VERSION{3};
/**
* Check for standard transaction types
### src/policy/rbf.h
@@ -23,7 +23,7 @@ class uint256;
/** Maximum number of unique clusters that can be affected by an RBF (Rule #5);
* see GetEntriesForConflicts() */
-static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
+inline constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
/** The rbf state of unconfirmed transactions */
enum class RBFTransactionState {
### src/policy/truc_policy.h
@@ -17,21 +17,21 @@
// This module enforces rules for BIP 431 TRUC transactions which help make
// RBF abilities more robust. A transaction with version=3 is treated as TRUC.
-static constexpr decltype(CTransaction::version) TRUC_VERSION{3};
+inline constexpr decltype(CTransaction::version) TRUC_VERSION{3};
// TRUC only allows 1 parent and 1 child when unconfirmed. This translates to a descendant set size
// of 2 and ancestor set size of 2.
/** Maximum number of transactions including an unconfirmed tx and its descendants. */
-static constexpr unsigned int TRUC_DESCENDANT_LIMIT{2};
+inline constexpr unsigned int TRUC_DESCENDANT_LIMIT{2};
/** Maximum number of transactions including a TRUC tx and all its mempool ancestors. */
-static constexpr unsigned int TRUC_ANCESTOR_LIMIT{2};
+inline constexpr unsigned int TRUC_ANCESTOR_LIMIT{2};
/** Maximum sigop-adjusted virtual size of all v3 transactions. */
-static constexpr int64_t TRUC_MAX_VSIZE{10000};
-static constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR};
+inline constexpr int64_t TRUC_MAX_VSIZE{10'000};
+inline constexpr int64_t TRUC_MAX_WEIGHT{TRUC_MAX_VSIZE * WITNESS_SCALE_FACTOR};
/** Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction. */
-static constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000};
-static constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR};
+inline constexpr int64_t TRUC_CHILD_MAX_VSIZE{1000};
+inline constexpr int64_t TRUC_CHILD_MAX_WEIGHT{TRUC_CHILD_MAX_VSIZE * WITNESS_SCALE_FACTOR};
// These limits are within the default cluster limits.
static_assert(TRUC_MAX_VSIZE + TRUC_CHILD_MAX_VSIZE <= DEFAULT_CLUSTER_SIZE_LIMIT_KVB * 1000);
### src/primitives/transaction.h
@@ -177,8 +177,8 @@ struct TransactionSerParams {
const bool allow_witness;
SER_PARAMS_OPFUNC
};
-static constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true};
-static constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
+inline constexpr TransactionSerParams TX_WITH_WITNESS{.allow_witness = true};
+inline constexpr TransactionSerParams TX_NO_WITNESS{.allow_witness = false};
/**
* Basic transaction serialization format:
### src/protocol.h
@@ -310,8 +310,8 @@ inline const std::array ALL_NET_MESSAGE_TYPES{std::to_array<std::string>({
NetMsgType::FEATURE,
})};
-static constexpr size_t MAX_FEATUREID_LENGTH{80};
-static constexpr size_t MAX_FEATUREDATA_LENGTH{512};
+inline constexpr size_t MAX_FEATUREID_LENGTH{80};
+inline constexpr size_t MAX_FEATUREDATA_LENGTH{512};
namespace NetMsgFeature {
//inline constexpr std::string_view FOO{"BIP-FOO"};
@@ -487,8 +487,8 @@ class CAddress : public CService
};
/** getdata message type flags */
-const uint32_t MSG_WITNESS_FLAG = 1 << 30;
-const uint32_t MSG_TYPE_MASK = 0xffffffff >> 2;
+inline constexpr uint32_t MSG_WITNESS_FLAG = 1 << 30;
+inline constexpr uint32_t MSG_TYPE_MASK = 0xffffffff >> 2;
/** getdata / inv message types.
* These numbers are defined by the protocol. When adding a new value, be sure
### src/psbt.h
@@ -29,71 +29,71 @@ enum class TransactionError;
using common::PSBTError;
// Magic bytes
-static constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
+inline constexpr uint8_t PSBT_MAGIC_BYTES[5] = {'p', 's', 'b', 't', 0xff};
// Global types
-static constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00;
-static constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01;
-static constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02;
-static constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03;
-static constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04;
-static constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05;
-static constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06;
-static constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB;
-static constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC;
+inline constexpr uint8_t PSBT_GLOBAL_UNSIGNED_TX = 0x00;
+inline constexpr uint8_t PSBT_GLOBAL_XPUB = 0x01;
+inline constexpr uint8_t PSBT_GLOBAL_TX_VERSION = 0x02;
+inline constexpr uint8_t PSBT_GLOBAL_FALLBACK_LOCKTIME = 0x03;
+inline constexpr uint8_t PSBT_GLOBAL_INPUT_COUNT = 0x04;
+inline constexpr uint8_t PSBT_GLOBAL_OUTPUT_COUNT = 0x05;
+inline constexpr uint8_t PSBT_GLOBAL_TX_MODIFIABLE = 0x06;
+inline constexpr uint8_t PSBT_GLOBAL_VERSION = 0xFB;
+inline constexpr uint8_t PSBT_GLOBAL_PROPRIETARY = 0xFC;
// Input types
-static constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00;
-static constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01;
-static constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02;
-static constexpr uint8_t PSBT_IN_SIGHASH = 0x03;
-static constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04;
-static constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05;
-static constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06;
-static constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07;
-static constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08;
-static constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A;
-static constexpr uint8_t PSBT_IN_SHA256 = 0x0B;
-static constexpr uint8_t PSBT_IN_HASH160 = 0x0C;
-static constexpr uint8_t PSBT_IN_HASH256 = 0x0D;
-static constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e;
-static constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f;
-static constexpr uint8_t PSBT_IN_SEQUENCE = 0x10;
-static constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11;
-static constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12;
-static constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13;
-static constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14;
-static constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15;
-static constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16;
-static constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17;
-static constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18;
-static constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a;
-static constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b;
-static constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c;
-static constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC;
+inline constexpr uint8_t PSBT_IN_NON_WITNESS_UTXO = 0x00;
+inline constexpr uint8_t PSBT_IN_WITNESS_UTXO = 0x01;
+inline constexpr uint8_t PSBT_IN_PARTIAL_SIG = 0x02;
+inline constexpr uint8_t PSBT_IN_SIGHASH = 0x03;
+inline constexpr uint8_t PSBT_IN_REDEEMSCRIPT = 0x04;
+inline constexpr uint8_t PSBT_IN_WITNESSSCRIPT = 0x05;
+inline constexpr uint8_t PSBT_IN_BIP32_DERIVATION = 0x06;
+inline constexpr uint8_t PSBT_IN_SCRIPTSIG = 0x07;
+inline constexpr uint8_t PSBT_IN_SCRIPTWITNESS = 0x08;
+inline constexpr uint8_t PSBT_IN_RIPEMD160 = 0x0A;
+inline constexpr uint8_t PSBT_IN_SHA256 = 0x0B;
+inline constexpr uint8_t PSBT_IN_HASH160 = 0x0C;
+inline constexpr uint8_t PSBT_IN_HASH256 = 0x0D;
+inline constexpr uint8_t PSBT_IN_PREVIOUS_TXID = 0x0e;
+inline constexpr uint8_t PSBT_IN_OUTPUT_INDEX = 0x0f;
+inline constexpr uint8_t PSBT_IN_SEQUENCE = 0x10;
+inline constexpr uint8_t PSBT_IN_REQUIRED_TIME_LOCKTIME = 0x11;
+inline constexpr uint8_t PSBT_IN_REQUIRED_HEIGHT_LOCKTIME = 0x12;
+inline constexpr uint8_t PSBT_IN_TAP_KEY_SIG = 0x13;
+inline constexpr uint8_t PSBT_IN_TAP_SCRIPT_SIG = 0x14;
+inline constexpr uint8_t PSBT_IN_TAP_LEAF_SCRIPT = 0x15;
+inline constexpr uint8_t PSBT_IN_TAP_BIP32_DERIVATION = 0x16;
+inline constexpr uint8_t PSBT_IN_TAP_INTERNAL_KEY = 0x17;
+inline constexpr uint8_t PSBT_IN_TAP_MERKLE_ROOT = 0x18;
+inline constexpr uint8_t PSBT_IN_MUSIG2_PARTICIPANT_PUBKEYS = 0x1a;
+inline constexpr uint8_t PSBT_IN_MUSIG2_PUB_NONCE = 0x1b;
+inline constexpr uint8_t PSBT_IN_MUSIG2_PARTIAL_SIG = 0x1c;
+inline constexpr uint8_t PSBT_IN_PROPRIETARY = 0xFC;
// Output types
-static constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00;
-static constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01;
-static constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02;
-static constexpr uint8_t PSBT_OUT_AMOUNT = 0x03;
-static constexpr uint8_t PSBT_OUT_SCRIPT = 0x04;
-static constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05;
-static constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06;
-static constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07;
-static constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08;
-static constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC;
+inline constexpr uint8_t PSBT_OUT_REDEEMSCRIPT = 0x00;
+inline constexpr uint8_t PSBT_OUT_WITNESSSCRIPT = 0x01;
+inline constexpr uint8_t PSBT_OUT_BIP32_DERIVATION = 0x02;
+inline constexpr uint8_t PSBT_OUT_AMOUNT = 0x03;
+inline constexpr uint8_t PSBT_OUT_SCRIPT = 0x04;
+inline constexpr uint8_t PSBT_OUT_TAP_INTERNAL_KEY = 0x05;
+inline constexpr uint8_t PSBT_OUT_TAP_TREE = 0x06;
+inline constexpr uint8_t PSBT_OUT_TAP_BIP32_DERIVATION = 0x07;
+inline constexpr uint8_t PSBT_OUT_MUSIG2_PARTICIPANT_PUBKEYS = 0x08;
+inline constexpr uint8_t PSBT_OUT_PROPRIETARY = 0xFC;
// The separator is 0x00. Reading this in means that the unserializer can interpret it
// as a 0 length key which indicates that this is the separator. The separator has no value.
-static constexpr uint8_t PSBT_SEPARATOR = 0x00;
+inline constexpr uint8_t PSBT_SEPARATOR = 0x00;
// BIP 174 does not specify a maximum file size, but we set a limit anyway
// to prevent reading a stream indefinitely and running out of memory.
-const std::streamsize MAX_FILE_SIZE_PSBT = 100000000; // 100 MB
+inline constexpr std::streamsize MAX_FILE_SIZE_PSBT{100'000'000}; // 100 MB
// PSBT version number
-static constexpr uint32_t PSBT_HIGHEST_VERSION = 2;
+inline constexpr uint32_t PSBT_HIGHEST_VERSION = 2;
/** A structure for PSBT proprietary types */
struct PSBTProprietary
### src/pubkey.h
@@ -16,8 +16,8 @@
#include <optional>
#include <vector>
-const unsigned int BIP32_EXTKEY_SIZE = 74;
-const unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE = 78;
+inline constexpr unsigned int BIP32_EXTKEY_SIZE = 74;
+inline constexpr unsigned int BIP32_EXTKEY_WITH_VERSION_SIZE = 78;
using KeyFingerprint = std::array<unsigned char, 4>;
### src/qt/guiconstants.h
@@ -11,18 +11,18 @@
using namespace std::chrono_literals;
/* A delay between model updates */
-static constexpr auto MODEL_UPDATE_DELAY{250ms};
+inline constexpr auto MODEL_UPDATE_DELAY{250ms};
/* A delay between shutdown pollings */
-static constexpr auto SHUTDOWN_POLLING_DELAY{200ms};
+inline constexpr auto SHUTDOWN_POLLING_DELAY{200ms};
/* AskPassphraseDialog -- Maximum passphrase length */
-static const int MAX_PASSPHRASE_SIZE = 1024;
+inline constexpr int MAX_PASSPHRASE_SIZE = 1024;
/* BitcoinGUI -- Size of icons in status bar */
-static const int STATUSBAR_ICONSIZE = 16;
+inline constexpr int STATUSBAR_ICONSIZE = 16;
-static const bool DEFAULT_SPLASHSCREEN = true;
+inline constexpr bool DEFAULT_SPLASHSCREEN = true;
/* Invalid field background style */
#define STYLE_INVALID "border: 3px solid #FF8080"
@@ -41,7 +41,7 @@ static const bool DEFAULT_SPLASHSCREEN = true;
/* Tooltips longer than this (in characters) are converted into rich text,
so that they can be word-wrapped.
*/
-static const int TOOLTIP_WRAP_THRESHOLD = 80;
+inline constexpr int TOOLTIP_WRAP_THRESHOLD = 80;
/* Number of frames in spinner animation */
#define SPINNER_FRAMES 36
@@ -55,9 +55,9 @@ static const int TOOLTIP_WRAP_THRESHOLD = 80;
#define QAPP_APP_NAME_REGTEST "Bitcoin-Qt-regtest"
/* One gigabyte (GB) in bytes */
-static constexpr uint64_t GB_BYTES{1000000000};
+inline constexpr uint64_t GB_BYTES{1'000'000'000};
// Default prune target displayed in GUI.
-static constexpr int DEFAULT_PRUNE_TARGET_GB{2};
+inline constexpr int DEFAULT_PRUNE_TARGET_GB{2};
#endif // BITCOIN_QT_GUICONSTANTS_H
### src/qt/intro.h
@@ -11,7 +11,7 @@
#include <QMutex>
#include <QThread>
-static const bool DEFAULT_CHOOSE_DATADIR = false;
+inline constexpr bool DEFAULT_CHOOSE_DATADIR = false;
namespace interfaces {
class Node;
### src/qt/modaloverlay.h
@@ -10,7 +10,7 @@
#include <QWidget>
//! The required delta of headers to the estimated number of available headers until we show the IBD progress
-static constexpr int HEADER_HEIGHT_DELTA_SYNC = 24;
+inline constexpr int HEADER_HEIGHT_DELTA_SYNC = 24;
namespace Ui {
class ModalOverlay;
### src/qt/optionsmodel.h
@@ -22,7 +22,7 @@ class Node;
}
extern const char *DEFAULT_GUI_PROXY_HOST;
-static constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
+inline constexpr uint16_t DEFAULT_GUI_PROXY_PORT = 9050;
/**
* Convert configured prune target MiB to displayed GB. Round up to avoid underestimating max disk usage.
### src/qt/qrimagewidget.h
@@ -9,12 +9,12 @@
#include <QLabel>
/* Maximum allowed URI length */
-static const int MAX_URI_LENGTH = 255;
+inline constexpr int MAX_URI_LENGTH = 255;
/* Size of exported QR Code image */
-static constexpr int QR_IMAGE_SIZE = 300;
-static constexpr int QR_IMAGE_TEXT_MARGIN = 10;
-static constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN;
+inline constexpr int QR_IMAGE_SIZE = 300;
+inline constexpr int QR_IMAGE_TEXT_MARGIN = 10;
+inline constexpr int QR_IMAGE_MARGIN = 2 * QR_IMAGE_TEXT_MARGIN;
QT_BEGIN_NAMESPACE
class QMenu;
### src/rpc/blockchain.h
@@ -27,7 +27,7 @@ class BlockManager;
struct NodeContext;
} // namespace node
-static constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
+inline constexpr int NUM_GETBLOCKSTATS_PERCENTILES = 5;
/**
* Get the difficulty of the net wrt to the given block index.
### src/rpc/mining.h
@@ -8,6 +8,6 @@
#include <cstdint>
/** Default max iterations to try in RPC generatetodescriptor, generatetoaddress, and generateblock. */
-static const uint64_t DEFAULT_MAX_TRIES{1000000};
+inline constexpr uint64_t DEFAULT_MAX_TRIES{1'000'000};
#endif // BITCOIN_RPC_MINING_H
### src/rpc/util.h
@@ -43,7 +43,7 @@ namespace node {
enum class TransactionError;
} // namespace node
-static constexpr bool DEFAULT_RPC_DOC_CHECK{
+inline constexpr bool DEFAULT_RPC_DOC_CHECK{
#ifdef RPC_DOC_CHECK
true
#else
### src/script/interpreter.h
@@ -45,7 +45,7 @@ enum
* flags (A | B) is a subset of the acceptable scripts under flag (A).
*/
-static constexpr script_verify_flags SCRIPT_VERIFY_NONE{0};
+inline constexpr script_verify_flags SCRIPT_VERIFY_NONE{0};
enum class script_verify_flag_name : uint8_t {
// Evaluate P2SH subscripts (BIP16).
@@ -152,12 +152,12 @@ enum class script_verify_flag_name : uint8_t {
};
using enum script_verify_flag_name;
-static constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast<int>(SCRIPT_VERIFY_END_MARKER);
+inline constexpr int MAX_SCRIPT_VERIFY_FLAGS_BITS = static_cast<int>(SCRIPT_VERIFY_END_MARKER);
// assert there is still a spare bit
static_assert(0 < MAX_SCRIPT_VERIFY_FLAGS_BITS && MAX_SCRIPT_VERIFY_FLAGS_BITS <= 63);
-static constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1);
+inline constexpr script_verify_flags::value_type MAX_SCRIPT_VERIFY_FLAGS = ((script_verify_flags::value_type{1} << MAX_SCRIPT_VERIFY_FLAGS_BITS) - 1);
bool CheckSignatureEncoding(const std::vector<unsigned char> &vchSig, script_verify_flags flags, ScriptError* serror);
@@ -235,16 +235,16 @@ struct ScriptExecutionData
};
/** Signature hash sizes */
-static constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32;
-static constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20;
-static constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32;
-
-static constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe;
-static constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0;
-static constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33;
-static constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32;
-static constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128;
-static constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT;
+inline constexpr size_t WITNESS_V0_SCRIPTHASH_SIZE = 32;
+inline constexpr size_t WITNESS_V0_KEYHASH_SIZE = 20;
+inline constexpr size_t WITNESS_V1_TAPROOT_SIZE = 32;
+
+inline constexpr uint8_t TAPROOT_LEAF_MASK = 0xfe;
+inline constexpr uint8_t TAPROOT_LEAF_TAPSCRIPT = 0xc0;
+inline constexpr size_t TAPROOT_CONTROL_BASE_SIZE = 33;
+inline constexpr size_t TAPROOT_CONTROL_NODE_SIZE = 32;
+inline constexpr size_t TAPROOT_CONTROL_MAX_NODE_COUNT = 128;
+inline constexpr size_t TAPROOT_CONTROL_MAX_SIZE = TAPROOT_CONTROL_BASE_SIZE + TAPROOT_CONTROL_NODE_SIZE * TAPROOT_CONTROL_MAX_NODE_COUNT;
extern const HashWriter HASHER_TAPSIGHASH; //!< Hasher with tag "TapSighash" pre-fed to it.
extern const HashWriter HASHER_TAPLEAF; //!< Hasher with tag "TapLeaf" pre-fed to it.
### src/script/miniscript.h
@@ -268,18 +268,18 @@ constexpr bool IsTapscript(MiniscriptContext ms_ctx)
namespace internal {
//! The maximum size of a witness item for a Miniscript under Tapscript context. (A BIP340 signature with a sighash type byte.)
-static constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65};
+inline constexpr uint32_t MAX_TAPMINISCRIPT_STACK_ELEM_SIZE{65};
//! version + nLockTime
-constexpr uint32_t TX_OVERHEAD{4 + 4};
+inline constexpr uint32_t TX_OVERHEAD{4 + 4};
//! prevout + nSequence + scriptSig
-constexpr uint32_t TXIN_BYTES_NO_WITNESS{36 + 4 + 1};
+inline constexpr uint32_t TXIN_BYTES_NO_WITNESS{36 + 4 + 1};
//! nValue + script len + OP_0 + pushdata 32.
-constexpr uint32_t P2WSH_TXOUT_BYTES{8 + 1 + 1 + 33};
+inline constexpr uint32_t P2WSH_TXOUT_BYTES{8 + 1 + 1 + 33};
//! Data other than the witness in a transaction. Overhead + vin count + one vin + vout count + one vout + segwit marker
-constexpr uint32_t TX_BODY_LEEWAY_WEIGHT{(TX_OVERHEAD + GetSizeOfCompactSize(1) + TXIN_BYTES_NO_WITNESS + GetSizeOfCompactSize(1) + P2WSH_TXOUT_BYTES) * WITNESS_SCALE_FACTOR + 2};
+inline constexpr uint32_t TX_BODY_LEEWAY_WEIGHT{(TX_OVERHEAD + GetSizeOfCompactSize(1) + TXIN_BYTES_NO_WITNESS + GetSizeOfCompactSize(1) + P2WSH_TXOUT_BYTES) * WITNESS_SCALE_FACTOR + 2};
//! Maximum possible stack size to spend a Taproot output (excluding the script itself).
-constexpr uint32_t MAX_TAPSCRIPT_SAT_SIZE{GetSizeOfCompactSize(MAX_STACK_SIZE) + (GetSizeOfCompactSize(MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) + MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) * MAX_STACK_SIZE + GetSizeOfCompactSize(TAPROOT_CONTROL_MAX_SIZE) + TAPROOT_CONTROL_MAX_SIZE};
+inline constexpr uint32_t MAX_TAPSCRIPT_SAT_SIZE{GetSizeOfCompactSize(MAX_STACK_SIZE) + (GetSizeOfCompactSize(MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) + MAX_TAPMINISCRIPT_STACK_ELEM_SIZE) * MAX_STACK_SIZE + GetSizeOfCompactSize(TAPROOT_CONTROL_MAX_SIZE) + TAPROOT_CONTROL_MAX_SIZE};
/** The maximum size of a script depending on the context. */
constexpr uint32_t MaxScriptSize(MiniscriptContext ms_ctx)
{
@@ -342,15 +342,15 @@ struct InputStack {
};
/** A stack consisting of a single zero-length element (interpreted as 0 by the script interpreter in numeric context). */
-static const auto ZERO = InputStack(std::vector<unsigned char>());
+inline const auto ZERO = InputStack(std::vector<unsigned char>());
/** A stack consisting of a single malleable 32-byte 0x0000...0000 element (for dissatisfying hash challenges). */
-static const auto ZERO32 = InputStack(std::vector<unsigned char>(32, 0)).SetMalleable();
+inline const auto ZERO32 = InputStack(std::vector<unsigned char>(32, 0)).SetMalleable();
/** A stack consisting of a single 0x01 element (interpreted as 1 by the script interpreted in numeric context). */
-static const auto ONE = InputStack(Vector((unsigned char)1));
+inline const auto ONE = InputStack(Vector((unsigned char)1));
/** The empty stack. */
-static const auto EMPTY = InputStack();
+inline const auto EMPTY = InputStack();
/** A stack representing the lack of any (dis)satisfactions. */
-static const auto INVALID = InputStack().SetAvailable(Availability::NO);
+inline const auto INVALID = InputStack().SetAvailable(Availability::NO);
//! A pair of a satisfaction and a dissatisfaction InputStack.
struct InputResult {
### src/script/script.h
@@ -26,43 +26,43 @@
#include <vector>
// Maximum number of bytes pushable to the stack
-static const unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520;
+inline constexpr unsigned int MAX_SCRIPT_ELEMENT_SIZE = 520;
// Maximum number of non-push operations per script
-static const int MAX_OPS_PER_SCRIPT = 201;
+inline constexpr int MAX_OPS_PER_SCRIPT = 201;
// Maximum number of public keys per multisig
-static const int MAX_PUBKEYS_PER_MULTISIG = 20;
+inline constexpr int MAX_PUBKEYS_PER_MULTISIG = 20;
/** The limit of keys in OP_CHECKSIGADD-based scripts. It is due to the stack limit in BIP342. */
-static constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999;
+inline constexpr unsigned int MAX_PUBKEYS_PER_MULTI_A = 999;
// Maximum script length in bytes
-static const int MAX_SCRIPT_SIZE = 10000;
+inline constexpr int MAX_SCRIPT_SIZE{10'000};
// Maximum number of values on script interpreter stack
-static const int MAX_STACK_SIZE = 1000;
+inline constexpr int MAX_STACK_SIZE = 1000;
// Threshold for nLockTime: below this value it is interpreted as block number,
// otherwise as UNIX timestamp.
-static const unsigned int LOCKTIME_THRESHOLD = 500000000; // Tue Nov 5 00:53:20 1985 UTC
+inline constexpr unsigned int LOCKTIME_THRESHOLD{500'000'000}; // Tue Nov 5 00:53:20 1985 UTC
// Maximum nLockTime. Since a lock time indicates the last invalid timestamp, a
// transaction with this lock time will never be valid unless lock time
// checking is disabled (by setting all input sequence numbers to
// SEQUENCE_FINAL).
-static const uint32_t LOCKTIME_MAX = 0xFFFFFFFFU;
+inline constexpr uint32_t LOCKTIME_MAX = 0xFFFFFFFFU;
// Tag for input annex. If there are at least two witness elements for a transaction input,
// and the first byte of the last element is 0x50, this last element is called annex, and
// has meanings independent of the script
-static constexpr unsigned int ANNEX_TAG = 0x50;
+inline constexpr unsigned int ANNEX_TAG = 0x50;
// Validation weight per passing signature (Tapscript only, see BIP 342).
-static constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50};
+inline constexpr int64_t VALIDATION_WEIGHT_PER_SIGOP_PASSED{50};
// How much weight budget is added to the witness size (Tapscript only, see BIP 342).
-static constexpr int64_t VALIDATION_WEIGHT_OFFSET{50};
+inline constexpr int64_t VALIDATION_WEIGHT_OFFSET{50};
template <typename T>
std::vector<unsigned char> ToByteVector(const T& in)
@@ -214,7 +214,7 @@ enum opcodetype
};
// Maximum value that an opcode can be
-static const unsigned int MAX_OPCODE = OP_NOP10;
+inline constexpr unsigned int MAX_OPCODE = OP_NOP10;
std::string GetOpName(opcodetype opcode);
### src/script/sigcache.h
@@ -28,9 +28,9 @@ class XOnlyPubKey;
// DoS prevention: limit cache size to 32MiB (over 1000000 entries on 64-bit
// systems). Due to how we count cache size, actual memory usage is slightly
// more (~32.25 MiB)
-static constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB};
-static constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2};
-static constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2};
+inline constexpr size_t DEFAULT_VALIDATION_CACHE_BYTES{32_MiB};
+inline constexpr size_t DEFAULT_SIGNATURE_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2};
+inline constexpr size_t DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES{DEFAULT_VALIDATION_CACHE_BYTES / 2};
static_assert(DEFAULT_VALIDATION_CACHE_BYTES == DEFAULT_SIGNATURE_CACHE_BYTES + DEFAULT_SCRIPT_EXECUTION_CACHE_BYTES);
/**
### src/serialize.h
@@ -32,10 +32,10 @@
* The maximum size of a serialized object in bytes or number of elements
* (for eg vectors) when the size is encoded as CompactSize.
*/
-static constexpr uint64_t MAX_SIZE = 0x02000000;
+inline constexpr uint64_t MAX_SIZE = 0x02000000;
/** Maximum amount of memory (in bytes) to allocate at once when deserializing vectors. */
-static const unsigned int MAX_VECTOR_ALLOCATE = 5000000;
+inline constexpr unsigned int MAX_VECTOR_ALLOCATE{5'000'000};
/**
* Dummy data type to identify deserializing constructors.
@@ -49,7 +49,7 @@ static const unsigned int MAX_VECTOR_ALLOCATE = 5000000;
* is likely the only way to do so.
*/
struct deserialize_type {};
-constexpr deserialize_type deserialize {};
+inline constexpr deserialize_type deserialize {};
/*
* Lowest-level serialization and conversion.
### src/test/fuzz/util/descriptor.h
@@ -49,7 +49,7 @@ class MockedDescriptorConverter {
};
//! Default maximum number of derivation indexes in a single derivation path when limiting its depth.
-constexpr int MAX_DEPTH{2};
+inline constexpr int MAX_DEPTH{2};
/**
* Whether the buffer, if it represents a valid descriptor, contains a derivation path deeper than
@@ -58,9 +58,9 @@ constexpr int MAX_DEPTH{2};
bool HasDeepDerivPath(std::span<const uint8_t> buff, int max_depth = MAX_DEPTH);
//! Default maximum number of sub-fragments.
-constexpr int MAX_SUBS{1'000};
+inline constexpr int MAX_SUBS{1'000};
//! Maximum number of nested sub-fragments we'll allow in a descriptor.
-constexpr size_t MAX_NESTED_SUBS{10'000};
+inline constexpr size_t MAX_NESTED_SUBS{10'000};
/**
* Whether the buffer, if it represents a valid descriptor, contains a fragment with more
@@ -70,7 +70,7 @@ bool HasTooManySubFrag(std::span<const uint8_t> buff, int max_subs = MAX_SUBS,
size_t max_nested_subs = MAX_NESTED_SUBS);
//! Default maximum number of wrappers per fragment.
-constexpr int MAX_WRAPPERS{100};
+inline constexpr int MAX_WRAPPERS{100};
/**
* Whether the buffer, if it represents a valid descriptor, contains a fragment with more
@@ -80,7 +80,7 @@ bool HasTooManyWrappers(std::span<const uint8_t> buff, int max_wrappers = MAX_WR
/// Default maximum leaf size. This should be large enough to cover an extended
/// key, including paths "/", inside and outside of "[]".
-constexpr uint32_t MAX_LEAF_SIZE{200};
+inline constexpr uint32_t MAX_LEAF_SIZE{200};
/// Whether the expanded buffer (after calling GetDescriptor() in
/// MockedDescriptorConverter) has a leaf size too large.
### src/test/util/chainstate.h
@@ -17,7 +17,7 @@
#include <univalue.h>
-const auto NoMalleation = [](AutoFile& file, node::SnapshotMetadata& meta){};
+inline constexpr auto NoMalleation = [](AutoFile& file, node::SnapshotMetadata& meta){};
/**
* Create and activate a UTXO snapshot, optionally providing a function to
### src/test/util/net.h
@@ -118,7 +118,7 @@ struct ConnmanTestMsg : public CConnman {
EXCLUSIVE_LOCKS_REQUIRED(!m_unused_i2p_sessions_mutex);
};
-constexpr ServiceFlags ALL_SERVICE_FLAGS[]{
+inline constexpr ServiceFlags ALL_SERVICE_FLAGS[]{
NODE_NONE,
NODE_NETWORK,
NODE_BLOOM,
@@ -128,7 +128,7 @@ constexpr ServiceFlags ALL_SERVICE_FLAGS[]{
NODE_P2P_V2,
};
-constexpr NetPermissionFlags ALL_NET_PERMISSION_FLAGS[]{
+inline constexpr NetPermissionFlags ALL_NET_PERMISSION_FLAGS[]{
NetPermissionFlags::None,
NetPermissionFlags::BloomFilter,
NetPermissionFlags::Relay,
@@ -141,7 +141,7 @@ constexpr NetPermissionFlags ALL_NET_PERMISSION_FLAGS[]{
NetPermissionFlags::All,
};
-constexpr ConnectionType ALL_CONNECTION_TYPES[]{
+inline constexpr ConnectionType ALL_CONNECTION_TYPES[]{
ConnectionType::INBOUND,
ConnectionType::OUTBOUND_FULL_RELAY,
ConnectionType::MANUAL,
@@ -151,7 +151,7 @@ constexpr ConnectionType ALL_CONNECTION_TYPES[]{
ConnectionType::PRIVATE_BROADCAST,
};
-constexpr auto ALL_NETWORKS = std::array{
+inline constexpr auto ALL_NETWORKS = std::array{
Network::NET_UNROUTABLE,
Network::NET_IPV4,
Network::NET_IPV6,
### src/test/util/script.h
@@ -9,8 +9,8 @@
#include <script/script.h>
#include <script/verify_flags.h>
-static const std::vector<uint8_t> WITNESS_STACK_ELEM_OP_TRUE{uint8_t{OP_TRUE}};
-static const CScript P2WSH_OP_TRUE{
+inline const std::vector<uint8_t> WITNESS_STACK_ELEM_OP_TRUE{uint8_t{OP_TRUE}};
+inline const CScript P2WSH_OP_TRUE{
CScript{}
<< OP_0
<< ToByteVector([] {
@@ -19,17 +19,17 @@ static const CScript P2WSH_OP_TRUE{
return hash;
}())};
-static const std::vector<uint8_t> EMPTY{};
-static const CScript P2WSH_EMPTY{
+inline const std::vector<uint8_t> EMPTY{};
+inline const CScript P2WSH_EMPTY{
CScript{}
<< OP_0
<< ToByteVector([] {
uint256 hash;
CSHA256().Write(EMPTY.data(), EMPTY.size()).Finalize(hash.begin());
return hash;
}())};
-static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TRUE_STACK{{static_cast<uint8_t>(OP_TRUE)}, {}};
-static const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TWO_STACK{{static_cast<uint8_t>(OP_2)}, {}};
+inline const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TRUE_STACK{{static_cast<uint8_t>(OP_TRUE)}, {}};
+inline const std::vector<std::vector<uint8_t>> P2WSH_EMPTY_TWO_STACK{{static_cast<uint8_t>(OP_2)}, {}};
/** Flags that are not forbidden by an assert in script validation */
bool IsValidFlagCombination(script_verify_flags flags);
### src/test/util/setup_common.h
@@ -38,7 +38,7 @@ extern const std::function<std::vector<const char*>()> G_TEST_COMMAND_LINE_ARGUM
/** Retrieve the unit test name. */
extern const std::function<std::string()> G_TEST_GET_FULL_NAME;
-static constexpr CAmount CENT{1000000};
+inline constexpr CAmount CENT{1'000'000};
/** Register common test args. Shared across binaries that rely on the test framework. */
void SetupCommonTestArgs(ArgsManager& argsman);
### src/test/util/versionbits.h
@@ -8,6 +8,6 @@
#include <versionbits.h>
/** Total possible bits available for versionbits per original BIP 9 specification */
-static constexpr int VERSIONBITS_MAX_NUM_BITS{29};
+inline constexpr int VERSIONBITS_MAX_NUM_BITS{29};
#endif // BITCOIN_TEST_UTIL_VERSIONBITS_H
### src/torcontrol.h
@@ -21,15 +21,15 @@
#include <thread>
#include <vector>
-constexpr uint16_t DEFAULT_TOR_SOCKS_PORT{9050};
-constexpr int DEFAULT_TOR_CONTROL_PORT = 9051;
+inline constexpr uint16_t DEFAULT_TOR_SOCKS_PORT{9050};
+inline constexpr int DEFAULT_TOR_CONTROL_PORT = 9051;
extern const std::string DEFAULT_TOR_CONTROL;
-static const bool DEFAULT_LISTEN_ONION = true;
+inline constexpr bool DEFAULT_LISTEN_ONION = true;
/** Tor control reply code. Ref: https://spec.torproject.org/control-spec/replies.html */
-constexpr int TOR_REPLY_OK{250};
-constexpr int TOR_REPLY_UNRECOGNIZED{510};
-constexpr int TOR_REPLY_SYNTAX_ERROR{512}; //!< Syntax error in command argument
+inline constexpr int TOR_REPLY_OK{250};
+inline constexpr int TOR_REPLY_UNRECOGNIZED{510};
+inline constexpr int TOR_REPLY_SYNTAX_ERROR{512}; //!< Syntax error in command argument
CService DefaultOnionServiceTarget(uint16_t port);
### src/txgraph.h
@@ -15,7 +15,7 @@
#ifndef BITCOIN_TXGRAPH_H
#define BITCOIN_TXGRAPH_H
-static constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64};
+inline constexpr unsigned MAX_CLUSTER_COUNT_LIMIT{64};
/** Data structure to encapsulate fees, sizes, and dependencies for a set of transactions.
*
### src/txmempool.h
@@ -47,15 +47,15 @@ class ValidationSignals;
struct bilingual_str;
/** Fake height value used in Coin to signify they are only in the memory pool (since 0.8) */
-static const uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
+inline constexpr uint32_t MEMPOOL_HEIGHT = 0x7FFFFFFF;
/** How much linearization cost required for TxGraph clusters to have
* "acceptable" quality, if they cannot be optimally linearized with less cost. */
-static constexpr uint64_t ACCEPTABLE_COST = 75'000;
+inline constexpr uint64_t ACCEPTABLE_COST = 75'000;
/** How much work we ask TxGraph to do after a mempool change occurs (either
* due to a changeset being applied, a new block being found, or a reorg). */
-static constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST;
+inline constexpr uint64_t POST_CHANGE_COST = 5 * ACCEPTABLE_COST;
/**
* Test whether the LockPoints height and time are still valid on the current chain
### src/univalue/include/univalue_escapes.h
@@ -5,7 +5,7 @@
#ifndef BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
#define BITCOIN_UNIVALUE_INCLUDE_UNIVALUE_ESCAPES_H
-static const char *escapes[256] = {
+inline constexpr const char* escapes[256]{
"\\u0000",
"\\u0001",
"\\u0002",
### src/util/check.h
@@ -18,14 +18,14 @@
#include <type_traits>
#include <utility>
-constexpr bool G_FUZZING_BUILD{
+inline constexpr bool G_FUZZING_BUILD{
#ifdef FUZZING_BUILD_MODE_UNSAFE_FOR_PRODUCTION
true
#else
false
#endif
};
-constexpr bool G_ABORT_ON_FAILED_ASSUME{G_FUZZING_BUILD ||
+inline constexpr bool G_ABORT_ON_FAILED_ASSUME{G_FUZZING_BUILD ||
#ifdef ABORT_ON_FAILED_ASSUME
true
#else
### src/util/rbf.h
@@ -9,7 +9,7 @@
class CTransaction;
-static constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
+inline constexpr uint32_t MAX_BIP125_RBF_SEQUENCE{0xfffffffd};
/** Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,
* according to BIP 125. Allow opt-out of transaction replacement by setting nSequence >
### src/util/sock.h
@@ -21,7 +21,7 @@ class CThreadInterrupt;
* Maximum time to wait for I/O readiness.
* It will take up until this time to break off in case of an interruption.
*/
-static constexpr auto MAX_WAIT_FOR_IO = 1s;
+inline constexpr auto MAX_WAIT_FOR_IO = 1s;
inline bool IOErrorIsPermanent(int err)
{
### src/util/string.h
@@ -23,7 +23,7 @@
namespace util {
namespace detail {
template <unsigned num_params>
-constexpr static void CheckNumFormatSpecifiers(const char* str)
+constexpr void CheckNumFormatSpecifiers(const char* str)
{
unsigned count_normal{0}; // Number of "normal" specifiers, like %s
unsigned count_pos{0}; // Max number in positional specifier, like %8$s
### src/util/subprocess.h
@@ -110,12 +110,12 @@ namespace subprocess {
// Max buffer size allocated on stack for read error
// from pipe
-static const size_t SP_MAX_ERR_BUF_SIZ = 1024;
+inline constexpr size_t SP_MAX_ERR_BUF_SIZ = 1024;
// Default buffer capacity for OutBuffer and ErrBuffer.
// If the data exceeds this capacity, the buffer size is grown
// by 1.5 times its previous capacity
-static const size_t DEFAULT_BUF_CAP_BYTES = 8192;
+inline constexpr size_t DEFAULT_BUF_CAP_BYTES = 8192;
/*-----------------------------------------------
### src/validation.h
@@ -73,9 +73,9 @@ class SignalInterrupt;
} // namespace util
/** Block files containing a block-height within MIN_BLOCKS_TO_KEEP of ActiveChain().Tip() will not be pruned. */
-static const unsigned int MIN_BLOCKS_TO_KEEP = 288;
-static const signed int DEFAULT_CHECKBLOCKS = 6;
-static constexpr int DEFAULT_CHECKLEVEL{3};
+inline constexpr unsigned int MIN_BLOCKS_TO_KEEP = 288;
+inline constexpr signed int DEFAULT_CHECKBLOCKS = 6;
+inline constexpr int DEFAULT_CHECKLEVEL{3};
// Require that user allocate at least 550 MiB for block & undo files (blk???.dat and rev???.dat)
// At 1MB per block, 288 blocks = 288MB.
// Add 15% for Undo data = 331MB
@@ -84,13 +84,13 @@ static constexpr int DEFAULT_CHECKLEVEL{3};
// full block file chunks, we need the high water mark which triggers the prune to be
// one 128MB block file + added 15% undo data = 147MB greater for a total of 545MB
// Setting the target to >= 550 MiB will make it likely we can respect the target.
-static const uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB};
+inline constexpr uint64_t MIN_DISK_SPACE_FOR_BLOCK_FILES{550_MiB};
/** Maximum number of dedicated script-checking threads allowed */
-static constexpr int MAX_SCRIPTCHECK_THREADS{15};
+inline constexpr int MAX_SCRIPTCHECK_THREADS{15};
/** Maximum number of dedicated threads allowed for prefetching block input prevouts */
-static constexpr int32_t MAX_PREVOUTFETCH_THREADS{16};
+inline constexpr int32_t MAX_PREVOUTFETCH_THREADS{16};
/** Current sync state passed to tip changed callbacks. */
enum class SynchronizationState {
### src/versionbits.h
@@ -16,13 +16,13 @@
class CChainParams;
/** What block version to use for new blocks (pre versionbits) */
-static const int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4;
+inline constexpr int32_t VERSIONBITS_LAST_OLD_BLOCK_VERSION = 4;
/** What bits to set in version for versionbits blocks */
-static const int32_t VERSIONBITS_TOP_BITS = 0x20000000UL;
+inline constexpr int32_t VERSIONBITS_TOP_BITS = 0x20000000UL;
/** What bitmask determines whether versionbits is in use */
-static const int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL;
+inline constexpr int32_t VERSIONBITS_TOP_MASK = 0xE0000000UL;
/** Total bits available for versionbits (BIP 323) */
-static const int32_t VERSIONBITS_NUM_BITS = 5;
+inline constexpr int32_t VERSIONBITS_NUM_BITS = 5;
/** Opaque type for BIP9 state. See versionbits_impl.h for details. */
enum class ThresholdState : uint8_t;
### src/wallet/coincontrol.h
@@ -19,13 +19,13 @@
#include <set>
namespace wallet {
-const int DEFAULT_MIN_DEPTH = 0;
-const int DEFAULT_MAX_DEPTH = 9999999;
+inline constexpr int DEFAULT_MIN_DEPTH = 0;
+inline constexpr int DEFAULT_MAX_DEPTH = 9'999'999;
-const int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION;
+inline constexpr int DEFAULT_WALLET_TX_VERSION = CTransaction::CURRENT_VERSION;
//! Default for -avoidpartialspends
-static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false;
+inline constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false;
class PreselectedInput
{
### src/wallet/coinselection.h
@@ -20,9 +20,9 @@
namespace wallet {
//! lower bound for randomly-chosen target change amount
-static constexpr CAmount CHANGE_LOWER{50000};
+inline constexpr CAmount CHANGE_LOWER{50'000};
//! upper bound for randomly-chosen target change amount
-static constexpr CAmount CHANGE_UPPER{1000000};
+inline constexpr CAmount CHANGE_UPPER{1'000'000};
/** A UTXO under consideration for use in funding a new transaction. */
struct COutput {
### src/wallet/crypter.h
@@ -11,9 +11,9 @@
namespace wallet {
-const unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
-const unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
-const unsigned int WALLET_CRYPTO_IV_SIZE = 16;
+inline constexpr unsigned int WALLET_CRYPTO_KEY_SIZE = 32;
+inline constexpr unsigned int WALLET_CRYPTO_SALT_SIZE = 8;
+inline constexpr unsigned int WALLET_CRYPTO_IV_SIZE = 16;
/**
* Private key encryption is done based on a CMasterKey,
### src/wallet/rpc/util.h
@@ -27,7 +27,7 @@ struct WalletContext;
extern const std::string HELP_REQUIRING_PASSPHRASE;
-static const RPCResult RESULT_LAST_PROCESSED_BLOCK { RPCResult::Type::OBJ, "lastprocessedblock", "hash and height of the block this information was generated on",{
+inline const RPCResult RESULT_LAST_PROCESSED_BLOCK { RPCResult::Type::OBJ, "lastprocessedblock", "hash and height of the block this information was generated on",{
{RPCResult::Type::STR_HEX, "hash", "hash of the block this information was generated on"},
{RPCResult::Type::NUM, "height", "height of the block this information was generated on"}}
};
### src/wallet/scriptpubkeyman.h
@@ -58,10 +58,10 @@ class WalletStorage
};
//! Constant representing an unknown spkm creation time
-static constexpr int64_t UNKNOWN_TIME = std::numeric_limits<int64_t>::max();
+inline constexpr int64_t UNKNOWN_TIME = std::numeric_limits<int64_t>::max();
//! Default for -keypool
-static const unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
+inline constexpr unsigned int DEFAULT_KEYPOOL_SIZE = 1000;
std::vector<CKeyID> GetAffectedKeys(const CScript& spk, const SigningProvider& provider);
@@ -161,7 +161,7 @@ class ScriptPubKeyMan
};
/** OutputTypes supported by the LegacyScriptPubKeyMan */
-static const std::unordered_set<OutputType> LEGACY_OUTPUT_TYPES {
+inline const std::unordered_set<OutputType> LEGACY_OUTPUT_TYPES {
OutputType::LEGACY,
OutputType::P2SH_SEGWIT,
OutputType::BECH32,
### src/wallet/test/util.h
@@ -25,11 +25,11 @@ class CWallet;
class WalletDatabase;
struct WalletContext;
-static const DatabaseFormat DATABASE_FORMATS[] = {
+inline constexpr DatabaseFormat DATABASE_FORMATS[] = {
DatabaseFormat::SQLITE,
};
-const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj";
+inline const std::string ADDRESS_BCRT1_UNSPENDABLE = "bcrt1qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq3xueyj";
std::unique_ptr<CWallet> CreateSyncedWallet(interfaces::Chain& chain, CChain& cchain, const CKey& key);
### src/wallet/wallet.h
@@ -103,51 +103,51 @@ void NotifyWalletLoaded(WalletContext& context, const std::shared_ptr<CWallet>&
std::unique_ptr<WalletDatabase> MakeWalletDatabase(const std::string& name, const DatabaseOptions& options, DatabaseStatus& status, bilingual_str& error);
//! -fallbackfee default
-static const CAmount DEFAULT_FALLBACK_FEE = 0;
+inline constexpr CAmount DEFAULT_FALLBACK_FEE = 0;
//! -discardfee default
-static const CAmount DEFAULT_DISCARD_FEE = 10000;
+inline constexpr CAmount DEFAULT_DISCARD_FEE{10'000};
//! -mintxfee default
-static const CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
+inline constexpr CAmount DEFAULT_TRANSACTION_MINFEE = 1000;
//! -consolidatefeerate default
-static const CAmount DEFAULT_CONSOLIDATE_FEERATE{10000}; // 10 sat/vbyte
+inline constexpr CAmount DEFAULT_CONSOLIDATE_FEERATE{10'000}; // 10 sat/vbyte
/**
* maximum fee increase allowed to do partial spend avoidance, even for nodes with this feature disabled by default
*
* A value of -1 disables this feature completely.
* A value of 0 (current default) means to attempt to do partial spend avoidance, and use its results if the fees remain *unchanged*
* A value > 0 means to do partial spend avoidance if the fee difference against a regular coin selection instance is in the range [0..value].
*/
-static const CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0;
+inline constexpr CAmount DEFAULT_MAX_AVOIDPARTIALSPEND_FEE = 0;
//! discourage APS fee higher than this amount
-constexpr CAmount HIGH_APS_FEE{COIN / 10000};
+inline constexpr CAmount HIGH_APS_FEE{COIN / 10000};
//! minimum recommended increment for replacement txs
-static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
+inline constexpr CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
//! Default for -spendzeroconfchange
-static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
+inline constexpr bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
//! Default for -walletrejectlongchains
-static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS{true};
+inline constexpr bool DEFAULT_WALLET_REJECT_LONG_CHAINS{true};
//! -txconfirmtarget default
-static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
+inline constexpr unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
//! -walletrbf default
-static const bool DEFAULT_WALLET_RBF = true;
-static const bool DEFAULT_WALLETBROADCAST = true;
-static const bool DEFAULT_DISABLE_WALLET = false;
-static const bool DEFAULT_WALLETCROSSCHAIN = false;
+inline constexpr bool DEFAULT_WALLET_RBF = true;
+inline constexpr bool DEFAULT_WALLETBROADCAST = true;
+inline constexpr bool DEFAULT_DISABLE_WALLET = false;
+inline constexpr bool DEFAULT_WALLETCROSSCHAIN = false;
//! -maxtxfee default
-constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10};
+inline constexpr CAmount DEFAULT_TRANSACTION_MAXFEE{COIN / 10};
//! Discourage users to set fees higher than this amount (in satoshis) per kB
-constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
+inline constexpr CAmount HIGH_TX_FEE_PER_KB{COIN / 100};
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
-constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
+inline constexpr CAmount HIGH_MAX_TX_FEE{100 * HIGH_TX_FEE_PER_KB};
//! Pre-calculated constants for input size estimation in *virtual size*
-static constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
+inline constexpr size_t DUMMY_NESTED_P2WPKH_INPUT_SIZE = 91;
class CCoinControl;
//! Default for -addresstype
-constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32};
+inline constexpr OutputType DEFAULT_ADDRESS_TYPE{OutputType::BECH32};
-static constexpr uint64_t KNOWN_WALLET_FLAGS =
+inline constexpr uint64_t KNOWN_WALLET_FLAGS =
WALLET_FLAG_AVOID_REUSE
| WALLET_FLAG_BLANK_WALLET
| WALLET_FLAG_KEY_ORIGIN_METADATA
@@ -156,10 +156,10 @@ static constexpr uint64_t KNOWN_WALLET_FLAGS =
| WALLET_FLAG_DESCRIPTORS
| WALLET_FLAG_EXTERNAL_SIGNER;
-static constexpr uint64_t MUTABLE_WALLET_FLAGS =
+inline constexpr uint64_t MUTABLE_WALLET_FLAGS =
WALLET_FLAG_AVOID_REUSE;
-static const std::map<WalletFlags, std::string> WALLET_FLAG_TO_STRING{
+inline const std::map<WalletFlags, std::string> WALLET_FLAG_TO_STRING{
{WALLET_FLAG_AVOID_REUSE, "avoid_reuse"},
{WALLET_FLAG_BLANK_WALLET, "blank"},
{WALLET_FLAG_KEY_ORIGIN_METADATA, "key_origin_metadata"},
@@ -169,7 +169,7 @@ static const std::map<WalletFlags, std::string> WALLET_FLAG_TO_STRING{
{WALLET_FLAG_EXTERNAL_SIGNER, "external_signer"}
};
-static const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{
+inline const std::map<std::string, WalletFlags> STRING_TO_WALLET_FLAG{
{WALLET_FLAG_TO_STRING.at(WALLET_FLAG_AVOID_REUSE), WALLET_FLAG_AVOID_REUSE},
{WALLET_FLAG_TO_STRING.at(WALLET_FLAG_BLANK_WALLET), WALLET_FLAG_BLANK_WALLET},
{WALLET_FLAG_TO_STRING.at(WALLET_FLAG_KEY_ORIGIN_METADATA), WALLET_FLAG_KEY_ORIGIN_METADATA},
### src/zmq/zmqutil.h
@@ -10,6 +10,6 @@
void zmqError(const std::string& str);
/** Prefix for unix domain socket addresses (which are local filesystem paths) */
-const std::string ADDR_PREFIX_IPC = "ipc://"; // used by libzmq, example "ipc:///root/path/to/file"
+inline const std::string ADDR_PREFIX_IPC = "ipc://"; // used by libzmq, example "ipc:///root/path/to/file"
#endif // BITCOIN_ZMQ_ZMQUTIL_HWhy this scored 15/100
Community notes
Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.
The AI analysis stands alone for now. Submit a note if you can add evidence or important context.