Skip to content

channeld: enforce the channel reserve in splice negotiation - #111

Merged
kwsantiago merged 3 commits into
blake2b-unifiedfrom
splice-reserve-negotiation
Nov 16, 2026
Merged

kwsantiago merged 3 commits into
blake2b-unifiedfrom
splice-reserve-negotiation

Conversation

@kwsantiago

Copy link
Copy Markdown

Summary

Splice negotiation never checked the channel reserve. A peer could splice its balance out to its wallet and keep almost nothing in the channel, leaving it with nothing to lose by broadcasting a revoked commitment. BOLT 2 requires the receiving node to send tx_abort when a side that added an output other than the channel funding output ends below the reserve for the new capacity, and channeld only had a TODO there.

  • check_balances() now aborts the splice when a side that adds an output, or takes funds out of the channel by any route (fees included), would keep less than the reserve for the new capacity. Both sides are checked, so we also refuse to send such a splice ourselves.
  • The reserve is the one lightningd sets when the splice locks: 1% of the new capacity, or the opener's dust limit if greater. That rule moves into channel_reserve_for_capacity() in common/ so both daemons share it.
  • A side below the reserve that adds no output and takes nothing out is unaffected, as the spec allows.
  • The funds channeld reports as available for a splice are now the most that can leave while keeping the reserve for the capacity that remains, so <channel> -> 100% still works rather than always aborting. As opener we also keep the commitment fee for one more HTLC at the marginal feerate, plus the anchors, which is what adding an HTLC already requires, so the channel stays usable after the splice. A smaller percentage is now a share of that amount, so <channel> -> 50% takes half of what 100% would.

Lightning Fork already enforces the same rule on both sides (an added output or a negative contribution, against 1% of the new capacity), so this matches what it sends and accepts.

Test plan

  • test_splice_out_below_reserve: l2 splices out keeping 5,049 sat of a 505,049 sat channel, one below the 5,050 sat reserve. Both l1 and l2 send tx_abort on their own checks, no inflight is left, and keeping exactly 5,050 sat then splices, confirms and locks.
  • test_splice_in_with_change_below_reserve: l2, with no channel balance, splices in 5,000 sat with a change output and is refused against the 10,050 sat reserve. 20,000 sat then goes through.
  • test_splice_out_all_keeps_reserve: <channel> -> 100% leaves l2 exactly the 5,050 sat reserve of the 505,050 sat channel that remains, and locks.
  • test_splice_out_all_opener_keeps_fee: the opener splicing out 100% of its whole channel keeps 10,583 sat, which is the 546 sat dust-limit reserve, 9,377 sat of commitment fee and 660 sat for the anchors.
  • test_script_two_chan_splice_out took everything l2 held out of its channel with l1, leaving 0 against a 9,000 sat reserve. It now takes 90,000 sat, keeping 10,000 sat above the 9,100 sat reserve.
  • test_script_two_chan_splice_n, _oo and _p splice out 50% of the opener's 500,000 sat in a 1,000,000 sat channel. 100% there would keep 15,201 sat (the 5,152 sat reserve plus 10,049 sat of fee headroom), so 50% takes 242,399 sat.
  • The reserve tests fail on the unfixed channeld and pass with the fix.
  • All of tests/test_splice.py, tests/test_splicing.py, tests/test_splicing_disconnect.py, tests/test_splicing_insane.py and tests/test_opening.py pass locally, with and without dual funding.
  • BOLT quote checks pass against the pinned spec version, and the new quote matches current BOLT 2.

…serve

Changelog-Fixed: Splicing refuses a splice that leaves a side which adds an output or takes funds out below the channel reserve for the new capacity.
Changelog-Changed: A splice script's percentage of a channel, such as `100%`, is now of the funds that can leave while keeping the channel reserve and, for the channel's opener, the commitment fee for one more HTLC, not of the whole balance.
@kwsantiago
kwsantiago merged commit 6693675 into blake2b-unified Nov 16, 2026
89 of 91 checks passed
@kwsantiago
kwsantiago deleted the splice-reserve-negotiation branch November 16, 2026 15:00
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.

1 participant