You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Extend OnchainTxHandler::generate_claim to optionally force feerate bump
In the next commit, we plan to extend the `OnchainTxHandler` to retry
pending claims on a timer. This timer may fire with much more frequency
than incoming blocks, so we want to avoid manually bumping feerates
(currently by 25%) each time our fee estimator provides a lower feerate
than before.
// If old feerate inferior to actual one given back by Fee Estimator, use it to compute new fee...
956
-
let new_fee = if let Some((new_fee, _)) = compute_fee_from_spent_amounts(input_amounts, predicted_weight, fee_estimator, logger) {
957
-
let updated_feerate = new_fee / (predicted_weight as u64 * 1000);
958
-
if updated_feerate > previous_feerate {
959
-
new_fee
971
+
let (new_fee, new_feerate) = if let Some((new_fee, new_feerate)) = compute_fee_from_spent_amounts(input_amounts, predicted_weight, fee_estimator, logger) {
972
+
if new_feerate > previous_feerate {
973
+
(new_fee, new_feerate)
974
+
} else if !force_feerate_bump {
975
+
let previous_fee = previous_feerate * (predicted_weight as u64) / 1000;
976
+
(previous_fee, previous_feerate)
960
977
} else {
961
978
// ...else just increase the previous feerate by 25% (because that's a nice number)
962
-
let new_fee = previous_feerate * (predicted_weight as u64) / 750;
963
-
if input_amounts <= new_fee {
979
+
let bumped_feerate = previous_feerate + (previous_feerate / 4);
980
+
let bumped_fee = bumped_feerate * (predicted_weight as u64) / 1000;
981
+
if input_amounts <= bumped_fee {
964
982
log_warn!(logger, "Can't 25% bump new claiming tx, amount {} is too small", input_amounts);
965
983
return None;
966
984
}
967
-
new_fee
985
+
(bumped_fee, bumped_feerate)
968
986
}
969
987
} else {
970
988
log_warn!(logger, "Can't new-estimation bump new claiming tx, amount {} is too small", input_amounts);
971
989
return None;
972
990
};
973
991
992
+
// Our feerates should never decrease. If it hasn't changed though, we just need to
993
+
// rebroadcast/re-sign the previous claim.
994
+
debug_assert!(new_feerate >= previous_feerate);
995
+
if new_feerate == previous_feerate {
996
+
return Some((new_fee, new_feerate));
997
+
}
998
+
974
999
let previous_fee = previous_feerate * (predicted_weight as u64) / 1000;
975
1000
let min_relay_fee = MIN_RELAY_FEE_SAT_PER_1000_WEIGHT * (predicted_weight as u64) / 1000;
0 commit comments