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.
This commit is contained in:
Olaoluwa Osuntokun 2019-04-11 17:53:25 -07:00
parent f9a08044dc
commit 5d68f0f9eb
No known key found for this signature in database
GPG Key ID: CE58F7F8E20FD9A2

View File

@ -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 "+