-
Notifications
You must be signed in to change notification settings - Fork 448
Expose current dust exposure in ChannelDetails #4470
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -479,6 +479,21 @@ pub struct ChannelDetails { | |||||
| /// | ||||||
| /// This field will be `None` for objects serialized with LDK versions prior to 0.2.0. | ||||||
| pub funding_redeem_script: Option<bitcoin::ScriptBuf>, | ||||||
| /// The current total dust exposure on this channel, in millisatoshis. | ||||||
| /// | ||||||
| /// This is the maximum of the dust exposure on the holder and counterparty commitment | ||||||
| /// transactions, and includes both the value of all pending HTLCs that are below the dust | ||||||
| /// threshold as well as the portion of commitment transaction fees that contribute to dust | ||||||
| /// exposure. | ||||||
| /// | ||||||
| /// The dust exposure is compared against | ||||||
| /// [`ChannelConfig::max_dust_htlc_exposure`] to determine whether new HTLCs can be | ||||||
| /// accepted or offered on this channel. | ||||||
| /// | ||||||
| /// This field will be `None` for objects serialized with LDK versions prior to 0.2.1. | ||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The version here says "prior to 0.2.1" but
Suggested change
|
||||||
| /// | ||||||
| /// [`ChannelConfig::max_dust_htlc_exposure`]: crate::util::config::ChannelConfig::max_dust_htlc_exposure | ||||||
| pub current_dust_exposure_msat: Option<u64>, | ||||||
| } | ||||||
|
|
||||||
| impl ChannelDetails { | ||||||
|
|
@@ -533,6 +548,7 @@ impl ChannelDetails { | |||||
| outbound_capacity_msat: 0, | ||||||
| next_outbound_htlc_limit_msat: 0, | ||||||
| next_outbound_htlc_minimum_msat: u64::MAX, | ||||||
| dust_exposure_msat: 0, | ||||||
| } | ||||||
| }); | ||||||
| let (to_remote_reserve_satoshis, to_self_reserve_satoshis) = | ||||||
|
|
@@ -596,6 +612,7 @@ impl ChannelDetails { | |||||
| channel_shutdown_state: Some(context.shutdown_state()), | ||||||
| pending_inbound_htlcs: context.get_pending_inbound_htlc_details(funding), | ||||||
| pending_outbound_htlcs: context.get_pending_outbound_htlc_details(funding), | ||||||
| current_dust_exposure_msat: Some(balance.dust_exposure_msat), | ||||||
| } | ||||||
| } | ||||||
| } | ||||||
|
|
@@ -636,6 +653,7 @@ impl_writeable_tlv_based!(ChannelDetails, { | |||||
| (43, pending_inbound_htlcs, optional_vec), | ||||||
| (45, pending_outbound_htlcs, optional_vec), | ||||||
| (47, funding_redeem_script, option), | ||||||
| (49, current_dust_exposure_msat, option), | ||||||
| (_unused, user_channel_id, (static_value, | ||||||
| _user_channel_id_low.unwrap_or(0) as u128 | ((_user_channel_id_high.unwrap_or(0) as u128) << 64) | ||||||
| )), | ||||||
|
|
@@ -756,6 +774,7 @@ mod tests { | |||||
| skimmed_fee_msat: Some(42), | ||||||
| is_dust: false, | ||||||
| }], | ||||||
| current_dust_exposure_msat: Some(150_000), | ||||||
| }; | ||||||
| let mut buffer = Vec::new(); | ||||||
| channel_details.write(&mut buffer).unwrap(); | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -512,13 +512,16 @@ fn get_available_balances( | |
| available_capacity_msat = 0; | ||
| } | ||
|
|
||
| let dust_exposure_msat = cmp::max(local_dust_exposure_msat, remote_dust_exposure_msat); | ||
|
|
||
| #[allow(deprecated)] // TODO: Remove once balance_msat is removed | ||
| crate::ln::channel::AvailableBalances { | ||
| inbound_capacity_msat: remote_balance_before_fee_msat | ||
| .saturating_sub(channel_constraints.holder_selected_channel_reserve_satoshis * 1000), | ||
| outbound_capacity_msat, | ||
| next_outbound_htlc_limit_msat: available_capacity_msat, | ||
| next_outbound_htlc_minimum_msat, | ||
| dust_exposure_msat, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @TheBlueMatt it's a current quirk of the Seems ok to me for now. |
||
| } | ||
| } | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Needs a link to the config knobs that limit it.