@@ -479,6 +479,21 @@ pub struct ChannelDetails {
479479 ///
480480 /// This field will be `None` for objects serialized with LDK versions prior to 0.2.0.
481481 pub funding_redeem_script : Option < bitcoin:: ScriptBuf > ,
482+ /// The current total dust exposure on this channel, in millisatoshis.
483+ ///
484+ /// This is the maximum of the dust exposure on the holder and counterparty commitment
485+ /// transactions, and includes both the value of all pending HTLCs that are below the dust
486+ /// threshold as well as the portion of commitment transaction fees that contribute to dust
487+ /// exposure.
488+ ///
489+ /// The dust exposure is compared against
490+ /// [`ChannelConfig::max_dust_htlc_exposure`] to determine whether new HTLCs can be
491+ /// accepted or offered on this channel.
492+ ///
493+ /// This field will be `None` for objects serialized with LDK versions prior to 0.3.0.
494+ ///
495+ /// [`ChannelConfig::max_dust_htlc_exposure`]: crate::util::config::ChannelConfig::max_dust_htlc_exposure
496+ pub current_dust_exposure_msat : Option < u64 > ,
482497}
483498
484499impl ChannelDetails {
@@ -533,6 +548,7 @@ impl ChannelDetails {
533548 outbound_capacity_msat : 0 ,
534549 next_outbound_htlc_limit_msat : 0 ,
535550 next_outbound_htlc_minimum_msat : u64:: MAX ,
551+ dust_exposure_msat : 0 ,
536552 }
537553 } ) ;
538554 let ( to_remote_reserve_satoshis, to_self_reserve_satoshis) =
@@ -596,6 +612,7 @@ impl ChannelDetails {
596612 channel_shutdown_state : Some ( context. shutdown_state ( ) ) ,
597613 pending_inbound_htlcs : context. get_pending_inbound_htlc_details ( funding) ,
598614 pending_outbound_htlcs : context. get_pending_outbound_htlc_details ( funding) ,
615+ current_dust_exposure_msat : Some ( balance. dust_exposure_msat ) ,
599616 }
600617 }
601618}
@@ -636,6 +653,7 @@ impl_writeable_tlv_based!(ChannelDetails, {
636653 ( 43 , pending_inbound_htlcs, optional_vec) ,
637654 ( 45 , pending_outbound_htlcs, optional_vec) ,
638655 ( 47 , funding_redeem_script, option) ,
656+ ( 49 , current_dust_exposure_msat, option) ,
639657 ( _unused, user_channel_id, ( static_value,
640658 _user_channel_id_low. unwrap_or( 0 ) as u128 | ( ( _user_channel_id_high. unwrap_or( 0 ) as u128 ) << 64 )
641659 ) ) ,
@@ -756,6 +774,7 @@ mod tests {
756774 skimmed_fee_msat: Some ( 42 ) ,
757775 is_dust: false ,
758776 } ] ,
777+ current_dust_exposure_msat : Some ( 150_000 ) ,
759778 } ;
760779 let mut buffer = Vec :: new ( ) ;
761780 channel_details. write ( & mut buffer) . unwrap ( ) ;
0 commit comments