Skip to content

Conversation

tankyleo
Copy link
Contributor

Depends on #3921

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 25, 2025

👋 Thanks for assigning @TheBlueMatt 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.

@tankyleo tankyleo requested a review from TheBlueMatt August 25, 2025 05:35
@tankyleo
Copy link
Contributor Author

@TheBlueMatt would appreciate a high-level design pass on this one thank you. I largely just move get_available_balances over to TxBuilder and then cleanup a bunch of things we no longer need in channel.

Comment on lines 128 to 141
fn get_available_balances(
&self, is_outbound_from_holder: bool, channel_value_satoshis: u64,
value_to_holder_msat: u64, pending_htlcs: &[HTLCAmountDirection], feerate_per_kw: u32,
dust_exposure_limiting_feerate: Option<u32>, max_dust_htlc_exposure_msat: u64,
holder_channel_constraints: ChannelConstraints,
counterparty_channel_constraints: ChannelConstraints, channel_type: &ChannelTypeFeatures,
) -> crate::ln::channel::AvailableBalances;
fn get_next_commitment_stats(
&self, local: bool, is_outbound_from_holder: bool, channel_value_satoshis: u64,
value_to_holder_msat: u64, next_commitment_htlcs: &[HTLCAmountDirection],
addl_nondust_htlc_count: usize, feerate_per_kw: u32,
dust_exposure_limiting_feerate: Option<u32>, broadcaster_dust_limit_satoshis: u64,
channel_type: &ChannelTypeFeatures,
) -> NextCommitmentStats;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm thinking we'll want to merge these two into one :)

Copy link

codecov bot commented Aug 25, 2025

Codecov Report

❌ Patch coverage is 98.75000% with 3 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.77%. Comparing base (a18f362) to head (81c31d6).

Files with missing lines Patch % Lines
lightning/src/ln/channel.rs 96.34% 1 Missing and 2 partials ⚠️
Additional details and impacted files
@@           Coverage Diff            @@
##             main    #4026    +/-   ##
========================================
  Coverage   88.76%   88.77%            
========================================
  Files         176      176            
  Lines      128139   127983   -156     
  Branches   128139   127983   -156     
========================================
- Hits       113743   113613   -130     
+ Misses      11822    11794    -28     
- Partials     2574     2576     +2     
Flag Coverage Δ
fuzzing 21.82% <74.12%> (-0.10%) ⬇️
tests 88.60% <98.75%> (+<0.01%) ⬆️

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.

Copy link
Collaborator

@TheBlueMatt TheBlueMatt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm confused, I was under the impression we were going to pause the custom tx builder work for a month or two after landing #3921?

@ldk-reviews-bot
Copy link

👋 The first review has been submitted!

Do you think this PR is ready for a second reviewer? If so, click here to assign a second reviewer.

@tankyleo
Copy link
Contributor Author

I'm confused, I was under the impression we were going to pause the custom tx builder work for a month or two after landing #3921?

Agreed yes this doesn't have to land anytime soon - I still wanted to get this PR out of my head and written before I stop TxBuilder for a while.

This will make our lives easier when we use `get_next_commitment_stats`
to determine the available balances in the channel.
These will be useful to pass these constraints to `TxBuilder` to
calculate `AvailableBalances`.
Also move things around to make the move in the next commit as
straightforward as possible.

We take the conservative route here and include all pending HTLCs,
including those in the holding cell, no matter their state.
Besides the changes in the `TxBuilder` API, this is a code move.
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.

3 participants