13 #include <txmempool.h> 71 return strprintf(
"rejecting replacement %s; too many conflicting clusters (%u > %d)",
86 const std::set<Txid>& direct_conflicts,
90 const Txid& hashAncestor = ancestorIt->GetTx().GetHash();
91 if (direct_conflicts.contains(hashAncestor)) {
92 return strprintf(
"%s spends conflicting transaction %s",
102 size_t replacement_vsize,
109 if (replacement_fees < original_fees) {
110 return strprintf(
"rejecting replacement %s, less fees than conflicting txs; %s < %s",
117 CAmount additional_fees = replacement_fees - original_fees;
118 if (additional_fees < relay_fee.
GetFee(replacement_vsize)) {
119 return strprintf(
"rejecting replacement %s, not enough additional fees to relay; %s < %s",
132 if (!chunk_results.has_value()) {
136 if (!std::is_gt(
CompareChunks(chunk_results.value().second, chunk_results.value().first))) {
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
std::optional< std::string > EntriesAndTxidsDisjoint(const CTxMemPool::setEntries &ancestors, const std::set< Txid > &direct_conflicts, const Txid &txid)
Check the intersection between two sets of transactions (a set of mempool entries and a set of txids)...
RBFTransactionState IsRBFOptIn(const CTransaction &tx, const CTxMemPool &pool)
Determine whether an unconfirmed transaction is signaling opt-in to RBF according to BIP 125 This inv...
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES
Maximum number of unique clusters that can be affected by an RBF (Rule #5); see GetEntriesForConflict...
Either this tx or a mempool ancestor signals rbf.
Unconfirmed tx that does not signal rbf and is not in the mempool.
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of given transaction.
std::set< txiter, CompareIteratorByHash > setEntries
bool SignalsOptInRBF(const CTransaction &tx)
Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee, according to BIP 125.
Unable to calculate due to topology or other reason.
RBFTransactionState
The rbf state of unconfirmed transactions.
size_t GetUniqueClusterCount(const setEntries &iters_conflicting) const EXCLUSIVE_LOCKS_REQUIRED(cs)
std::optional< std::string > GetEntriesForConflicts(const CTransaction &tx, CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting, CTxMemPool::setEntries &all_conflicts)
Get all descendants of iters_conflicting.
int64_t CAmount
Amount in satoshis (Can be negative)
std::partial_ordering CompareChunks(std::span< const FeeFrac > chunks0, std::span< const FeeFrac > chunks1)
Compare the feerate diagrams implied by the provided sorted chunks data.
util::Result< std::pair< std::vector< FeeFrac >, std::vector< FeeFrac > > > CalculateChunksForRBF()
Calculate the sorted chunks for the old and new mempool relating to the clusters that would be affect...
std::optional< std::string > PaysForRBF(CAmount original_fees, CAmount replacement_fees, size_t replacement_vsize, CFeeRate relay_fee, const Txid &txid)
The replacement transaction must pay more fees than the original transactions.
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction &tx)
setEntries CalculateMemPoolAncestors(const CTxMemPoolEntry &entry) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Calculate all in-mempool ancestors of entry (not including the tx itself)
std::string ToString() const
bool exists(const Txid &txid) const
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
const CTxMemPoolEntry * GetEntry(const Txid &txid) const LIFETIMEBOUND EXCLUSIVE_LOCKS_REQUIRED(cs)
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
bilingual_str ErrorString(const Result< T > &result)
The basic transaction that is broadcasted on the network and contained in blocks. ...
std::optional< std::pair< DiagramCheckError, std::string > > ImprovesFeerateDiagram(CTxMemPool::ChangeSet &changeset)
The replacement transaction must improve the feerate diagram of the mempool.
CAmount GetFee(int32_t virtual_bytes) const
Return the fee in satoshis for the given vsize in vbytes.
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it...
#define Assert(val)
Identity function.
const Txid & GetHash() const LIFETIMEBOUND
Neither this tx nor a mempool ancestor signals rbf.
New diagram wasn't strictly superior.