[node] interface to get bump fees

This commit is contained in:
glozow
2022-03-09 11:23:22 +00:00
committed by Murch
parent c24851be94
commit c57889da66
2 changed files with 58 additions and 0 deletions

View File

@@ -216,6 +216,43 @@ public:
//! Calculate mempool ancestor and descendant counts for the given transaction.
virtual void getTransactionAncestry(const uint256& txid, size_t& ancestors, size_t& descendants, size_t* ancestorsize = nullptr, CAmount* ancestorfees = nullptr) = 0;
//! For each outpoint, calculate the fee-bumping cost to spend this outpoint at the specified
// feerate, including bumping its ancestors. For example, if the target feerate is 10sat/vbyte
// and this outpoint refers to a mempool transaction at 3sat/vbyte, the bump fee includes the
// cost to bump the mempool transaction to 10sat/vbyte (i.e. 7 * mempooltx.vsize). If that
// transaction also has, say, an unconfirmed parent with a feerate of 1sat/vbyte, the bump fee
// includes the cost to bump the parent (i.e. 9 * parentmempooltx.vsize).
//
// If the outpoint comes from an unconfirmed transaction that is already above the target
// feerate or bumped by its descendant(s) already, it does not need to be bumped. Its bump fee
// is 0. Likewise, if any of the transaction's ancestors are already bumped by a transaction
// in our mempool, they are not included in the transaction's bump fee.
//
// Also supported is bump-fee calculation in the case of replacements. If an outpoint
// conflicts with another transaction in the mempool, it is assumed that the goal is to replace
// that transaction. As such, the calculation will exclude the to-be-replaced transaction, but
// will include the fee-bumping cost. If bump fees of descendants of the to-be-replaced
// transaction are requested, the value will be 0. Fee-related RBF rules are not included as
// they are logically distinct.
//
// Any outpoints that are otherwise unavailable from the mempool (e.g. UTXOs from confirmed
// transactions or transactions not yet broadcast by the wallet) are given a bump fee of 0.
//
// If multiple outpoints come from the same transaction (which would be very rare because
// it means that one transaction has multiple change outputs or paid the same wallet using multiple
// outputs in the same transaction) or have shared ancestry, the bump fees are calculated
// independently, i.e. as if only one of them is spent. This may result in double-fee-bumping. This
// caveat can be rectified per use of the sister-function CalculateCombinedBumpFee(…).
virtual std::map<COutPoint, CAmount> CalculateIndividualBumpFees(const std::vector<COutPoint>& outpoints, const CFeeRate& target_feerate) = 0;
//! Calculate the combined bump fee for an input set per the same strategy
// as in CalculateIndividualBumpFees(…).
// Unlike CalculateIndividualBumpFees(…), this does not return individual
// bump fees per outpoint, but a single bump fee for the shared ancestry.
// The combined bump fee may be used to correct overestimation due to
// shared ancestry by multiple UTXOs after coin selection.
virtual std::optional<CAmount> CalculateCombinedBumpFee(const std::vector<COutPoint>& outpoints, const CFeeRate& target_feerate) = 0;
//! Get the node's package limits.
//! Currently only returns the ancestor and descendant count limits, but could be enhanced to
//! return more policy settings.