Skip to content

openingd: fail open_channel at receipt when our dust limit exceeds their reserve - #9479

Open
Amperstrand wants to merge 4 commits into
ElementsProject:masterfrom
Amperstrand:pr9439-open-channel-dust-must
Open

Amperstrand wants to merge 4 commits into
ElementsProject:masterfrom
Amperstrand:pr9439-open-channel-dust-must

Conversation

@Amperstrand

@Amperstrand Amperstrand commented Sep 5, 2026 •

Copy link
Copy Markdown

BOLT #2 requires the accept_channel sender to set dust_limit_satoshis
less than or equal to channel_reserve_satoshis from the open_channel
message. CLN's fundee_channel() quotes this exact MUST in its comment
block but implements no check for it: with the chainparams dust limit (546)
and an opener reserve below that, CLN replies accept_channel with
dust_limit_satoshis=546, violating the sender MUST. A spec-strict opener
then fails the channel (the reporter's LDK LSP sits at the 354-sat floor
the spec itself mandates as the minimum dust limit); nothing above DEBUG
on our side records why (#9439).

This adds the mirror of the existing opener-side check (dust limit … would be above our reserve, now check_dust_limit() in openingd/common.c)
to the accepter path, respecting --dev-allowdustreserve like both
neighboring checks.

Folded in from #9527 (per reviewer request): the accepter-side self-consistency fix for #9515

As fundee, set_reserve_absolute() used to floor our 1% channel reserve at
the peer's dust_limit_satoshis only, never at our own — so on channels
below ~54,600 sat we could send an accept_channel whose
dust_limit_satoshis (546) exceeds its own channel_reserve_satoshis
(#9515, found and fixed by @Andezion in #9527; his commit is folded here
verbatim, authorship preserved). The two checks are duals that together
make the accepter side BOLT-#2-clean in both directions:

set_reserve_absolute()'s floor now also covers the master-supplied
absolute-reserve path used on the v1 accepter side; the
check_dust_limit() refactor on master (both call sites and dualopend)
is untouched.

Notes for reviewers

  • The opener side already enforces the same rule when CLN opens (fails
    an accept_channel whose dust exceeds our reserve) — two unpatched
    CLN nodes reject each other in this shape (the opener under
    --dev-allowdustreserve; a stock fundchannel self-bumps its
    reserve to 546, so the violating open is unreachable without it).
  • The quoted-MUST comment block sits under "Pending proposal to remove
    these limits." — but until the bolts change, the MUST stands, and
    stock CLN violates it against strict peers today.
  • Verified on the official v25.02 / v26.06 / v26.06.7 binaries and the
    docker v26.06 tag with a BOLT8 wire peer: the violation reproduces
    at every reserve below 546 I probed (354, 545), clean at 546.
  • The in-suite test runs the opener under --dev-allowdustreserve to
    send a true sub-546 reserve (same crutch as test_zeroreserve); it
    fails on master and passes with this change.
  • With the check in place a spec-strict peer no longer needs to error:
    CLN fails first, at open_channel receipt.
  • Fold validation: branch rebased on current master; all four commits
    build clean, and the full dust/reserve test selection passes —
    test_dust_limit_above_reserve, test_zeroreserve,
    test_zeroreserve_mixed, test_zeroreserve_alldust, and Andezion's
    wire-level test_accept_channel_reserve_below_our_dust_limit
    (his reserve=546 deliberately clears the openingd: accept_channel violates BOLT 2 when the peer's channel_reserve_satoshis is below our dust limit (silent open failure) #9439 receipt check, so
    the two tests exercise exactly one fix each).
pre-fix wire journal (v26.06.7): accept_channel with dust_limit 546 against opener reserve 354 — expand
"kind": "accept_channel", "dust_limit_satoshis": 546, ... "channel_reserve_satoshis": 1500,
  "channel_type": "401000"   (opener's open_channel carried channel_reserve_satoshis: 354)
post-fix (pr9439): rejection at open_channel receipt + the inclusive 545/546 boundary — expand
"kind": "wire_error", "data": "You gave bad parameters: Our dust limit 546sat would be above their reserve 354sat"
boundary-r545: accepted=NO  ... would be above their reserve 545sat
boundary-r546: accepted=YES (accept_channel; 546 > 546 is false — the MUST is <=)

Fuller validation record — every cell, the four-version matrix, the red/green transcript, and the repro recipe: https://gist.github.com/Amperstrand/880bf568f792db0227666e9472d2c9b5

Fixes #9439
Fixes #9515

(Second issue and its fix folded in from #9527 by @Andezion, with his
commit cherry-picked verbatim — #9527 can be closed once this merges.)

Andezion
Andezion previously approved these changes Sep 8, 2026

@Andezion Andezion 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.

Given dualopend.c (v2 / dual-funding) has no equivalent reserve/dust cross-check at all, and the issue flags that a channel under ~~54,600 sat can hit the same class of problem there (derived 1% reserve below 546) - is a follow-up planned for that path, or is it intentionally left out because the reserve there is derived rather than negotiated?

@Amperstrand

Copy link
Copy Markdown
Author

Intentionally left out — the derivation closes it. v2 floors the reserve at max(1% of total, dust_limit) on both sides (the clamp in dualopend.c's set_reserve, per the spec's own rule), so the sub-54,600 case floors both reserves at 546 rather than below dust. The dead-channel shape needs both initial balances at or under reserve, i.e. total <= 2x reserve — check_config_bounds rejects that arithmetic at every dualopend site, and above 54,600 it's outright impossible (2x1% < total). One side under its reserve is fine: the spec notes it "may not be met" initially, and v2 lets the accepter fund zero. The shared initial_commit_tx backstop still fails loudly if it ever sees it. Happy to open a follow-up if you see a shape I'm missing.

@madelinevibes madelinevibes added this to the v26.09 milestone Sep 14, 2026
@daywalker90
daywalker90 force-pushed the pr9439-open-channel-dust-must branch from 52b7f86 to 04840a3 Compare September 14, 2026 10:26
@daywalker90

Copy link
Copy Markdown
Collaborator

CI is failing with:

FAILED tests/test_opening.py::test_zeroreserve_mixed - pyln.client.lightning.RpcError: RPC call failed: method: fundchannel, payload: {'id': '033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a', 'amount': 1000000, 'announce': True, 'reserve': '0sat'}, error: {'code': -1, 'message': 'They sent ERROR channel ddf4fcde6d97bcae2473e8dfe3f94710fa3e8a855a9f81875555173f4152df02: You gave bad parameters: Our dust limit 546sat would be above their reserve 0sat', 'data': {'id': '033845802d25b4e074ccfd7cd8b339a41dc75bf9978a034800444b51d42b07799a', 'method': 'fundchannel_start'}}

@Amperstrand

Copy link
Copy Markdown
Author

That's the new receipt check on a shape the test relied on: test_zeroreserve_mixed had l2 accept l1's 0sat reserve while l2's dust limit is the chainparams 546 — the accepter-side MUST this PR enforces, and a stock accepter has no legal dust_limit_satoshis against a 0sat reserve at all (the spec floors dust at 354). l2 sets --dev-allowdustreserve now — the same crutch its sibling tests already use on every node. Mixed/all zeroreserve tests pass on both networks locally. Fix pushed (0ef2286); anything smaller that comes up, feel free to push to the branch directly.

@Amperstrand
Amperstrand force-pushed the pr9439-open-channel-dust-must branch from 0ef2286 to 630da2c Compare September 21, 2026 07:19
@madelinevibes madelinevibes modified the milestones: v26.09, v26.12 Oct 14, 2026
@madelinevibes madelinevibes removed this from the v26.12 milestone Nov 9, 2026
@madelinevibes

Copy link
Copy Markdown
Collaborator

@Amperstrand FYI: https://t.me/lightningd/39196
CLN skipped 26.09 to prioritize security fixes but after four HUGE point releases v26.06.7, .8, .9 and .10 we're back to focus on CLN v26.12.
This PR has been removed from the 26.12 Milestone. Instead of throwing everything at the milestone and moving it on if it doesn't get done, let's add things to the Github Release Milestone that have an owner to shepherd them through and make sure they get done!
If you've been working on any and are committed to seeing it through to release time, feel free to add back on.🤓
Updating here or join the conversation in Discord. https://discord.gg/geG54FzHdK

@sangbida

sangbida commented Nov 12, 2026 •

Copy link
Copy Markdown
Collaborator

@Amperstrand @Andezion I think we should keep one PR for #9439 and #9515 rather than carry two very similar fixes. I mildly prefer #9479 as the base. Could we fold the changes and test from #9527 into this PR? Then this can close both issues and we can close #9527.

Amperstrand and others added 4 commits November 12, 2026 08:16
…eir reserve

BOLT #2 requires the accept_channel sender to set dust_limit_satoshis
less than or equal to channel_reserve_satoshis from the open_channel
message. fundee_channel() quotes this exact MUST in its comment block
but implements no check for it: with the chainparams dust limit (546)
and an opener reserve below that, CLN replies accept_channel with
dust_limit_satoshis=546, violating the sender MUST. Spec-strict peers
(e.g. an LDK opener at the 354-sat spec-minimum dust limit) then fail
the channel, with nothing above DEBUG on our side recording why.

Mirror the existing opener-side check (openingd.c:446-455) in the
accepter path, respecting --dev-allowdustreserve like both
neighboring checks. The in-suite test sends a true sub-546 reserve by
running the opener under --dev-allowdustreserve (a stock fundchannel
self-bumps to its dust limit, mirroring test_zeroreserve's
construction); it fails on master and passes with this change.

Changelog-Fixes: ElementsProject#9439
Fixes: ElementsProject#9439
The new accepter-side check (dust_limit <= their reserve) rejects
l1's 0sat-reserve open at l2, whose dust limit is the chainparams
546 -- and a stock accepter has no legal dust_limit against a 0sat
reserve at all (the spec floors dust at 354). l2 sets
--dev-allowdustreserve, the same crutch its sibling tests already
use on every node; mixed/all zeroreserve tests pass on both
networks.

Changelog-None: test-only
Signed-off-by: Amperstrand <amperstrand@localhost>
Changelog-Fixed: 'openingd' no longer sends an 'accept_channel' whose 'channel_reserve_satoshis' is below its own 'dust_limit_satoshis'
Master's comment above the fundee set_reserve() call predates the
folded floor in set_reserve_absolute(), which now bumps our reserve
to the higher of the two dust limits, not just the peer's. Say so.

Changelog-None: comment-only
Signed-off-by: Amperstrand <amperstrand@localhost>
@Amperstrand
Amperstrand force-pushed the pr9439-open-channel-dust-must branch from 630da2c to 54c55b9 Compare November 12, 2026 09:07
@Amperstrand

Copy link
Copy Markdown
Author

Agreed — folded in: #9527's change and its wire-level test are now in this branch (Andezion's commit cherry-picked verbatim, authorship kept), rebased on current master. This PR now closes both #9439 and #9515, so #9527 can be closed (for @Andezion to confirm). CI needs an approval click on the new head.

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants