@@ -294,6 +294,7 @@ struct HTLCStats {
294294 on_counterparty_tx_dust_exposure_msat : u64 ,
295295 on_holder_tx_dust_exposure_msat : u64 ,
296296 holding_cell_msat : u64 ,
297+ on_holder_tx_holding_cell_htlcs_count : u32 , // dust HTLCs *non*-included
297298}
298299
299300/// An enum gathering stats on commitment transaction, either local or remote.
@@ -2024,6 +2025,7 @@ impl<Signer: Sign> Channel<Signer> {
20242025 on_counterparty_tx_dust_exposure_msat : 0 ,
20252026 on_holder_tx_dust_exposure_msat : 0 ,
20262027 holding_cell_msat : 0 ,
2028+ on_holder_tx_holding_cell_htlcs_count : 0 ,
20272029 } ;
20282030
20292031 let counterparty_dust_limit_timeout_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * HTLC_TIMEOUT_TX_WEIGHT / 1000 ) + self . counterparty_dust_limit_satoshis ;
@@ -2048,6 +2050,7 @@ impl<Signer: Sign> Channel<Signer> {
20482050 on_counterparty_tx_dust_exposure_msat : 0 ,
20492051 on_holder_tx_dust_exposure_msat : 0 ,
20502052 holding_cell_msat : 0 ,
2053+ on_holder_tx_holding_cell_htlcs_count : 0 ,
20512054 } ;
20522055
20532056 let counterparty_dust_limit_success_sat = ( self . get_dust_buffer_feerate ( outbound_feerate_update) as u64 * HTLC_SUCCESS_TX_WEIGHT / 1000 ) + self . counterparty_dust_limit_satoshis ;
@@ -2072,6 +2075,8 @@ impl<Signer: Sign> Channel<Signer> {
20722075 }
20732076 if * amount_msat / 1000 < holder_dust_limit_timeout_sat {
20742077 stats. on_holder_tx_dust_exposure_msat += amount_msat;
2078+ } else {
2079+ stats. on_holder_tx_holding_cell_htlcs_count += 1 ;
20752080 }
20762081 }
20772082 }
@@ -3099,7 +3104,7 @@ impl<Signer: Sign> Channel<Signer> {
30993104 let outbound_stats = self . get_outbound_pending_htlc_stats ( Some ( feerate_per_kw) ) ;
31003105 let keys = if let Ok ( keys) = self . build_holder_transaction_keys ( self . cur_holder_commitment_transaction_number ) { keys } else { return None ; } ;
31013106 let commitment_stats = self . build_commitment_transaction ( self . cur_holder_commitment_transaction_number , & keys, true , true , logger) ;
3102- let buffer_fee_msat = Channel :: < Signer > :: commit_tx_fee_sat ( feerate_per_kw, commitment_stats. num_nondust_htlcs + CONCURRENT_INBOUND_HTLC_FEE_BUFFER as usize ) * 1000 ;
3107+ 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 ;
31033108 let holder_balance_msat = commitment_stats. local_balance_msat - outbound_stats. holding_cell_msat ;
31043109 if holder_balance_msat < buffer_fee_msat + self . counterparty_selected_channel_reserve_satoshis . unwrap ( ) * 1000 {
31053110 //TODO: auto-close after a number of failures?
0 commit comments