Bitcoin Core  24.99.0
P2P Digital Currency
rbf.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2022 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 
13 #include <cstddef>
14 #include <cstdint>
15 #include <optional>
16 #include <set>
17 #include <string>
18 
19 class CFeeRate;
20 class uint256;
21 
24 static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES{100};
25 
27 enum class RBFTransactionState {
29  UNKNOWN,
33  FINAL,
34 };
35 
49 
60 std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& pool,
61  const CTxMemPool::setEntries& iters_conflicting,
62  CTxMemPool::setEntries& all_conflicts)
63  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
64 
69 std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTxMemPool& pool,
70  const CTxMemPool::setEntries& iters_conflicting)
71  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
72 
82 std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
83  const std::set<uint256>& direct_conflicts,
84  const uint256& txid);
85 
91 std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& iters_conflicting,
92  CFeeRate replacement_feerate, const uint256& txid);
93 
103 std::optional<std::string> PaysForRBF(CAmount original_fees,
104  CAmount replacement_fees,
105  size_t replacement_vsize,
106  CFeeRate relay_fee,
107  const uint256& txid);
108 
109 #endif // BITCOIN_POLICY_RBF_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Fee rate in satoshis per kilovirtualbyte: CAmount / kvB.
Definition: feerate.h:33
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:295
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:316
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:411
256-bit opaque blob.
Definition: uint256.h:105
std::optional< std::string > HasNoNewUnconfirmed(const CTransaction &tx, const CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
The replacement transaction may only include an unconfirmed input if that input was included in one o...
Definition: rbf.cpp:84
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...
Definition: rbf.cpp:131
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:21
std::optional< std::string > PaysForRBF(CAmount original_fees, CAmount replacement_fees, size_t replacement_vsize, CFeeRate relay_fee, const uint256 &txid)
The replacement transaction must pay more fees than the original transactions.
Definition: rbf.cpp:157
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction &tx)
Definition: rbf.cpp:50
RBFTransactionState
The rbf state of unconfirmed transactions.
Definition: rbf.h:27
@ 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.
static constexpr uint32_t MAX_REPLACEMENT_CANDIDATES
Maximum number of transactions that can be replaced by RBF (Rule #5).
Definition: rbf.h:24
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)...
Definition: rbf.cpp:116
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:56
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49