Bitcoin Core  31.0.0
P2P Digital Currency
rbf.h
Go to the documentation of this file.
1 // Copyright (c) 2016-present The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_POLICY_RBF_H
6 #define BITCOIN_POLICY_RBF_H
7 
8 #include <consensus/amount.h>
10 #include <threadsafety.h>
11 #include <txmempool.h>
12 #include <util/feefrac.h>
13 
14 #include <compare>
15 #include <cstddef>
16 #include <cstdint>
17 #include <optional>
18 #include <set>
19 #include <string>
20 
21 class CFeeRate;
22 class uint256;
23 
26 static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
27 
29 enum class RBFTransactionState {
31  UNKNOWN,
35  FINAL,
36 };
37 
38 enum class DiagramCheckError {
42  FAILURE,
43 };
44 
58 
69 std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& pool,
70  const CTxMemPool::setEntries& iters_conflicting,
71  CTxMemPool::setEntries& all_conflicts)
72  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
73 
83 std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
84  const std::set<Txid>& direct_conflicts,
85  const Txid& txid);
86 
96 std::optional<std::string> PaysForRBF(CAmount original_fees,
97  CAmount replacement_fees,
98  size_t replacement_vsize,
99  CFeeRate relay_fee,
100  const Txid& txid);
101 
107 std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool::ChangeSet& changeset);
108 
109 #endif // BITCOIN_POLICY_RBF_H
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction &tx)
Definition: rbf.cpp:52
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES
Maximum number of unique clusters that can be affected by an RBF (Rule #5); see GetEntriesForConflict...
Definition: rbf.h:26
Either this tx or a mempool ancestor signals rbf.
Unconfirmed tx that does not signal rbf and is not in the mempool.
DiagramCheckError
Definition: rbf.h:38
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.
Definition: rbf.cpp:100
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:268
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)...
Definition: rbf.cpp:85
Unable to calculate due to topology or other reason.
RBFTransactionState
The rbf state of unconfirmed transactions.
Definition: rbf.h:29
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
RBFTransactionState IsRBFOptIn(const CTransaction &tx, const CTxMemPool &pool) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
Determine whether an unconfirmed transaction is signaling opt-in to RBF according to BIP 125 This inv...
Definition: rbf.cpp:24
std::optional< std::string > GetEntriesForConflicts(const CTransaction &tx, CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting, CTxMemPool::setEntries &all_conflicts) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
Get all descendants of iters_conflicting.
Definition: rbf.cpp:58
256-bit opaque blob.
Definition: uint256.h:195
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:186
Fee rate in satoshis per virtualbyte: CAmount / vB the feerate is represented internally as FeeFrac...
Definition: feerate.h:31
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:280
Neither this tx nor a mempool ancestor signals rbf.
std::optional< std::pair< DiagramCheckError, std::string > > ImprovesFeerateDiagram(CTxMemPool::ChangeSet &changeset)
The replacement transaction must improve the feerate diagram of the mempool.
Definition: rbf.cpp:127
New diagram wasn&#39;t strictly superior.