@@ -1276,10 +1276,13 @@ fn feerate_bump<F: Deref, L: Logger>(
12761276where
12771277 F :: Target : FeeEstimator ,
12781278{
1279+ let previous_fee = previous_feerate * predicted_weight / 1000 ;
1280+
12791281 // If old feerate inferior to actual one given back by Fee Estimator, use it to compute new fee...
12801282 let ( new_fee, new_feerate) = if let Some ( ( new_fee, new_feerate) ) =
12811283 compute_fee_from_spent_amounts ( input_amounts, predicted_weight, conf_target, fee_estimator, logger)
12821284 {
1285+ log_trace ! ( logger, "Initiating fee rate bump from {} s/kWU ({} s) to {} s/kWU ({} s)" , previous_feerate, previous_fee, new_feerate, new_fee) ;
12831286 match feerate_strategy {
12841287 FeerateStrategy :: RetryPrevious => {
12851288 let previous_fee = previous_feerate * predicted_weight / 1000 ;
@@ -1297,6 +1300,8 @@ where
12971300 // ...else just increase the previous feerate by 25% (because that's a nice number)
12981301 let bumped_feerate = previous_feerate + ( previous_feerate / 4 ) ;
12991302 let bumped_fee = bumped_feerate * predicted_weight / 1000 ;
1303+ log_trace ! ( logger, "Attempting forced 25% fee rate bump from {} s/kWU ({} s) to {} s/kWU ({} s)" , previous_feerate, previous_fee, bumped_feerate, bumped_fee) ;
1304+
13001305 if input_amounts <= bumped_fee {
13011306 log_warn ! ( logger, "Can't 25% bump new claiming tx, amount {} is too small" , input_amounts) ;
13021307 return None ;
@@ -1316,17 +1321,16 @@ where
13161321 return Some ( ( new_fee, new_feerate) ) ;
13171322 }
13181323
1319- let previous_fee = previous_feerate * predicted_weight / 1000 ;
13201324 let min_relay_fee = INCREMENTAL_RELAY_FEE_SAT_PER_1000_WEIGHT * predicted_weight / 1000 ;
13211325 // BIP 125 Opt-in Full Replace-by-Fee Signaling
13221326 // * 3. The replacement transaction pays an absolute fee of at least the sum paid by the original transactions.
13231327 // * 4. The replacement transaction must also pay for its own bandwidth at or above the rate set by the node's minimum relay fee setting.
1324- let new_fee = if new_fee < previous_fee + min_relay_fee {
1325- new_fee + previous_fee + min_relay_fee - new_fee
1326- } else {
1327- new_fee
1328- } ;
1329- Some ( ( new_fee, new_fee * 1000 / predicted_weight ) )
1328+ let naive_new_fee = new_fee;
1329+ let naive_new_feerate = new_feerate ;
1330+ let new_fee = cmp :: max ( new_fee , previous_fee + min_relay_fee ) ;
1331+ let new_feerate = new_fee * 1000 / predicted_weight ;
1332+ log_trace ! ( logger , "Fee rate bumped by {}s from {} s/KWU ({} s) to {} s/KWU ({} s) (naive: {} s/KWU ({} s))" , new_fee - previous_fee , previous_feerate , previous_fee , new_feerate , new_fee , naive_new_feerate , naive_new_fee ) ;
1333+ Some ( ( new_fee, new_feerate ) )
13301334}
13311335
13321336#[ cfg( test) ]
0 commit comments