Bitcoin Core  27.99.0
P2P Digital Currency
Go to the documentation of this file.
1 // Copyright (c) 2022 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or
8 #include <consensus/amount.h>
9 #include <policy/packages.h>
10 #include <policy/policy.h>
11 #include <primitives/transaction.h>
12 #include <txmempool.h>
13 #include <util/result.h>
15 #include <set>
16 #include <string>
18 // This module enforces rules for transactions with nVersion=3 ("v3 transactions") which help make
19 // RBF abilities more robust.
21 // v3 only allows 1 parent and 1 child when unconfirmed.
23 static constexpr unsigned int V3_DESCENDANT_LIMIT{2};
25 static constexpr unsigned int V3_ANCESTOR_LIMIT{2};
28 static constexpr int64_t V3_CHILD_MAX_VSIZE{1000};
29 // These limits are within the default ancestor/descendant limits.
59 std::optional<std::pair<std::string, CTransactionRef>> SingleV3Checks(const CTransactionRef& ptx,
60  const CTxMemPool::setEntries& mempool_ancestors,
61  const std::set<Txid>& direct_conflicts,
62  int64_t vsize);
85 std::optional<std::string> PackageV3Checks(const CTransactionRef& ptx, int64_t vsize,
86  const Package& package,
87  const CTxMemPool::setEntries& mempool_ancestors);
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:395
static const int WITNESS_SCALE_FACTOR
Definition: consensus.h:21
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
Definition: packages.h:50
static constexpr unsigned int DEFAULT_ANCESTOR_SIZE_LIMIT_KVB
Default for -limitancestorsize, maximum kilobytes of tx + all in-mempool ancestors.
Definition: policy.h:61
static constexpr unsigned int DEFAULT_DESCENDANT_SIZE_LIMIT_KVB
Default for -limitdescendantsize, maximum kilobytes of in-mempool descendants.
Definition: policy.h:65
static constexpr int32_t MAX_STANDARD_TX_WEIGHT
The maximum weight for transactions we're willing to relay/mine.
Definition: policy.h:27
std::shared_ptr< const CTransaction > CTransactionRef
Definition: transaction.h:423
static constexpr unsigned int V3_DESCENDANT_LIMIT
Maximum number of transactions including an unconfirmed tx and its descendants.
Definition: v3_policy.h:23
static constexpr int64_t V3_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed v3 transaction.
Definition: v3_policy.h:28
std::optional< std::string > PackageV3Checks(const CTransactionRef &ptx, int64_t vsize, const Package &package, const CTxMemPool::setEntries &mempool_ancestors)
Must be called for every transaction that is submitted within a package, even if not v3.
Definition: v3_policy.cpp:58
std::optional< std::pair< std::string, CTransactionRef > > SingleV3Checks(const CTransactionRef &ptx, const CTxMemPool::setEntries &mempool_ancestors, const std::set< Txid > &direct_conflicts, int64_t vsize)
Must be called for every transaction, even if not v3.
Definition: v3_policy.cpp:162
static constexpr unsigned int V3_ANCESTOR_LIMIT
Maximum number of transactions including a V3 tx and all its mempool ancestors.
Definition: v3_policy.h:25