Bitcoin Core  22.99.0
P2P Digital Currency
rbf.h
Go to the documentation of this file.
1 // Copyright (c) 2016-2020 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 
9 #include <txmempool.h>
10 #include <uint256.h>
11 
12 #include <optional>
13 #include <string>
14 
17 static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES{100};
18 
20 enum class RBFTransactionState {
22  UNKNOWN,
26  FINAL,
27 };
28 
42 
53 std::optional<std::string> GetEntriesForConflicts(const CTransaction& tx, CTxMemPool& pool,
54  const CTxMemPool::setEntries& iters_conflicting,
55  CTxMemPool::setEntries& all_conflicts)
56  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
57 
61 std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTxMemPool& pool,
62  const CTxMemPool::setEntries& iters_conflicting)
63  EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
64 
74 std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
75  const std::set<uint256>& direct_conflicts,
76  const uint256& txid);
77 
83 std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& iters_conflicting,
84  CFeeRate replacement_feerate, const uint256& txid);
85 
96 std::optional<std::string> PaysForRBF(CAmount original_fees,
97  CAmount replacement_fees,
98  size_t replacement_vsize,
99  CFeeRate relay_fee,
100  const uint256& txid);
101 
102 #endif // BITCOIN_POLICY_RBF_H
CTxMemPool::setEntries
std::set< txiter, CompareIteratorByHash > setEntries
Definition: txmempool.h:569
PaysMoreThanConflicts
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:125
transaction.h
RBFTransactionState
RBFTransactionState
The rbf state of unconfirmed transactions.
Definition: rbf.h:20
MAX_BIP125_REPLACEMENT_CANDIDATES
static constexpr uint32_t MAX_BIP125_REPLACEMENT_CANDIDATES
Maximum number of transactions that can be replaced by BIP125 RBF (Rule #5).
Definition: rbf.h:17
CTxMemPool
CTxMemPool stores valid-according-to-the-current-best-chain transactions that may be included in the ...
Definition: txmempool.h:475
uint256.h
GetEntriesForConflicts
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:50
CFeeRate
Fee rate in satoshis per kilobyte: CAmount / kB.
Definition: feerate.h:29
IsRBFOptIn
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:12
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
txmempool.h
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
uint256
256-bit opaque blob.
Definition: uint256.h:124
HasNoNewUnconfirmed
std::optional< std::string > HasNoNewUnconfirmed(const CTransaction &tx, const CTxMemPool &pool, const CTxMemPool::setEntries &iters_conflicting) EXCLUSIVE_LOCKS_REQUIRED(pool.cs)
BIP125 Rule #2: "The replacement transaction may only include an unconfirmed input if that input was ...
Definition: rbf.cpp:78
RBFTransactionState::FINAL
@ FINAL
Neither this tx nor a mempool ancestor signals rbf.
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
IsRBFOptInEmptyMempool
RBFTransactionState IsRBFOptInEmptyMempool(const CTransaction &tx)
Definition: rbf.cpp:44
RBFTransactionState::UNKNOWN
@ UNKNOWN
Unconfirmed tx that does not signal rbf and is not in the mempool.
EntriesAndTxidsDisjoint
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:110
RBFTransactionState::REPLACEABLE_BIP125
@ REPLACEABLE_BIP125
Either this tx or a mempool ancestor signals rbf.
PaysForRBF
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 ...
Definition: rbf.cpp:151