Skip to content

Add splice-out support #3979

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 7 commits into
base: main
Choose a base branch
from

Conversation

jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Jul 31, 2025

Splice-in support was added in #3736. This PR expands ChannelManager::splice_channel to support splice-out (i.e., removing funds from a channel). This is accomplished by adding a FundingTxContributions enum to cover both use cases.

Depends on #3736.

@ldk-reviews-bot
Copy link

ldk-reviews-bot commented Jul 31, 2025

🎉 This PR is now ready for review!
Please choose at least one reviewer by assigning them on the right bar.
If no reviewers are assigned within 10 minutes, I'll automatically assign one.
Once the first reviewer has submitted a review, a second will be assigned if required.

@jkczyz jkczyz requested a review from wpaulino July 31, 2025 16:11
@jkczyz jkczyz marked this pull request as draft July 31, 2025 16:11
@jkczyz jkczyz self-assigned this Jul 31, 2025
Copy link

codecov bot commented Jul 31, 2025

Codecov Report

❌ Patch coverage is 70.17544% with 34 lines in your changes missing coverage. Please review.
✅ Project coverage is 88.93%. Comparing base (1e1d300) to head (381fba6).

Files with missing lines Patch % Lines
lightning/src/ln/msgs.rs 29.41% 15 Missing and 9 partials ⚠️
lightning/src/ln/channel.rs 77.77% 7 Missing and 1 partial ⚠️
lightning/src/ln/channelmanager.rs 0.00% 1 Missing ⚠️
lightning/src/ln/interactivetxs.rs 97.61% 0 Missing and 1 partial ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #3979      +/-   ##
==========================================
- Coverage   88.94%   88.93%   -0.02%     
==========================================
  Files         174      174              
  Lines      124200   124211      +11     
  Branches   124200   124211      +11     
==========================================
- Hits       110471   110462       -9     
- Misses      11253    11261       +8     
- Partials     2476     2488      +12     
Flag Coverage Δ
fuzzing 22.63% <2.53%> (-0.01%) ⬇️
tests 88.75% <68.42%> (-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.

@jkczyz jkczyz force-pushed the 2025-07-splice-out branch 2 times, most recently from acab158 to 2d39059 Compare July 31, 2025 22:15
jkczyz added 7 commits July 31, 2025 19:22
Splice contributions should never exceed the total bitcoin supply. This
check prevents a potential overflow when converting the contribution
from sats to msats. The commit additionally begins to store the
contribution using SignedAmount.
…text

Once the counterparty supplies their funding contribution, there is no
longer a need to store it in FundingNegotiationContext as it will have
already been used to create a FundingScope.
Specify what inputs and outputs to contribute to a funding transaction
using an enum. This will make the splice-in and upcoming splice-out use
cases explicit.
TransactionU16LenLimited was used to limit Transaction serialization
size to u16::MAX. This was because messages can not be longer than
u16::MAX bytes when serialized for the transport layer. However, this
limit doesn't take into account other fields in a message containing a
Transaction, including the length of the transaction itself.

Remove TransactionU16LenLimited and instead check any user supplied
transactions in the context of the enclosing message (e.g. TxAddInput).
In preparation for having ChannelManager::splice_channel take
FundingTxContributions, add a weight to the
FundingTxContributions::InputsOnly, which supports the splice-in use
case.
Using FundingTxContributions for ChannelManager::splice_channel allows
supporting both splice-in and splice-out using the same method, with a
descriptive enum for the contributions.
Update FundingTxContributions with a variant used to support splice-out
(i.e., removing funds from a channel). The TxOut values must not exceed
the users channel balance after accounting for fees and the reserve
requirement.
@jkczyz jkczyz force-pushed the 2025-07-splice-out branch from 2d39059 to 381fba6 Compare August 1, 2025 00:23
@jkczyz jkczyz marked this pull request as ready for review August 1, 2025 00:23
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.

2 participants