aboutsummaryrefslogtreecommitdiff
path: root/src/interfaces/chain.h
diff options
context:
space:
mode:
authorglozow <gloriajzhao@gmail.com>2022-03-09 11:23:22 +0000
committerMurch <murch@murch.one>2023-09-13 14:33:55 -0400
commitc57889da6650715f3e1153b6104bbdae15fcac90 (patch)
treec00ff6b76f469fe1b55bc11862ebae8347753139 /src/interfaces/chain.h
parentc24851be945b2a633ee44ed3c8a501eee5580b62 (diff)
downloadbitcoin-c57889da6650715f3e1153b6104bbdae15fcac90.tar.xz
[node] interface to get bump fees
Diffstat (limited to 'src/interfaces/chain.h')
-rw-r--r--src/interfaces/chain.h37
1 files changed, 37 insertions, 0 deletions
diff --git a/src/interfaces/chain.h b/src/interfaces/chain.h
index dd664165d3..b5243725ad 100644
--- a/src/interfaces/chain.h
+++ b/src/interfaces/chain.h
@@ -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.