Repository navigation
Count the funding fee in the anchor reserve check for splice-ins - #1223
Open
shubhamkmr04 wants to merge 2 commits into
Open
shubhamkmr04 wants to merge 2 commits into
shubhamkmr04 wants to merge 2 commits into
Conversation
|
👋 Thanks for assigning @tnull as a reviewer! |
shubhamkmr04
force-pushed
the
splice-in-reserve-fees
branch
2 times, most recently
from
November 11, 2026 08:57
afede9a to
39ef2ad
Compare
shubhamkmr04
force-pushed
the
splice-in-reserve-fees
branch
from
November 17, 2026 12:15
39ef2ad to
0c1cba9
Compare
shubhamkmr04
force-pushed
the
splice-in-reserve-fees
branch
from
November 17, 2026 13:23
0c1cba9 to
0689499
Compare
Splicing in an exact amount is about to also check what its built contribution takes from our wallet, fee included. Coin selection locks the inputs it picks, which takes them off the spendable balance, so that check needs the balance from before coin selection. Have `check_sufficient_onchain_funds` return the spendable balance it checked the amount against, so that the splice-in can reuse it. Part of lightningdevkit#1166. Developed with assistance from Claude Code.
Splicing in an exact amount only checked that our on-chain funds cover the amount on top of the anchor reserve. The fee for our contribution to the splice transaction is paid from the same funds, though, and coin selection doesn't keep the reserve aside, so the fee could be taken from it. Once the contribution is built, also check that what it takes from our wallet, its inputs minus its change, fits in the funds beyond the reserve. Coin selection locks the inputs it picks, which takes them off the spendable balance, so compare against the balance from before it: the check of the amount alone now runs right before coin selection and provides it. If the contribution doesn't fit, release what coin selection locked for it and fail with `InsufficientFunds`. A plain lack of funds still fails before coin selection. Part of lightningdevkit#1166. Developed with assistance from Claude Code.
shubhamkmr04
force-pushed
the
splice-in-reserve-fees
branch
from
November 17, 2026 13:40
0689499 to
915b7dd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Part of #1166.
When splicing in an exact amount, we checked that our on-chain funds cover the amount on top of the anchor reserve, but not the fee for our contribution to the splice transaction, which is paid from the same funds. Coin selection doesn't keep the reserve aside, so the fee could come out of it.
Changes
check_sufficient_onchain_fundsnow returns the spendable balance it checked the amount against.splice_in: once LDK has built the contribution, we check that what it takes from our wallet, its inputs minus its change, fits in that balance, and fail withInsufficientFundsotherwise. LDK runs coin selection with the shared input and output, so the change is net of the whole fee, and inputs minus change is exactly the amount plus our fee. Checking the built contribution also avoids estimating the fee up front, which Buildsplice_in_with_allfrom manually selected inputs #1176 moved away from forsplice_in_with_all.splice_in, and a CHANGELOG entry.Testing
splice_in_fee_does_not_spend_anchor_reserve: node B holds 1,000,000 sats with a 25,000 sat anchor reserve. Splicing in 970,000 at 50 sat/vB fails withInsufficientFunds, because the ~12,500 sat fee would leave only ~17,500 for the reserve, and B's spendable balance is unchanged afterwards. The same amount at the regtest estimate splices in and keeps the reserve on-chain.Fee bumps are left for a follow-up: the reserve check when a bump of an exact splice-in shrinks its change or re-runs coin selection, and when a bump of a splice-out falls back to the wallet, as discussed in #1181.
This change was developed with the assistance of Claude Code.