@@ -1320,7 +1320,7 @@ impl<Signer: Sign> Channel<Signer> {
1320
1320
broadcaster_max_commitment_tx_output. 1 = cmp:: max ( broadcaster_max_commitment_tx_output. 1 , value_to_remote_msat as u64 ) ;
1321
1321
}
1322
1322
1323
- let total_fee_sat = Channel :: < Signer > :: commit_tx_fee_sat ( feerate_per_kw, included_non_dust_htlcs. len ( ) ) ;
1323
+ let total_fee_sat = Channel :: < Signer > :: commit_tx_fee_sat ( feerate_per_kw, included_non_dust_htlcs. len ( ) , self . channel_transaction_parameters . opt_anchors . is_some ( ) ) ;
1324
1324
let ( value_to_self, value_to_remote) = if self . is_outbound ( ) {
1325
1325
( value_to_self_msat / 1000 - total_fee_sat as i64 , value_to_remote_msat / 1000 )
1326
1326
} else {
@@ -2167,8 +2167,8 @@ impl<Signer: Sign> Channel<Signer> {
2167
2167
// Get the fee cost in SATS of a commitment tx with a given number of HTLC outputs.
2168
2168
// Note that num_htlcs should not include dust HTLCs.
2169
2169
#[ inline]
2170
- fn commit_tx_fee_sat ( feerate_per_kw : u32 , num_htlcs : usize ) -> u64 {
2171
- feerate_per_kw as u64 * ( COMMITMENT_TX_BASE_WEIGHT + num_htlcs as u64 * COMMITMENT_TX_WEIGHT_PER_HTLC ) / 1000
2170
+ fn commit_tx_fee_sat ( feerate_per_kw : u32 , num_htlcs : usize , opt_anchors : bool ) -> u64 {
2171
+ feerate_per_kw as u64 * ( if opt_anchors { 1124 } else { COMMITMENT_TX_BASE_WEIGHT } + num_htlcs as u64 * COMMITMENT_TX_WEIGHT_PER_HTLC ) / 1000
2172
2172
}
2173
2173
2174
2174
// Get the commitment tx fee for the local's (i.e. our) next commitment transaction based on the
@@ -3151,7 +3151,7 @@ impl<Signer: Sign> Channel<Signer> {
3151
3151
let outbound_stats = self . get_outbound_pending_htlc_stats ( Some ( feerate_per_kw) ) ;
3152
3152
let keys = if let Ok ( keys) = self . build_holder_transaction_keys ( self . cur_holder_commitment_transaction_number ) { keys } else { return None ; } ;
3153
3153
let commitment_stats = self . build_commitment_transaction ( self . cur_holder_commitment_transaction_number , & keys, true , true , logger) ;
3154
- let buffer_fee_msat = Channel :: < Signer > :: commit_tx_fee_sat ( feerate_per_kw, commitment_stats. num_nondust_htlcs + outbound_stats. on_holder_tx_holding_cell_htlcs_count as usize + CONCURRENT_INBOUND_HTLC_FEE_BUFFER as usize ) * 1000 ;
3154
+ let buffer_fee_msat = Channel :: < Signer > :: commit_tx_fee_sat ( feerate_per_kw, commitment_stats. num_nondust_htlcs + outbound_stats. on_holder_tx_holding_cell_htlcs_count as usize + CONCURRENT_INBOUND_HTLC_FEE_BUFFER as usize , self . opt_anchors ( ) ) * 1000 ;
3155
3155
let holder_balance_msat = commitment_stats. local_balance_msat - outbound_stats. holding_cell_msat ;
3156
3156
if holder_balance_msat < buffer_fee_msat + self . counterparty_selected_channel_reserve_satoshis . unwrap ( ) * 1000 {
3157
3157
//TODO: auto-close after a number of failures?
0 commit comments