Correctness fixes for node announcement validation, HTLC limits, funding state release, BOLT text, and gossip cache #11632
🔴 PR Severity: CRITICAL
gh pr view | 26 files | 1271 additions / 89 deletions
<details>
<summary>🔴 <strong>Critical</strong> (4 files)</summary>
funding/manager.go - channel funding workflow coordinationlnwallet/reservation.go - channel funding/reservation logiclnwire/lnwire.go - Lightning wire protocol message handlinglnwire/node_announcement.go, lnwire/node_announcement_2.go - wire protocol message definitionsserver.go - core server coordination</details>
<details>
<summary>🟠 <strong>High</strong> (1 file)</summary>
discovery/gossiper.go - gossip protocol handling</details>
<details>
<summary>🟡 <strong>Medium</strong> (6 files)</summary>
accessman.go - top-level Go file, not separately categorizedbolt12/validate.go - BOLT12 validation logicchannel_notifier.go - top-level Go file, not separately categorizednetann/channel_announcement.go - network announcement helperszpay32/decode.go, zpay32/invoice.go - invoice encoding/decoding</details>
<details>
<summary>🟢 <strong>Low</strong> (1 file)</summary>
docs/release-notes/release-notes-0.22.0.md - release notes</details>
Analysis
This PR is classified CRITICAL because it modifies funding/manager.go and lnwallet/reservation.go (channel funding/reservation workflow), lnwire/* (wire protocol message definitions), and server.go (core server coordination). It additionally touches discovery/gossiper.go (HIGH) and several MEDIUM-tier packages. Because the change spans multiple distinct critical packages (funding, lnwallet, lnwire, server.go), it would normally warrant an additional severity bump, but CRITICAL is already the highest tier. Non-test/non-generated changes total 14 files and ~374 lines, below the file/line count bump thresholds on their own. Given the breadth across wire protocol, funding, and server-level code, this PR warrants expert review.
---
<sub>To override, add a severity-override-{critical,high,medium,low} label.</sub>
<!-- pr-severity-bot -->
I found three issues at 7ec8c3e that I’d address before merge.
1. Funding validation failure can enter the channel_ready success path. Cleanup closes the discovery signal that ordinarily means confirmation succeeded. The failed channel is still in the DB as pending, so the readiness handler can proceed with state changes. The handler should check the persisted open state before processing readiness.
2. An offline funding timeout can consume a restricted slot. The missing-score branch synthesizes a score, and the last-pending-channel path charges a live restricted slot. Update the pending count without adding a score or changing slot accounting for offline peers.
3. BOLT text writers still accept unassigned Unicode code points. BOLT 1 allows readers to accept Cn, but the writer rule excludes all C* categories. Apply the stricter rule at local authoring boundaries while preserving validation and serialization of received announcements.
make lint-native also reported three line-length findings and one whitespace finding. The enabled staticcheck analyzer reported no findings on the diff.
The code changes address the findings from my review, including the startup and invoice compatibility fixes and the reconnect-pruning guard. The local tests, native lint, staticcheck, and GitHub Static Checks passed on this revision.
The release-note fragment check still needs to pass before merge.
Could these entries move to docs/release-notes/unreleased/11632.md, each linking to this PR? The release-notes check rejects edits to the version file and entries without a PR link.
This matches the spec (lightning/bolts#1341 says readers MUST fail the payment), but lnd would be the first to enforce it. Today CLN, Eclair and LDK only check that the description is valid UTF-8, so they still create and pay invoices with newlines. CLN (ElementsProject/lightning#9398) and Eclair (ACINQ/eclair#3329) have open PRs to reject them; I couldn't find one for LDK. Once this ships, lnd users can't pay any of those invoices, or invoices from older lnd, while other wallets still can. The spec discussion measured gossip impact but not invoices.
Should we plan the rollout for that period? For example, warn about it in the release note, or decode leniently for a release while enforcing on the writer side. Separately, the user sees "description is not valid UTF-8", which is inaccurate for valid UTF-8. Could the error name the rejected character?
Dropping remote announcements with these aliases matches BOLT 7 (MUST ignore), and t-bast's mainnet scan on lightning/bolts#1341 found only 9 affected nodes. Local behaviour still needs attention, though. Cf includes the zero-width joiner (U+200D) used in emoji like 👨💻, so after upgrading:
alias=: lnd fails at startup with "invalid configured alias: node alias has non-utf8 characters". That's misleading, since the alias is valid UTF-8.peersrpc.UpdateNodeAnnouncement: it is silently replaced on the network with the hex pubkey, with only a WARN log.Can the error name the rejected character, and can the release note warn about the startup failure and the alias reset?
If bitcoin.minhtlc or openchannel --min_htlc_msat is above the remote's maximum, the advertised minimum is capped here with no log line. Could we log when this happens, so operators know their setting wasn't applied? Fine as a follow-up.
This entry describes the change in spec terms only. Could it add a plain-language line for operators: emoji that use zero-width joiners and newlines in invoice memos are no longer accepted, an invalid configured alias now stops startup, and a stored alias may be reset to the pubkey default?
Thanks for batching these, the fixes look good from a product side. Main asks before merge:
1. Release note needs to move to docs/release-notes/unreleased/11632.md with PR links, or the check will fail.
2. The BOLT 1 text rules match bolts#1341, but lnd would be the first implementation to enforce them. CLN, Eclair and LDK still create and pay invoices with newlines in the description. Can we plan the rollout (release-note warning, or lenient decoding for a release)?
3. Local alias handling: a ZWJ emoji in alias= now stops startup with a misleading "non-utf8" error, and a stored alias may be silently reset to the pubkey. Please make the errors and the release note clear for operators.
Thanks, Suheb. I’ve prepared a local update for these comments:
docs/release-notes/unreleased/11632.md and linked each entry to this PR. Both release-note checks pass locally.The targeted Go tests and native lint, including staticcheck, pass. The changes are still local.
Thanks for working through all five. The release note now gives operators clear steps for the stricter text rules, and the new errors name the rejected character. LGTM from a product side.
Created backport PR for v0.21.x-branch:
Please cherry-pick the changes locally and resolve any conflicts.
git fetch origin backport-11632-to-v0.21.x-branch
git worktree add --checkout .worktree/backport-11632-to-v0.21.x-branch backport-11632-to-v0.21.x-branch
cd .worktree/backport-11632-to-v0.21.x-branch
git reset --hard HEAD^
git cherry-pick -x 4174c1c07779b2c1c90b89aa7a144a418a5078d5 67d26d85029f9675e5a611e86cf7f283056e88df 710a79e898beb6a4731340ca4ea9573efa7d417e 03d59d5cc0cc7a0cfc4fb742b75d04ae66bcdb3f 979648da2f226d203fe8035a4e88d48e5b14dcca d1ddf7cab1399808f0ddc28486968c82bdf950a4 62e730808c49ee197e826a843e357c44de5b3d18 dc22517552782dae2c6ebe2831e5ba63299c7190 bcafd9e847abaa086a0d8dd058ef3ae8c291a16d c6c09479722f0ba82d299b88728917780da7381c 4d94fc6500360ea5985a22a964e1dd38cfb85e07
git push --force-with-lease
ziggie1984
Roasbeef
This PR is a batch of correctness fixes for the Morehouse public issue set. Each fix is in its own commit with a regression test.
Fixes
netannnow rejectschannel_announcementmessages whosenode_id_1is not lexicographically beforenode_id_2, as BOLT 7 requires. The check runs before signature validation, so invalid announcements are rejected cheaply.channel_update(minimum HTLC above capacity, zero max pending amount) are rejected during funding, and our advertised minimum HTLC is capped at the usable maximum.funding_signednow release all pinned state: the local discovery signal, the initial forwarding policy row, the channel opening state row, the chain arbitrator's watch, on-disk backups, and access-manager pending counts. Persistent connection state is only pruned when the peer has no remaining channels.Notes
-tags=dev; the scoped custom linter reports no findings on this branch.ValidBoltTextwas independently reviewed against the BOLT 1 reader requirements.