htlcswitch: use the delta within the time lock, not the default policy at exit node

In this commit, we fix a lingering bug within the link when we're the
exit node for a particular payment. Before this commit, we would assert
that the invoice gives us enough of a delta based on our current routing
policy. However, if the invoice was generated with a lower delta, or
we've changed from the default routing policy, then this would case us
to fail back any payments sent to us.

We fix this by instead using the newly available final CLTV delta
information within the extracted invoice.

Fixes #1431.
This commit is contained in:
Olaoluwa Osuntokun 2018-06-26 16:58:12 -07:00
parent 8dcfeeaef5
commit a2f0d6d38e
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -2210,9 +2210,8 @@ func (l *channelLink) processRemoteAdds(fwdPkg *channeldb.FwdPkg,
// We'll also ensure that our time-lock value has been
// computed correctly.
//
// TODO(roasbeef): also accept global default?
expectedHeight := heightNow + l.cfg.FwrdingPolicy.TimeLockDelta
minCltvDelta := uint32(invoice.Terms.FinalCltvDelta)
expectedHeight := heightNow + minCltvDelta
switch {
case !l.cfg.DebugHTLC && fwdInfo.OutgoingCTLV < expectedHeight: