[bug]: reverse the order inside invoice settlement flow #7463
Labels
bug
Unintended code behaviour
htlcswitch
intermediate
Issues suitable for developers moderately familiar with the codebase and LN
invoices
itests
Issues related to integration tests.
P2
should be fixed if one has time
Background
When updating an invoice state, we'd mark it as settled before the HTLC is locked in first, resulting in a possible edge case that although an invoice is marked as settled, the HTLC is timed out.
lnd/htlcswitch/link.go
Lines 3285 to 3307 in d321182
NotifyExitHopHtlc
, which callsnotifyExitHopHtlcLocked
.return l.processHtlcResolution(event, htlc)
.With the final settle signal introduced here this issue is mitigated with extra data, but this still needs a proper fix.
Steps to reproduce
Remove the following sleep in
testExternalFundingChanPoint
and run the itest,lnd/itest/lnd_funding_test.go
Lines 558 to 569 in d321182
Expected behavior
When the invoice is reported as settled, the commitment dance should be finished.
Possible Solutions
PendingSettle
to the invoice and replace it with the currentSettled
state. Then we only mark it as settled AFTER the HTLC lock-in.The text was updated successfully, but these errors were encountered: