From 5d68f0f9ebe9dd96c12919498564f7839e200730 Mon Sep 17 00:00:00 2001 From: Olaoluwa Osuntokun Date: Thu, 11 Apr 2019 17:53:25 -0700 Subject: [PATCH] htlcswitch: only perform CLTV checks for HTLCs with open invoices In this commit, we fix a bug that would cause a node with a hodl HTLC to cancel back the HTLC upon restart if the invoice has been settled, but the HTLC is still present on the commitment transaction. A fix for the HTLC still being present (not triggering a new commitment) has been fixed recently. However, for older nodes with a lingering HTLC, on restart it would be failed back. In this commit, we make the check stricter by only performing these checks for HTLCs that are in the open state. This ensures that we'll only check this constraints the first time around, before the HTLC has been transitioned to the accepted state. --- htlcswitch/link.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 488ea74d..79a37f00 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -2792,7 +2792,7 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor, expectedHeight := heightNow + minCltvDelta switch { case !l.cfg.DebugHTLC && - invoice.Terms.State != channeldb.ContractAccepted && + invoice.Terms.State == channeldb.ContractOpen && pd.Timeout < expectedHeight: log.Errorf("Incoming htlc(%x) has an expiration that is too "+