]> git.bitcoin.ninja Git - rust-lightning/commitdiff
Drop bogus debug assertion that we don't overpay on fees
authorMatt Corallo <git@bluematt.me>
Thu, 29 Aug 2024 22:47:32 +0000 (22:47 +0000)
committerMatt Corallo <git@bluematt.me>
Tue, 3 Sep 2024 14:15:28 +0000 (14:15 +0000)
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.

lightning/src/events/bump_transaction.rs

index 5597836d30163a94ce7b8bbb33dcf07018b1e1ae..2728e21fcab9d82942e59be0506ccc068ccd0055 100644 (file)
@@ -703,11 +703,9 @@ where
 
                                let expected_package_fee = Amount::from_sat(fee_for_weight(package_target_feerate_sat_per_1000_weight,
                                        signed_tx_weight + commitment_tx.weight().to_wu()));
-                               // Our fee should be within a 5% error margin of the expected fee based on the
-                               // feerate and transaction weight and we should never pay less than required.
-                               let fee_error_margin = expected_package_fee * 5 / 100;
-                               assert!(package_fee >= expected_package_fee &&
-                                       package_fee - fee_error_margin <= expected_package_fee);
+                               // Our feerate should always be at least what we were seeking. It may overshoot if
+                               // the coin selector burned funds to an OP_RETURN without a change output.
+                               assert!(package_fee >= expected_package_fee);
                        }
 
                        log_info!(self.logger, "Broadcasting anchor transaction {} to bump channel close with txid {}",
@@ -811,11 +809,9 @@ where
                        let expected_signed_tx_fee = fee_for_weight(target_feerate_sat_per_1000_weight, signed_tx_weight);
                        let signed_tx_fee = total_input_amount -
                                htlc_tx.output.iter().map(|output| output.value.to_sat()).sum::<u64>();
-                       // Our fee should be within a 5% error margin of the expected fee based on the
-                       // feerate and transaction weight and we should never pay less than required.
-                       let fee_error_margin = expected_signed_tx_fee * 5 / 100;
-                       assert!(signed_tx_fee >= expected_signed_tx_fee &&
-                               signed_tx_fee - fee_error_margin <= expected_signed_tx_fee);
+                       // Our feerate should always be at least what we were seeking. It may overshoot if
+                       // the coin selector burned funds to an OP_RETURN without a change output.
+                       assert!(signed_tx_fee >= expected_signed_tx_fee);
                }
 
                log_info!(self.logger, "Broadcasting {}", log_tx!(htlc_tx));