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

This commit is contained in:
Joost Jager
2019-11-18 12:08:42 +01:00
parent 814dbea745
commit f28941c7e4
10 changed files with 760 additions and 675 deletions

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,