Skip to content

Commit e8528d0

Browse files
committed
Drop bogus debug assertion that we don't overpay on fees
We should always select at least as many coins as is required to meet the feerate target, but its perfectly fine if we overshoot. Specifically, we may overshoot deliberately if we choose to burn change to fee instead.
1 parent 3c8467d commit e8528d0

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lightning/src/events/bump_transaction.rs

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -704,11 +704,9 @@ where
704704

705705
let expected_package_fee = Amount::from_sat(fee_for_weight(package_target_feerate_sat_per_1000_weight,
706706
signed_tx_weight + commitment_tx.weight().to_wu()));
707-
// Our fee should be within a 5% error margin of the expected fee based on the
708-
// feerate and transaction weight and we should never pay less than required.
709-
let fee_error_margin = expected_package_fee * 5 / 100;
710-
assert!(package_fee >= expected_package_fee &&
711-
package_fee - fee_error_margin <= expected_package_fee);
707+
// Our feerate should always be at least what we were seeking. It may overshoot if
708+
// the coin selector burned funds to an OP_RETURN without a change output.
709+
assert!(package_fee >= expected_package_fee);
712710
}
713711

714712
log_info!(self.logger, "Broadcasting anchor transaction {} to bump channel close with txid {}",
@@ -812,11 +810,9 @@ where
812810
let expected_signed_tx_fee = fee_for_weight(target_feerate_sat_per_1000_weight, signed_tx_weight);
813811
let signed_tx_fee = total_input_amount -
814812
htlc_tx.output.iter().map(|output| output.value.to_sat()).sum::<u64>();
815-
// Our fee should be within a 5% error margin of the expected fee based on the
816-
// feerate and transaction weight and we should never pay less than required.
817-
let fee_error_margin = expected_signed_tx_fee * 5 / 100;
818-
assert!(signed_tx_fee >= expected_signed_tx_fee &&
819-
signed_tx_fee - fee_error_margin <= expected_signed_tx_fee);
813+
// Our feerate should always be at least what we were seeking. It may overshoot if
814+
// the coin selector burned funds to an OP_RETURN without a change output.
815+
assert!(signed_tx_fee >= expected_signed_tx_fee);
820816
}
821817

822818
log_info!(self.logger, "Broadcasting {}", log_tx!(htlc_tx));

0 commit comments

Comments
 (0)