31 uint64_t noLimit = std::numeric_limits<uint64_t>::max();
57 uint64_t nConflictingCount = 0;
58 for (
const auto& mi : iters_conflicting) {
59 nConflictingCount += mi->GetCountWithDescendants();
65 return strprintf(
"rejecting replacement %s; too many potential replacements (%d > %d)\n",
83 std::set<uint256> parents_of_conflicts;
84 for (
const auto& mi : iters_conflicting) {
85 for (
const CTxIn& txin : mi->GetTx().vin) {
86 parents_of_conflicts.insert(txin.prevout.hash);
90 for (
unsigned int j = 0; j < tx.
vin.size(); j++) {
98 if (!parents_of_conflicts.count(tx.
vin[j].prevout.hash)) {
102 return strprintf(
"replacement %s adds unconfirmed input, idx %d",
111 const std::set<uint256>& direct_conflicts,
115 const uint256& hashAncestor = ancestorIt->GetTx().GetHash();
116 if (direct_conflicts.count(hashAncestor)) {
117 return strprintf(
"%s spends conflicting transaction %s",
129 for (
const auto& mi : iters_conflicting) {
140 CFeeRate original_feerate(mi->GetModifiedFee(), mi->GetTxSize());
141 if (replacement_feerate <= original_feerate) {
142 return strprintf(
"rejecting replacement %s; new feerate %s <= old feerate %s",
153 size_t replacement_vsize,
160 if (replacement_fees < original_fees) {
161 return strprintf(
"rejecting replacement %s, less fees than conflicting txs; %s < %s",
168 CAmount additional_fees = replacement_fees - original_fees;
169 if (additional_fees < relay_fee.
GetFee(replacement_vsize)) {
170 return strprintf(
"rejecting replacement %s, not enough additional fees to relay; %s < %s",
int64_t CAmount
Amount in satoshis (Can be negative)
Fee rate in satoshis per kilobyte: CAmount / kB.
std::string ToString(const FeeEstimateMode &fee_estimate_mode=FeeEstimateMode::BTC_KVB) const
CAmount GetFee(uint32_t num_bytes) const
Return the fee in satoshis for the given size in bytes.
The basic transaction that is broadcasted on the network and contained in blocks.
const uint256 & GetHash() const
const std::vector< CTxIn > vin
An input of a transaction.
CTxMemPoolEntry stores data about the corresponding transaction, as well as data about all in-mempool...
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
RecursiveMutex cs
This mutex needs to be locked when accessing mapTx or other members that are guarded by it.
bool CalculateMemPoolAncestors(const CTxMemPoolEntry &entry, setEntries &setAncestors, uint64_t limitAncestorCount, uint64_t limitAncestorSize, uint64_t limitDescendantCount, uint64_t limitDescendantSize, std::string &errString, bool fSearchForParents=true) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Try to calculate all in-mempool ancestors of entry.
std::set< txiter, CompareIteratorByHash > setEntries
indexed_transaction_set::nth_index< 0 >::type::const_iterator txiter
bool exists(const GenTxid >xid) const
void CalculateDescendants(txiter it, setEntries &setDescendants) const EXCLUSIVE_LOCKS_REQUIRED(cs)
Populate setDescendants with all in-mempool descendants of hash.
static GenTxid Txid(const uint256 &hash)
std::string ToString() const
std::string FormatMoney(const CAmount n)
Money parsing/formatting utilities.
std::optional< std::string > HasNoNewUnconfirmed(const CTransaction &tx, const CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting)
BIP125 Rule #2: "The replacement transaction may only include an unconfirmed input if that input was ...
std::optional< std::string > PaysForRBF(CAmount original_fees, CAmount replacement_fees, size_t replacement_vsize, CFeeRate relay_fee, const uint256 &txid)
Enforce BIP125 Rule #3 "The replacement transaction pays an absolute fee of at least the sum paid by ...
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction &tx)
std::optional< std::string > EntriesAndTxidsDisjoint(const CTxMemPool::setEntries &ancestors, const std::set< uint256 > &direct_conflicts, const uint256 &txid)
Check the intersection between two sets of transactions (a set of mempool entries and a set of txids)...
std::optional< std::string > PaysMoreThanConflicts(const CTxMemPool::setEntries &iters_conflicting, CFeeRate replacement_feerate, const uint256 &txid)
Check that the feerate of the replacement transaction(s) is higher than the feerate of each of the tr...
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...
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.
static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES
Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5).
RBFTransactionState
The rbf state of unconfirmed transactions.
@ UNKNOWN
Unconfirmed tx that does not signal rbf and is not in the mempool.
@ FINAL
Neither this tx nor a mempool ancestor signals rbf.
@ REPLACEABLE_BIP125
Either this tx or a mempool ancestor signals rbf.
bool SignalsOptInRBF(const CTransaction &tx)
Check whether the sequence numbers on this transaction are signaling opt-in to replace-by-fee,...