routing+routerrpc+lncli: enable last hop restriction for payments

This commit is contained in:
Joost Jager committed 2019-11-18 21:03:03 +01:00
1 parent 814dbea745
commit f28941c7e4
10 files changed
+760 -675

No files matched your search

+13
View File
@@ -3017,6 +3017,7 @@ type rpcPaymentIntent struct {
cltvDelta uint16
routeHints [][]zpay32.HopHint
outgoingChannelID *uint64
lastHop *route.Vertex
payReq []byte
destTLV []tlv.Record
@@ -3058,6 +3059,17 @@ func extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPaymentIntent, error
payIntent.outgoingChannelID = &rpcPayReq.OutgoingChanId
}
// Pass along a last hop restriction if specified.
if len(rpcPayReq.LastHopPubkey) > 0 {
lastHop, err := route.NewVertexFromBytes(
rpcPayReq.LastHopPubkey,
)
if err != nil {
return payIntent, err
}
payIntent.lastHop = &lastHop
}
// Take the CLTV limit from the request if set, otherwise use the max.
cltvLimit, err := routerrpc.ValidateCLTVLimit(
rpcPayReq.CltvLimit, cfg.MaxOutgoingCltvExpiry,
@@ -3237,6 +3249,7 @@ func (r *rpcServer) dispatchPaymentIntent(
PaymentHash: payIntent.rHash,
RouteHints: payIntent.routeHints,
OutgoingChannelID: payIntent.outgoingChannelID,
LastHop: payIntent.lastHop,
PaymentRequest: payIntent.payReq,
PayAttemptTimeout: routing.DefaultPayAttemptTimeout,
FinalDestRecords: payIntent.destTLV,