mirror of
https://github.com/lightningnetwork/lnd.git
synced 2025-10-10 00:53:03 +02:00
routing+routerrpc+lncli: enable last hop restriction for payments
This commit is contained in:
13
rpcserver.go
13
rpcserver.go
@@ -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,
|
||||
|
Reference in New Issue
Block a user