routing: add new FinalCLTVDelta attribute to SendPayment

In this commit, we’ll now optionally allow the user to pass in the CLTV
delta value specified by the recipient a payment. If the value isn’t
specified, then we’ll use the current global default for the payment.
This commit is contained in:
Olaoluwa Osuntokun 2017-10-18 22:00:03 -07:00
parent c8f45e3a04
commit aee1619488
No known key found for this signature in database
GPG Key ID: 964EA263DD637C21

@ -1164,6 +1164,13 @@ type LightningPayment struct {
// the first hop. // the first hop.
PaymentHash [32]byte PaymentHash [32]byte
// FinalCLTVDelta is the CTLV expiry delta to use for the _final_ hop
// in the route. This means that the final hop will have a CLTV delta
// of at least: currentHeight + FinalCLTVDelta. If this value is
// unspcified, then a default value of DefaultFinalCLTVDelta will be
// used.
FinalCLTVDelta *uint16
// TODO(roasbeef): add e2e message? // TODO(roasbeef): add e2e message?
} }
@ -1194,6 +1201,13 @@ func (r *ChannelRouter) SendPayment(payment *LightningPayment) ([32]byte, *Route
return preImage, nil, err return preImage, nil, err
} }
var finalCLTVDelta uint16
if payment.FinalCLTVDelta == nil {
finalCLTVDelta = DefaultFinalCLTVDelta
} else {
finalCLTVDelta = *payment.FinalCLTVDelta
}
// We'll continue until either our payment succeeds, or we encounter a // We'll continue until either our payment succeeds, or we encounter a
// critical error during path finding. // critical error during path finding.
for { for {