aboutsummaryrefslogtreecommitdiff
path: root/src/policy/rbf.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/policy/rbf.h')
-rw-r--r--src/policy/rbf.h28
1 files changed, 27 insertions, 1 deletions
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
index fff9828482..252fbec8e3 100644
--- a/src/policy/rbf.h
+++ b/src/policy/rbf.h
@@ -9,7 +9,9 @@
#include <primitives/transaction.h>
#include <threadsafety.h>
#include <txmempool.h>
+#include <util/feefrac.h>
+#include <compare>
#include <cstddef>
#include <cstdint>
#include <optional>
@@ -33,6 +35,13 @@ enum class RBFTransactionState {
FINAL,
};
+enum class DiagramCheckError {
+ /** Unable to calculate due to topology or other reason */
+ UNCALCULABLE,
+ /** New diagram wasn't strictly superior */
+ FAILURE,
+};
+
/**
* Determine whether an unconfirmed transaction is signaling opt-in to RBF
* according to BIP 125
@@ -80,7 +89,7 @@ std::optional<std::string> HasNoNewUnconfirmed(const CTransaction& tx, const CTx
* @returns error message if the sets intersect, std::nullopt if they are disjoint.
*/
std::optional<std::string> EntriesAndTxidsDisjoint(const CTxMemPool::setEntries& ancestors,
- const std::set<uint256>& direct_conflicts,
+ const std::set<Txid>& direct_conflicts,
const uint256& txid);
/** Check that the feerate of the replacement transaction(s) is higher than the feerate of each
@@ -106,4 +115,21 @@ std::optional<std::string> PaysForRBF(CAmount original_fees,
CFeeRate relay_fee,
const uint256& txid);
+/**
+ * The replacement transaction must improve the feerate diagram of the mempool.
+ * @param[in] pool The mempool.
+ * @param[in] direct_conflicts Set of in-mempool txids corresponding to the direct conflicts i.e.
+ * input double-spends with the proposed transaction
+ * @param[in] all_conflicts Set of mempool entries corresponding to all transactions to be evicted
+ * @param[in] replacement_fees Fees of proposed replacement package
+ * @param[in] replacement_vsize Size of proposed replacement package
+ * @returns error type and string if mempool diagram doesn't improve, otherwise std::nullopt.
+ */
+std::optional<std::pair<DiagramCheckError, std::string>> ImprovesFeerateDiagram(CTxMemPool& pool,
+ const CTxMemPool::setEntries& direct_conflicts,
+ const CTxMemPool::setEntries& all_conflicts,
+ CAmount replacement_fees,
+ int64_t replacement_vsize)
+ EXCLUSIVE_LOCKS_REQUIRED(pool.cs);
+
#endif // BITCOIN_POLICY_RBF_H