Skip to content

Comments

Contribute to splice as acceptor#4416

Draft
jkczyz wants to merge 10 commits intolightningdevkit:mainfrom
jkczyz:2026-02-splice-acceptor
Draft

Contribute to splice as acceptor#4416
jkczyz wants to merge 10 commits intolightningdevkit:mainfrom
jkczyz:2026-02-splice-acceptor

Conversation

@jkczyz
Copy link
Contributor

@jkczyz jkczyz commented Feb 12, 2026

When both nodes want to splice simultaneously, the quiescence tie-breaker designates one as the initiator. Previously, the losing node responded with zero contribution, requiring a second full splice session after the first splice locked. This is wasteful, especially for often-offline nodes that may connect and immediately want to splice.

Instead, the losing node will contribute to the splice as the acceptor, resulting in a single splice transaction and eliminating the need for a second splice. Unfortunately, they will over pay fees since the FundingContribution was produced as the initiator. However, CoinSelectionSource doesn't support specifying whether common fields need to be paid for. Adjusting the change could work, but there may not be a change output.

Based on #4388.

@ldk-reviews-bot
Copy link

👋 Hi! I see this is a draft PR.
I'll wait to assign reviewers until you mark it as ready for review.
Just convert it out of draft status when you're ready for review!

@jkczyz jkczyz self-assigned this Feb 12, 2026
@jkczyz jkczyz force-pushed the 2026-02-splice-acceptor branch from fc3e1da to 758ab0a Compare February 18, 2026 01:02
jkczyz and others added 2 commits February 21, 2026 12:14
Add a helper function to assert that SpliceFailed events contain the
expected channel_id and contributed inputs/outputs. This ensures that
tests verify the contributions match what was originally provided.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The following types have methods for returning contributed inputs and
outputs:
- FundingNegotiationContext
- InteractiveTxConstructor
- InteractiveTxSigningSession
- ConstructedTransaction

Having iterators for these can avoid allocations, which is useful for
filtering contributed input and outputs when producing DiscardFunding
events.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkczyz jkczyz force-pushed the 2026-02-splice-acceptor branch 3 times, most recently from b6cec12 to 5a26025 Compare February 23, 2026 17:16
@codecov
Copy link

codecov bot commented Feb 23, 2026

Codecov Report

❌ Patch coverage is 90.74316% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 85.99%. Comparing base (62c7575) to head (658f332).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
lightning/src/ln/funding.rs 92.93% 22 Missing and 5 partials ⚠️
lightning/src/ln/channelmanager.rs 82.57% 23 Missing ⚠️
lightning/src/ln/channel.rs 92.36% 8 Missing and 2 partials ⚠️
lightning/src/ln/interactivetxs.rs 92.94% 6 Missing ⚠️
lightning/src/ln/functional_test_utils.rs 86.48% 5 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4416      +/-   ##
==========================================
+ Coverage   85.87%   85.99%   +0.11%     
==========================================
  Files         157      159       +2     
  Lines      103769   104622     +853     
  Branches   103769   104622     +853     
==========================================
+ Hits        89115    89970     +855     
+ Misses      12158    12148      -10     
- Partials     2496     2504       +8     
Flag Coverage Δ
tests 85.99% <90.74%> (+0.11%) ⬆️

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 and others added 8 commits February 23, 2026 15:44
When a splice fails, users need to reclaim UTXOs they contributed to the
funding transaction. Previously, the contributed inputs and outputs were
included in the SpliceFailed event. This commit splits them into a
separate DiscardFunding event with a new FundingInfo::Contribution
variant, providing a consistent interface for UTXO cleanup across all
funding failure scenarios.

Changes:
- Add FundingInfo::Contribution variant to hold inputs/outputs for
  DiscardFunding events
- Remove contributed_inputs/outputs fields from SpliceFailed event
- Add QuiescentError enum for better error handling in funding_contributed
- Emit DiscardFunding on all funding_contributed error paths
- Filter duplicate inputs/outputs when contribution overlaps existing
  pending contribution
- Return Err(APIError) from funding_contributed on all error cases
- Add comprehensive test coverage for funding_contributed error paths

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Now that the Splice variant (containing non-serializable
FundingContribution) is the only variant produced, and the previous
commit consumes the acceptor's quiescent_action in splice_init(),
there is no longer a need to persist it. This allows removing
LegacySplice, SpliceInstructions, ChangeStrategy, and related code
paths including calculate_change_output, calculate_change_output_value,
and the legacy send_splice_init method.

With ChangeStrategy removed, the only remaining path in
calculate_change_output was FromCoinSelection which always returned
Ok(None), making it dead code. The into_interactive_tx_constructor
method is simplified accordingly, and the signer_provider parameter
is removed from it and from splice_init/splice_ack since it was only
needed for the removed change output calculation.

On deserialization, quiescent_action (TLV 65) is still read for
backwards compatibility but discarded, and the awaiting_quiescence
channel state flag is cleared since it cannot be acted upon without
a quiescent_action.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace the single public InteractiveTxConstructor::new() with separate
new_for_outbound() and new_for_inbound() constructors. This moves the
initiator's first message preparation out of the core constructor,
making it infallible and removing is_initiator from the args struct.

Callers no longer need to handle constructor errors, which avoids having
to generate SpliceFailed/DiscardFunding events after the QuiescentAction
has already been consumed during splice_init/splice_ack handling.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When constructing a FundingContribution, it's always assumed the
estimated_fee is for when used as the initiator, who pays for the common
fields and shared inputs / outputs. However, when the contribution is
used as the acceptor, we'd be overpaying fees. Provide a method on
FundingContribution that adjusts the fees and the change output, if
possible.
Add a `change_output: Option<&TxOut>` parameter to
`estimate_transaction_fee` so the initial fee estimate accounts for the
change output's weight. Previously, the change output weight was omitted
from `estimated_fee` in `FundingContribution`, causing the estimate to
be slightly too low when a change output was present.

This also eliminates an unnecessary `Vec<TxOut>` allocation in
`compute_feerate_adjustment`, which previously cloned outputs into a
temporary Vec just to include the change output for the fee estimate.

A mock `TightBudgetWallet` is added to `splicing_tests` to demonstrate
that `validate()` correctly rejects contributions where the input value
is sufficient without the change output weight but insufficient with it.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
When both nodes want to splice simultaneously, the quiescence
tie-breaker designates one as the initiator. Previously, the losing
node responded with zero contribution, requiring a second full splice
session after the first splice locked. This is wasteful, especially for
often-offline nodes that may connect and immediately want to splice.

Instead, the losing node contributes to the winner's splice as the
acceptor, merging both contributions into a single splice transaction.
Since the FundingContribution was originally built with initiator fees
(which include common fields and shared input/output weight), the fee is
adjusted to the acceptor rate before contributing, with the surplus
returned to the change output.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jkczyz jkczyz force-pushed the 2026-02-splice-acceptor branch from 5a26025 to 658f332 Compare February 23, 2026 22:06
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