From 038ce342b31a237e44abd0b2b763b6b1082c248c Mon Sep 17 00:00:00 2001 From: Joost Jager Date: Mon, 8 Apr 2019 18:16:21 +0200 Subject: [PATCH] htlcswitch: do not check final cltv for accepted invoices --- htlcswitch/link.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/htlcswitch/link.go b/htlcswitch/link.go index 41725f16..076415b2 100644 --- a/htlcswitch/link.go +++ b/htlcswitch/link.go @@ -2775,10 +2775,15 @@ func (l *channelLink) processExitHop(pd *lnwallet.PaymentDescriptor, } // We'll also ensure that our time-lock value has been computed - // correctly. + // correctly. Only check the final cltv expiry for invoices when the + // invoice has not yet moved to the accepted state. Otherwise hodl htlcs + // would be canceled after a restart. expectedHeight := heightNow + minCltvDelta switch { - case !l.cfg.DebugHTLC && pd.Timeout < expectedHeight: + case !l.cfg.DebugHTLC && + invoice.Terms.State != channeldb.ContractAccepted && + pd.Timeout < expectedHeight: + log.Errorf("Incoming htlc(%x) has an expiration that is too "+ "soon: expected at least %v, got %v", pd.RHash[:], expectedHeight, pd.Timeout)