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.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/src/policy/rbf.h b/src/policy/rbf.h
index 5a33ed64a3..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
@@ -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