+macro_rules! subtract_high_prio_fee {
+ ($self: ident, $fee_estimator: expr, $value: expr, $predicted_weight: expr, $spent_txid: expr) => {
+ {
+ let mut fee = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::HighPriority) * $predicted_weight / 1000;
+ if $value <= fee {
+ fee = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Normal) * $predicted_weight / 1000;
+ if $value <= fee {
+ fee = $fee_estimator.get_est_sat_per_1000_weight(ConfirmationTarget::Background) * $predicted_weight / 1000;
+ if $value <= fee {
+ log_error!($self, "Failed to generate an on-chain punishment tx spending {} as even low priority fee ({} sat) was more than the entire claim balance ({} sat)",
+ $spent_txid, fee, $value);
+ false
+ } else {
+ log_warn!($self, "Used low priority fee for on-chain punishment tx spending {} as high priority fee was more than the entire claim balance ({} sat)",
+ $spent_txid, $value);
+ $value -= fee;
+ true
+ }
+ } else {
+ log_warn!($self, "Used medium priority fee for on-chain punishment tx spending {} as high priority fee was more than the entire claim balance ({} sat)",
+ $spent_txid, $value);
+ $value -= fee;
+ true
+ }
+ } else {
+ $value -= fee;
+ true
+ }
+ }
+ }
+}
+