File tree 1 file changed +3
-2
lines changed
1 file changed +3
-2
lines changed Original file line number Diff line number Diff line change @@ -2953,11 +2953,12 @@ impl<Signer: Sign> Channel<Signer> {
2953
2953
panic ! ( "Cannot update fee while peer is disconnected/we're awaiting a monitor update (ChannelManager should have caught this)" ) ;
2954
2954
}
2955
2955
2956
- // Before to propose a feerate update, check that we can actually afford the new fee compare to the holder balance .
2956
+ // Before proposing a feerate update, check that we can actually afford the new fee.
2957
2957
let inbound_stats = self . get_inbound_pending_htlc_stats ( Some ( feerate_per_kw) ) ;
2958
2958
let outbound_stats = self . get_outbound_pending_htlc_stats ( Some ( feerate_per_kw) ) ;
2959
2959
let total_fee = feerate_per_kw as u64 * ( COMMITMENT_TX_BASE_WEIGHT + ( inbound_stats. pending_htlcs as u64 + outbound_stats. pending_htlcs as u64 ) * COMMITMENT_TX_WEIGHT_PER_HTLC ) / 1000 ;
2960
- if self . value_to_self_msat / 1000 - total_fee - outbound_stats. pending_htlcs_value_msat < self . counterparty_selected_channel_reserve_satoshis . unwrap ( ) {
2960
+ let holder_balance_after_fee_sub = ( self . value_to_self_msat / 1000 ) . checked_sub ( total_fee) . map ( |a| a. checked_sub ( outbound_stats. pending_htlcs_value_msat / 1000 ) ) . unwrap_or ( None ) . unwrap_or ( u64:: max_value ( ) ) ;
2961
+ if holder_balance_after_fee_sub < self . counterparty_selected_channel_reserve_satoshis . unwrap ( ) {
2961
2962
log_debug ! ( logger, "Cannot afford to send new feerate at {}" , feerate_per_kw) ;
2962
2963
return None ;
2963
2964
}
You can’t perform that action at this time.
0 commit comments