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