Skip to content

[0.2] Backport of #4580#4686

Open
tankyleo wants to merge 5 commits into
lightningdevkit:0.2from
tankyleo:2026-06-reserve-greater-than-channel-value
Open

[0.2] Backport of #4580#4686
tankyleo wants to merge 5 commits into
lightningdevkit:0.2from
tankyleo:2026-06-reserve-greater-than-channel-value

Conversation

@tankyleo

Copy link
Copy Markdown
Contributor

No description provided.

@ldk-reviews-bot

ldk-reviews-bot commented Jun 12, 2026

Copy link
Copy Markdown

👋 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 June 12, 2026 08:01
@ldk-claude-review-bot

ldk-claude-review-bot commented Jun 12, 2026

Copy link
Copy Markdown
Collaborator

Based on my prior thorough review (recorded in memory), I examined all changes in this PR: the Result-returning reserve helpers, the prop-millionths cap at 1M, the removed cmp::min cap, the dust-limit crossover in for_splice/validate_splice_contributions/new_inbound v2, all Result callers, and the removed debug_assert in tx_builder.rs. The new splicing test and the conditional-compilation change to counterparty_dust_limit_satoshis were also reviewed.

No issues found.

@TheBlueMatt TheBlueMatt left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

On the first commit, please provide a brief summary of conflicts resolved after the "Backport of..." line. On the second commit, given the counterparty dust limit is required to be between 354 and 546, should we just check that the channel value is at least 546?

Comment thread lightning/src/ln/channel.rs Outdated
Some(get_v2_channel_reserve_satoshis(post_channel_value, MIN_CHAN_DUST_LIMIT_SATOSHIS));
let counterparty_selected_channel_reserve_satoshis = Some(
get_v2_channel_reserve_satoshis(post_channel_value, context.holder_dust_limit_satoshis)
.expect("We ran this exact function in `validate_splice_contributions`"),

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I admit I don't love adding expects in a backport that aren't there upstream. Can we just convert these to failures?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Done below, I add an extra commit where I make for_splice fallible

@ldk-reviews-bot

Copy link
Copy Markdown

👋 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 added 4 commits June 15, 2026 17:39
The floor for *our* selected reserve is *their* dust limit.

Backport of a3dded1
In preparation for an upcoming backport commit, we make
`FundedChannel::for_splice` fallible. This will avoid introducing
`expect` calls in the backport commit that aren't present in the
upstream commit.
In 0FC channels, capping the reserve to the total value of the channel
allowed a splice initiator to withdraw past their reserve in case the
acceptor had no balance in the channel.

This is because the post-splice value of the channel was equal to the
initiator's post splice balance. Hence, this post splice balance always
matched the reserve, even though the reserve was below the dust limit.

The only thing that prevented the initiator from withdrawing all their
balance was the script dust limit check in
`interactivetxs::NegotiationContext::receive_tx_add_output`.

In case the splice acceptor had any balance in the channel, or there
were HTLCs in the channel, or the channel was not 0FC, the
splice initiator's post-splice balance was always below the full channel
value. Hence when the reserve was capped at the channel value, the
post-splice balance was always below the reserve, and the splice was
rejected.

Also, in `validate_splice_contributions`, to determine the
`counterparty_selected_channel_reserve`, we now read the holder's dust
limit from the context, instead of the current global constant.

Backport of 3835f84

Conflicts resolved in:
 * lightning/src/ln/channel.rs
 * lightning/src/ln/splicing_tests.rs
 * lightning/src/sign/tx_builder.rs
We made the same change to the calculation of the v2 reserve in the
previous commit.

Backport of 53e156a

Conflicts resolved in:
 * lightning/src/ln/channel.rs
 * lightning/src/ln/channel_open_tests.rs
 * lightning/src/ln/functional_tests.rs
 * lightning/src/ln/htlc_reserve_unit_tests.rs
 * lightning/src/ln/update_fee_tests.rs

Here their `dust_limit_satoshis` can never be greater than
`MIN_THEIR_CHAN_RESERVE_SATOSHIS`, so by making sure that
`channel_value_satoshis` is greater than
`MIN_THEIR_CHAN_RESERVE_SATOSHIS`, we also make sure that
`channel_value_satoshis` is greater than their `dust_limit_satoshis`.
@tankyleo tankyleo force-pushed the 2026-06-reserve-greater-than-channel-value branch from 5eb859d to 9755b2e Compare June 15, 2026 18:28
@tankyleo

Copy link
Copy Markdown
Contributor Author

I added a backport of a3dded1

On the second commit, given the counterparty dust limit is required to be between 354 and 546, should we just check that the channel value is at least 546?

Hmm in that case we'd return a reserve of 1000sats for a channel value of 546? I think we should error in this case.

@tankyleo tankyleo requested a review from TheBlueMatt June 15, 2026 18:30
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.

4 participants