Skip to content

Commit b3644dc

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 d383ac4 commit b3644dc

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

lightning/src/events/bump_transaction.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -703,11 +703,9 @@ where
703703

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

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

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

0 commit comments

Comments
 (0)