Skip to content

Expose current dust exposure in ChannelDetails#4470

Open
Bortlesboat wants to merge 1 commit intolightningdevkit:mainfrom
Bortlesboat:feat/expose-dust-exposure
Open

Expose current dust exposure in ChannelDetails#4470
Bortlesboat wants to merge 1 commit intolightningdevkit:mainfrom
Bortlesboat:feat/expose-dust-exposure

Conversation

@Bortlesboat
Copy link

Summary

Adds a current_dust_exposure_msat field to ChannelDetails that surfaces the current total dust exposure on a channel.

  • The value is the maximum of the dust exposure across the holder and counterparty commitment transactions
  • Includes both dust HTLC values and the commitment transaction fee component (as noted by @TheBlueMatt in Expose current dust exposure #2264, dust exposure now includes commitment tx fees, not just dust HTLCs)
  • Users can compare this against ChannelConfig::max_dust_htlc_exposure to monitor how close a channel is to its dust limit
  • Field is Option<u64>, None for objects serialized prior to 0.2.1
  • TLV tag 49 for backwards-compatible serialization

Implementation

  1. Added dust_exposure_msat to AvailableBalances — computed as max(local_dust_exposure_msat, remote_dust_exposure_msat) in get_available_balances (tx_builder.rs)
  2. When folding across multiple funding scopes (splices), takes the max dust exposure
  3. Added current_dust_exposure_msat: Option<u64> to ChannelDetails struct, populated from the balance computation in from_channel

Fixes #2264

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Mar 8, 2026

👋 Thanks for assigning @tankyleo as a reviewer!
I'll wait for their review and will help manage the review process.
Once they submit their review, I'll check if a second reviewer would be helpful.

@Bortlesboat Bortlesboat force-pushed the feat/expose-dust-exposure branch from 06585ba to c571ad4 Compare March 9, 2026 01:31
@tankyleo tankyleo requested review from tankyleo and removed request for valentinewallace March 9, 2026 11:18
Add current_dust_exposure_msat field to ChannelDetails that surfaces
the total dust exposure including both dust HTLC values and the
commitment transaction fee component. This is the maximum of the
holder and counterparty commitment transaction dust exposures.

Users can compare this value against max_dust_htlc_exposure in
ChannelConfig to understand how close a channel is to its dust
exposure limit without needing internal channel access.

Fixes lightningdevkit#2264
@Bortlesboat Bortlesboat force-pushed the feat/expose-dust-exposure branch from c571ad4 to 4f9b1e5 Compare March 9, 2026 18:25
@codecov
Copy link

codecov bot commented Mar 9, 2026

Codecov Report

❌ Patch coverage is 66.66667% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 86.01%. Comparing base (647c3f7) to head (4f9b1e5).

Files with missing lines Patch % Lines
lightning/src/ln/channel_state.rs 66.66% 1 Missing ⚠️
lightning/src/ln/channelmanager.rs 0.00% 1 Missing ⚠️
lightning/src/routing/router.rs 50.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4470      +/-   ##
==========================================
+ Coverage   85.98%   86.01%   +0.02%     
==========================================
  Files         159      159              
  Lines      105415   105424       +9     
  Branches   105415   105424       +9     
==========================================
+ Hits        90643    90679      +36     
+ Misses      12255    12235      -20     
+ Partials     2517     2510       -7     
Flag Coverage Δ
tests 86.01% <66.66%> (+0.02%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@ldk-reviews-bot
Copy link

🔔 1st Reminder

Hey @tankyleo! This PR has been waiting for your review.
Please take a look when you have a chance. If you're unable to review, please let us know so we can find another reviewer.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Expose current dust exposure

2 participants