7#include <chainparams.h>
27 .signals =
node.validation_signals.get(),
61 for (
const auto& tx :
txns) {
62 const auto&
wtxid = tx->GetWitnessHash();
75 return strprintf(
"tx %s result replaced too many transactions",
81 atmp_result.m_wtxids_fee_calculations.has_value() &&
atmp_result.m_wtxids_fee_calculations.value().size() > 2) {
82 return strprintf(
"tx %s was part of a too-large package RBF subpackage",
86 if (!
atmp_result.m_replaced_transactions.empty() && mempool) {
89 if (
atmp_result.m_wtxids_fee_calculations.has_value() &&
atmp_result.m_wtxids_fee_calculations.value().size() == 2) {
91 if (cluster.size() != 2)
return strprintf(
"tx %s has too many ancestors or descendants for a package rbf",
wtxid.ToString());
115 return strprintf(
"tx %s result should %shave m_effective_feerate",
116 wtxid.ToString(), valid ?
"" :
"not ");
119 return strprintf(
"tx %s result should %shave m_effective_feerate",
120 wtxid.ToString(), valid ?
"" :
"not ");
132 return strprintf(
"wtxid %s should not be in mempool",
wtxid.ToString());
137 return strprintf(
"tx %s should not be in mempool as it was replaced",
tx_ref->GetWitnessHash().ToString());
158 Assert(entry.GetFee() == 0 && entry.GetModifiedFee() == 0);
161 const auto& children =
tx_pool.GetChildren(entry);
165 Assert(children.size() < 2);
167 if (children.empty()) {
174 const auto&
only_child = children.begin()->get().GetTx();
177 return txin.prevout == dust_outpoint;
203 const auto& parents =
tx_pool.GetParents(entry);
208 for (
const auto& parent :
tx_pool.GetParents(entry)) {
CScript GetScriptForDestination(const CTxDestination &dest)
Generate a Bitcoin scriptPubKey for the given CTxDestination.
static constexpr CAmount COIN
The amount of satoshis in one BTC.
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac.
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
An outpoint - a combination of a transaction hash and an index n into its vout.
Serialized script, used inside transaction inputs and outputs.
An input of a transaction.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
const LockPoints & GetLockPoints() const
uint64_t GetSequence() const
unsigned int GetHeight() const
std::chrono::seconds GetTime() const
bool GetSpendsCoinbase() const
int64_t GetSigOpCost() const
CTransactionRef GetSharedTx() const
const CAmount & GetFee() const
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
std::unique_ptr< ChangeSet > GetChangeSet() EXCLUSIVE_LOCKS_REQUIRED(cs)
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
CFeeRate GetMinFee(size_t sizelimit) const
void TrimToSize(size_t sizelimit, std::vector< COutPoint > *pvNoSpendsRemaining=nullptr) EXCLUSIVE_LOCKS_REQUIRED(cs)
Remove transactions from the mempool until its dynamic size is <= sizelimit.
bool exists(const Txid &txid) const
std::vector< txiter > GatherClusters(const std::vector< Txid > &txids) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Collect the entire cluster of connected transactions for each transaction in txids.
unsigned long size() const
std::string ToString() const
static transaction_identifier FromUint256(const uint256 &id)
@ TX_RECONSIDERABLE
fails some policy, but might be acceptable if submitted in a (different) package
RecursiveMutex cs_main
Mutex to guard access to validation specific variables, such as reading or changing the chainstate.
util::Result< void > ApplyArgsManOptions(const ArgsManager &argsman, const CChainParams &chainparams, MemPoolOptions &mempool_opts)
Overlay the options set in argsman on top of corresponding members in mempool_opts.
std::vector< CTransactionRef > Package
A package is an ordered list of transactions.
@ PCKG_POLICY
The package itself is invalid (e.g. too many transactions).
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES
Maximum number of unique clusters that can be affected by an RBF (Rule #5); see GetEntriesForConflict...
int64_t GetVirtualTransactionSize(int64_t nWeight, int64_t nSigOpCost, unsigned int bytes_per_sigop)
Compute the virtual transaction size (weight reinterpreted as bytes).
std::vector< uint32_t > GetDust(const CTransaction &tx, CFeeRate dust_relay_rate)
Get the vout index numbers of all dust outputs.
static CTransactionRef MakeTransactionRef(Tx &&txIn)
std::shared_ptr< const CTransaction > CTransactionRef
A mutable version of CTransaction.
@ DIFFERENT_WITNESS
Valid, transaction was already in the mempool.
@ INVALID
Fully validated, valid.
Validation result for package mempool acceptance.
PackageValidationState m_state
std::map< Wtxid, MempoolAcceptResult > m_tx_results
Map from wtxid to finished MempoolAcceptResults.
CTxMemPoolEntry FromTx(const CMutableTransaction &tx) const
Options struct containing options for constructing a CTxMemPool.
CFeeRate incremental_relay_feerate
CFeeRate min_relay_feerate
A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation)
NodeContext struct containing references to chain state and connection state.
void CheckMempoolTRUCInvariants(const CTxMemPool &tx_pool)
For every transaction in tx_pool, check TRUC invariants:
CTxMemPool::Options MemPoolOptionsForTest(const NodeContext &node)
std::optional< std::string > CheckPackageMempoolAcceptResult(const Package &txns, const PackageMempoolAcceptResult &result, bool expect_valid, const CTxMemPool *mempool)
Check expected properties for every PackageMempoolAcceptResult, regardless of value.
void CheckMempoolEphemeralInvariants(const CTxMemPool &tx_pool)
Check that we never get into a state where an ephemeral dust transaction would be mined without the s...
void TryAddToMempool(CTxMemPool &tx_pool, const CTxMemPoolEntry &entry)
One-line wrapper for creating a mempool changeset with a single transaction and applying it if the po...
void MockMempoolMinFee(const CFeeRate &target_feerate, CTxMemPool &mempool)
Mock the mempool minimum feerate by adding a transaction and calling TrimToSize(0),...
void BulkTransaction(CMutableTransaction &tx, int32_t target_weight)
static constexpr unsigned int TRUC_DESCENDANT_LIMIT
Maximum number of transactions including an unconfirmed tx and its descendants.
static constexpr int64_t TRUC_CHILD_MAX_VSIZE
Maximum sigop-adjusted virtual size of a tx which spends from an unconfirmed TRUC transaction.
static constexpr decltype(CTransaction::version) TRUC_VERSION
static constexpr int64_t TRUC_MAX_VSIZE
Maximum sigop-adjusted virtual size of all v3 transactions.
static constexpr unsigned int TRUC_ANCESTOR_LIMIT
Maximum number of transactions including a TRUC tx and all its mempool ancestors.
constexpr auto Ticks(Dur2 d)
Helper to count the seconds of a duration/time_point.