LND, a widely used Bitcoin Lightning Network implementation, has fixed a recordkeeping bug that could leave nodes missing records of settled payments after a restart. Versions v0.21.8-beta and v0.20.8-beta were released on November 11 with changes to update-log counting and recovery. Developers said they have not confirmed any exploitation or related financial losses.
The issue affected accounting consistency in Lightning payment channels. Each side relies on its own state records to track settled payments and the amounts owed between participants. If a node rebuilt an incomplete record after restarting, its view of the channel could differ from previously stored information.
A 16-bit counter overflowed at 65,536 updates
LND maintainer Olaoluwa Osuntokun, known as Roasbeef, said the bug involved a counter tracking the number of confirmed updates received from a peer. The counter used a 16-bit unsigned integer, which can represent values up to 65,535. When the update list reached 65,536 entries, the counter wrapped to zero, even though LND could continue writing updates to storage.
After a restart, the node could interpret the zero count as an empty list and omit one or more previously stored updates. These could include records for settled hash time-locked contracts (HTLCs), a conditional payment mechanism used to route payments across Lightning channels.
The bug did not necessarily mean the underlying data had been erased from disk. Rather, the node could use the incorrect count to rebuild an incomplete payment record during recovery. Because channel obligations depend on both sides maintaining consistent state, such a discrepancy could complicate account reconciliation.
Peer messages could keep updates accumulating
Developers also identified an interaction that could push the counter toward its limit. LND contributor ziggie1984 explained in a GitHub discussion that a peer could repeatedly send fee updates and commitment signatures without sending the required revocation messages, preventing the pending update list from clearing as expected.
Developers reproduced the behavior in a unit test: after 200 rounds of messages, the record had accumulated 201 updates. The entries remained after reconnection, so repeatedly disconnecting and reconnecting would not necessarily stop the list from growing. The disclosure described a possible trigger path but provided no evidence that a live node had reached the overflow threshold.
New releases add checks and validate recovery data
The fix prevents excessively large update lists from advancing channel state and checks them before writing to storage, stopping new oversized logs from being committed. LND also changed how older stored records are read: nodes now attempt recovery only when the entries and count pass validation and the record is complete. Malformed or invalid data is rejected.
The changes address the counter overflow in confirmed update logs. They were merged into LND's main development branch on November 5 and included in the v0.21.8-beta and v0.20.8-beta releases on November 11. Developers have not confirmed that the bug caused any user payment losses, and it remains unclear whether any node was affected before the fix.