Skip to content

Conversation

wpaulino
Copy link
Contributor

Similar to FundedChannel::get_available_balances, we should reflect the correct balance in the monitor based on the current state of a splice. While the channel is still open, we consider our balance to be the lowest balance across all commitment transaction candidates for the current state. Once the channel has a confirmed commitment transaction, we report the balance specific to the corresponding FundingScope being spent.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Aug 26, 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.

@wpaulino wpaulino self-assigned this Aug 26, 2025
@wpaulino wpaulino requested review from TheBlueMatt and jkczyz August 26, 2025 16:46
Copy link

codecov bot commented Aug 26, 2025

Codecov Report

❌ Patch coverage is 95.55556% with 4 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.77%. Comparing base (b40dca0) to head (a33a7bd).
⚠️ Report is 4 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/chain/channelmonitor.rs 90.00% 3 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4029      +/-   ##
==========================================
+ Coverage   88.56%   88.77%   +0.20%     
==========================================
  Files         175      176       +1     
  Lines      129175   129402     +227     
  Branches   129175   129402     +227     
==========================================
+ Hits       114408   114878     +470     
+ Misses      12246    11913     -333     
- Partials     2521     2611      +90     
Flag Coverage Δ
fuzzing 22.00% <0.00%> (?)
tests 88.60% <95.55%> (+0.04%) ⬆️

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 @jkczyz! 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.

@ldk-reviews-bot
Copy link

🔔 2nd Reminder

Hey @jkczyz! 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.

@TheBlueMatt
Copy link
Collaborator

Discussed this one offline, needs the balance stuff to consider splices.

@TheBlueMatt TheBlueMatt removed the request for review from jkczyz August 30, 2025 17:18
@wpaulino wpaulino force-pushed the splice-claimable-balances branch 3 times, most recently from 3ae60bf to b5244ee Compare September 2, 2025 16:31
@wpaulino wpaulino requested a review from TheBlueMatt September 2, 2025 16:39
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 think this LGTM.

@@ -928,7 +946,11 @@ impl Balance {
#[rustfmt::skip]
pub fn claimable_amount_satoshis(&self) -> u64 {
match self {
Balance::ClaimableOnChannelClose { amount_satoshis, .. }|
Balance::ClaimableOnChannelClose { balance_candidates, .. } => {
// FIXME: Should we report the balance for the currently confirmed splice
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think this is right. In practice if a splice happens you want to see your balance go down/up in accordance with where the channel is going, not where it was. We need to update the docs to describe this behavior, however.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Let me know if the docs added are sufficient or if we should clarify a bit more elsewhere

@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.

@wpaulino wpaulino force-pushed the splice-claimable-balances branch from b5244ee to 0dcabb9 Compare September 2, 2025 20:37
There are two states in which a pending splice balance should be
considered:

1. The channel has closed with a confirmed holder commitment transaction
   from a splice that did not become locked. The balance from this
   transaction is reported.
2. The channel is open and has multiple holder commitment transaction
   candidates that are valid based on the funding transaction that
   confirms. We want to report the pending splice balance to users while
   it has yet to become locked, such that they are able to see their
   funds have moved from their onchain wallet to the channel. We default
   to reporting the latest splice/RBF balance via
   `Balance::claimable_amount_satoshis` to mimic how an onchain wallet
   would behave when reporting unconfirmed balance, otherwise we report
   the balance for the confirmed splice transaction.
@wpaulino wpaulino force-pushed the splice-claimable-balances branch from 0dcabb9 to a33a7bd Compare September 2, 2025 21:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: No status
Development

Successfully merging this pull request may close these issues.

3 participants