AI-generated analysisPublished automatically and not human-verified. Validated context appears in community notes below.
← Watch feed
Informational 17 Bitcoin

lntest: make sure HTLCs are locked in when sending a payment

Public commit record

What the developer wrote

Authored by ziggie

83/100 · Strong
lntest: make sure HTLCs are locked in when sending a payment

Before this change, CompletePaymentRequestsNoWait would return as
soon as the channel's NumUpdates increased by at least one. When
sending multiple payments, this meant the function could return
while some HTLCs were still in-flight and not yet committed to the
channel state.

The problem occurred when tests captured the channel state
immediately after calling this function. Even though we read the
current NumUpdates from the channel, HTLCs could still be in the
process of being committed. This led to a race where the channel
would progress to a new state after we thought we had correctly
captured it, causing tests to see unexpected commitment heights.

Fix this by waiting for all outgoing HTLCs to appear in
PendingHtlcs before returning. We count outgoing HTLCs before
sending, then wait until exactly len(paymentRequests) new HTLCs
are present. This guarantees all payments have fully completed
their commitment exchange and are locked in on both sides.

Fixes the flaky revokedCloseRetributionRemoteHodlCase test where
backups would capture state at height N+1 instead of the expected
height N.
✓ Specific, descriptive subject✓ Names a concrete action or component✓ Provides detailed explanatory context✓ Mentions testing or verification
The short version

What changed, and why it matters

This commit fixes a timing bug in LND's internal test helper. The helper previously returned too early when sending test payments, before all payment commitments were fully recorded on the channel. This caused occasional flaky test failures because tests captured channel state at the wrong moment. The fix makes the helper wait until every sent payment appears as a pending HTLC. There is no indication this affects real user funds or production code paths.

Recommended action

No security action required. Treat as a normal test reliability improvement. Reviewers may optionally verify that the new PendingHtlcs-based wait condition is robust against HTLCs that settle or fail before the count is checked, though the commit message indicates the intended use is for in-flight HTLCs.

Security signals we found

01

Race condition in test synchronization helper

02

No production code path modified

03

No cryptographic, network, or consensus logic changed

04

Fixes flaky test revokedCloseRetributionRemoteHodlCase

Risk score

Why this scored 17/100

Our methodology →
Potential impact 2/30
Exploitability 0/25
Stealth signal 0/15
Affected reach 1/15
Confidence 9/10
Evidence quality 5/5
Human-validated context

Community notes

Notes can correct, qualify, or add evidence to the AI analysis. Every note shown here has been validated by a human moderator.

No validated notes yet.

The AI analysis stands alone for now. Submit a note if you can add evidence or important context.