channeld: fail channel on zero next_commitment_number - #9435
Open
vincenzopalazzo wants to merge 2 commits into
Open
channeld: fail channel on zero next_commitment_number#9435vincenzopalazzo wants to merge 2 commits into
vincenzopalazzo wants to merge 2 commits into
Conversation
vincenzopalazzo
force-pushed
the
channeld-fail-zero-reestablish-commit
branch
from
August 18, 2026 09:31
e90f23d to
281e95c
Compare
BOLT ElementsProject#2 says if next_commitment_number is zero we MUST immediately fail the channel and broadcast the latest commitment. On an advanced channel a reset peer sends 0 for both numbers; we warn about the stale revocation_number and never reach the zero check, so the channel stays up. The test funds, pays so next_index is past 1, then injects that reestablish. It fails until the next commit. Reproduces: ElementsProject#9425 Reported-by: Leo Nash (@tankyleo) Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
The existing BOLT ElementsProject#2 quote already required this, but the first bullet was unimplemented: the only zero check sat under next_commitment_number == next_index[REMOTE] - 1, after the stale-revocation warning. Implement that bullet next to the quote, and drop the nested copy. Fixes: ElementsProject#9425 Changelog-Fixed: Protocol: immediately fail the channel if channel_reestablish next_commitment_number is zero. Reported-by: Leo Nash (@tankyleo) Signed-off-by: Vincenzo Palazzo <vincenzopalazzodev@gmail.com>
vincenzopalazzo
force-pushed
the
channeld-fail-zero-reestablish-commit
branch
from
August 18, 2026 11:51
281e95c to
bb2efbc
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.
BOLT #2 says if
next_commitment_numberis zero we MUST immediately fail the channel and broadcast the latest commitment. On an advanced channel a reset peer sends 0 for both numbers; we warned about the stalenext_revocation_numberand never reached the zero check, so the channel stayed up.The existing BOLT quote already required this. The first bullet was unimplemented: the only zero check sat under
next_commitment_number == next_index[REMOTE] - 1, after the revocation warning. Implement that bullet next to the quote, and drop the nested copy.Two commits, test then fix:
tests: reproduce zero next_commitment_number on advanced channelchanneld: fail channel on zero next_commitment_numberLocal:
test_reestablish_zero_commitment_numberfails on the first commit (transient warning, no close) and passes on the second.Thanks to Leo Nash (@tankyleo) for the report.
Fixes: #9425
Reported-by: Leo Nash (@tankyleo)
Changelog-Fixed: Protocol: immediately fail the channel if channel_reestablish next_commitment_number is zero.