rpcserver+routerrpc: thread features + payment addr to SendPayment

This commit is contained in:
Conner Fromknecht 2019-12-18 23:56:59 -08:00
parent 0993256b77
commit f868bc128b
No known key found for this signature in database
GPG Key ID: E7D737B67FA592C7
4 changed files with 27 additions and 3 deletions

@ -602,6 +602,8 @@ func (r *RouterBackend) extractIntentFromSendRequest(
payIntent.RouteHints = append( payIntent.RouteHints = append(
payIntent.RouteHints, payReq.RouteHints..., payIntent.RouteHints, payReq.RouteHints...,
) )
payIntent.DestFeatures = payReq.Features
payIntent.PaymentAddr = payReq.PaymentAddr
} else { } else {
// Otherwise, If the payment request field was not specified // Otherwise, If the payment request field was not specified
// (and a custom route wasn't specified), construct the payment // (and a custom route wasn't specified), construct the payment

@ -98,6 +98,8 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
LastHop: payment.LastHop, LastHop: payment.LastHop,
CltvLimit: cltvLimit, CltvLimit: cltvLimit,
DestCustomRecords: payment.DestCustomRecords, DestCustomRecords: payment.DestCustomRecords,
DestFeatures: payment.DestFeatures,
PaymentAddr: payment.PaymentAddr,
} }
// We'll also obtain a set of bandwidthHints from the lower layer for // We'll also obtain a set of bandwidthHints from the lower layer for
@ -131,9 +133,10 @@ func (p *paymentSession) RequestRoute(payment *LightningPayment,
route, err := newRoute( route, err := newRoute(
sourceVertex, path, height, sourceVertex, path, height,
finalHopParams{ finalHopParams{
amt: payment.Amount, amt: payment.Amount,
cltvDelta: finalCltvDelta, cltvDelta: finalCltvDelta,
records: payment.DestCustomRecords, records: payment.DestCustomRecords,
paymentAddr: payment.PaymentAddr,
}, },
) )
if err != nil { if err != nil {

@ -1601,6 +1601,19 @@ type LightningPayment struct {
// is reached. If nil, any node may be used. // is reached. If nil, any node may be used.
LastHop *route.Vertex LastHop *route.Vertex
// DestFeatures specifies the set of features we assume the final node
// has for pathfinding. Typically these will be taken directly from an
// invoice, but they can also be manually supplied or assumed by the
// sender. If a nil feature vector is provided, the router will try to
// fallback to the graph in order to load a feature vector for a node in
// the public graph.
DestFeatures *lnwire.FeatureVector
// PaymentAddr is the payment address specified by the receiver. This
// field should be a random 32-byte nonce presented in the receiver's
// invoice to prevent probing of the destination.
PaymentAddr *[32]byte
// PaymentRequest is an optional payment request that this payment is // PaymentRequest is an optional payment request that this payment is
// attempting to complete. // attempting to complete.
PaymentRequest []byte PaymentRequest []byte

@ -3241,6 +3241,8 @@ type rpcPaymentIntent struct {
routeHints [][]zpay32.HopHint routeHints [][]zpay32.HopHint
outgoingChannelID *uint64 outgoingChannelID *uint64
lastHop *route.Vertex lastHop *route.Vertex
destFeatures *lnwire.FeatureVector
paymentAddr *[32]byte
payReq []byte payReq []byte
destCustomRecords record.CustomSet destCustomRecords record.CustomSet
@ -3370,6 +3372,8 @@ func (r *rpcServer) extractPaymentIntent(rpcPayReq *rpcPaymentRequest) (rpcPayme
payIntent.cltvDelta = uint16(payReq.MinFinalCLTVExpiry()) payIntent.cltvDelta = uint16(payReq.MinFinalCLTVExpiry())
payIntent.routeHints = payReq.RouteHints payIntent.routeHints = payReq.RouteHints
payIntent.payReq = []byte(rpcPayReq.PaymentRequest) payIntent.payReq = []byte(rpcPayReq.PaymentRequest)
payIntent.destFeatures = payReq.Features
payIntent.paymentAddr = payReq.PaymentAddr
if err := validateDest(payIntent.dest); err != nil { if err := validateDest(payIntent.dest); err != nil {
return payIntent, err return payIntent, err
@ -3492,6 +3496,8 @@ func (r *rpcServer) dispatchPaymentIntent(
PaymentRequest: payIntent.payReq, PaymentRequest: payIntent.payReq,
PayAttemptTimeout: routing.DefaultPayAttemptTimeout, PayAttemptTimeout: routing.DefaultPayAttemptTimeout,
DestCustomRecords: payIntent.destCustomRecords, DestCustomRecords: payIntent.destCustomRecords,
DestFeatures: payIntent.destFeatures,
PaymentAddr: payIntent.paymentAddr,
} }
preImage, route, routerErr = r.server.chanRouter.SendPayment( preImage, route, routerErr = r.server.chanRouter.SendPayment(