lnworker: keep watchtower sync alive on invalid get_ctn replies - #10857
Open
rdymac wants to merge 1 commit into
Open
lnworker: keep watchtower sync alive on invalid get_ctn replies#10857rdymac wants to merge 1 commit into
rdymac wants to merge 1 commit into
Conversation
Co-authored-by: Cursor <cursoragent@cursor.com>
rdymac
marked this pull request as ready for review
August 15, 2026 16:16
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.
Summary
get_ctnfrom a remote watchtower (must be a non-negativeint) before feeding it torange()/assert ctn >= 0.while Truesync loop so one bad reply cannot kill watchtower updates for the rest of the session.A JSON-RPC
get_ctnresult was used unvalidated. A negative or non-int value (including HTTP non-200 returning an'Error: …'string) escaped the loop'sexcept aiohttp.ClientError. The coroutine is spawned once instart_network, so syncing then stopped for all channels until restart.Tests
Optional tests live on a separate branch, not in this PR: watchtower_invalid_ctn-test. Pull that if you want the unit tests as well.
Comments already received on the suggested fix
util.py:763already hasis_non_negative_integer, andlnworker.py:38already imports from.util.is_integeris justisinstance(val, int), so the helper acceptsTrue/False.type(watchtower_ctn) is not intrejects them. A watchtower answering JSONtruewould otherwise becomerange(2, n)silently treated as ctn=1.Suggested in-code comment:
python