Skip to content

Add AvailableBalances::next_splice_out_maximum_sat#4550

Open
tankyleo wants to merge 5 commits intolightningdevkit:mainfrom
tankyleo:2026-04-next-splice-out-maximum
Open

Add AvailableBalances::next_splice_out_maximum_sat#4550
tankyleo wants to merge 5 commits intolightningdevkit:mainfrom
tankyleo:2026-04-next-splice-out-maximum

Conversation

@tankyleo
Copy link
Copy Markdown
Contributor

@tankyleo tankyleo commented Apr 9, 2026

This is the maximum value the holder can splice out of their channel balance, accounting for the updated v2 reserves after the splice, and the "must have at least one output" constraint on zero-reserve channels.

tankyleo added 4 commits April 9, 2026 07:21
We now validate that both commitments retain at least one output after a
splice, which is crucial for zero-reserve channels.
We previously determined this value by subtracting the htlcs, the
anchors, and the commitment transaction fee. This ignored the reserve,
as well as the at-least-one-output requirement in zero-reserve channels.

This new field now accounts for both of these constraints.
This is equivalent to the previous commit, see the debug assertions
added in the previous commit. We now also get to communicate the
exact maximum back to the user, instead of some "balance is lower
than our reserve" message, which is hard to react to.
@ldk-reviews-bot
Copy link
Copy Markdown

ldk-reviews-bot commented Apr 9, 2026

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

@ldk-reviews-bot ldk-reviews-bot requested a review from jkczyz April 9, 2026 08:13
@tankyleo tankyleo force-pushed the 2026-04-next-splice-out-maximum branch from 724acf9 to 3bd7a76 Compare April 9, 2026 08:29
@ldk-claude-review-bot
Copy link
Copy Markdown
Collaborator

ldk-claude-review-bot commented Apr 9, 2026

Review Summary

Correction of Prior Comments

My previous review flagged three "unit mismatch" bugs that were incorrect:

  • channel_state.rs:628 — The TLV default already divides by 1000: u64::from(outbound_capacity_msat.0.unwrap()) / 1000
  • router.rs:4153 — The test helper already uses outbound_capacity_msat / 1000
  • router.rs:9653 — The value 10_000_000 is already correct (10_000_000_000 / 1000)

I apologize for the false positives.

Still-Valid Prior Comments

The following prior comments remain valid concerns:

  • lightning/src/sign/tx_builder.rs:414get_next_splice_out_maximum_sat checks has_output only on the local commitment (using holder_dust_limit). If counterparty_dust_limit > holder_dust_limit in a zero-reserve channel, the remote commitment could have no outputs, causing the debug assertion unwrap() at channel.rs:13419 to panic.

  • lightning/src/sign/tx_builder.rs:355dust_limit_max_splice_out_sat uses holder_dust_limit_satoshis as the floor, while validate_splice_contributions uses MIN_CHAN_DUST_LIMIT_SATOSHIS (354). For channels deserialized from older LDK versions where holder_dust_limit could be 546, the debug assertion unwrap_err() at channel.rs:13425 could panic.

  • lightning/src/ln/channel.rs:13426 — Debug assertions rely on exact agreement between get_next_splice_out_maximum_sat and validate_splice_contributions, but the two have subtle inconsistencies in dust limit handling and commitment selection.

  • lightning/src/sign/tx_builder.rs:391 — Comment says "bump this maximum" when the code actually reduces it.

New Issues Found

No new issues found beyond those already covered by prior comments. The equation derivation for the v2 reserve constraint is correct, the feerate spike handling is consistent (no double-spike in the validation path), the accumulator logic for multi-funding channels correctly takes the minimum, and the semantic change from "holder balance floor" to "max splice-out" in resolve_queued_contribution and build_prior_contribution is appropriate since downstream consumers (compute_feerate_adjustment) compare total splice-out cost against this value.

@tankyleo tankyleo requested review from TheBlueMatt and wpaulino and removed request for jkczyz April 9, 2026 08:32
@tankyleo tankyleo self-assigned this Apr 9, 2026
@tankyleo tankyleo moved this to Goal: Merge in Weekly Goals Apr 9, 2026
@tankyleo
Copy link
Copy Markdown
Contributor Author

tankyleo commented Apr 9, 2026

Seems the fuzz failure produces this error on my machine

Hex:

ff1cb4a6a6ffffff02000000ffffb4a669696969696969691b00000000000000ffffffffffa2ad06301100ffffffffffffcf111f7d29000000000000001f0007

Target: chanmon_consistency

Error:

2      ERROR [lightning::ln::channelmanager:4635]      ch:8c0000 p:020000          Closed channel due to close-required error: Channel closed because of an exception: splice tx of another pending funding already confirmed
2      ERROR [lightning::ln::channelmanager:4557]      ch:8c0000 p:020000          Closing channel: Channel closed because of an exception: splice tx of another pending funding already confirmed

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

Labels

None yet

Projects

Status: Goal: Merge

Development

Successfully merging this pull request may close these issues.

3 participants