lnrpc: deprecate multiple routes sendtoroute

This commit is contained in:
Joost Jager 2019-01-21 12:54:08 +01:00
parent 5a4951affd
commit 17645fefdf
No known key found for this signature in database
GPG Key ID: A61B9D4C393C59C7
4 changed files with 597 additions and 557 deletions

File diff suppressed because it is too large Load Diff

View File

@ -781,8 +781,16 @@ message SendToRouteRequest {
/// An optional hex-encoded payment hash to be used for the HTLC.
string payment_hash_string = 2;
/// The set of routes that should be used to attempt to complete the payment.
repeated Route routes = 3;
/**
Deprecated. The set of routes that should be used to attempt to complete the
payment. The possibility to pass in multiple routes is deprecated and
instead the single route field below should be used in combination with the
streaming variant of SendToRoute.
*/
repeated Route routes = 3 [deprecated = true];
/// Route that should be used to attempt to complete the payment.
Route route = 4;
}
message ChannelPoint {

View File

@ -2911,7 +2911,11 @@
"items": {
"$ref": "#/definitions/lnrpcRoute"
},
"description": "/ The set of routes that should be used to attempt to complete the payment."
"description": "*\nDeprecated. The set of routes that should be used to attempt to complete the\npayment. The possibility to pass in multiple routes is deprecated and \ninstead the single route field below should be used in combination with the \nstreaming variant of SendToRoute."
},
"route": {
"$ref": "#/definitions/lnrpcRoute",
"description": "/ Route that should be used to attempt to complete the payment."
}
}
},

View File

@ -2580,17 +2580,29 @@ func (r *rpcServer) SendToRoute(stream lnrpc.Lightning_SendToRouteServer) error
func unmarshallSendToRouteRequest(req *lnrpc.SendToRouteRequest,
graph *channeldb.ChannelGraph) (*rpcPaymentRequest, error) {
if len(req.Routes) == 0 {
switch {
case len(req.Routes) == 0 && req.Route == nil:
return nil, fmt.Errorf("unable to send, no routes provided")
case len(req.Routes) > 0 && req.Route != nil:
return nil, fmt.Errorf("cannot use both route and routes field")
}
routes := make([]*routing.Route, len(req.Routes))
for i, rpcroute := range req.Routes {
route, err := unmarshallRoute(rpcroute, graph)
var routes []*routing.Route
if len(req.Routes) > 0 {
routes = make([]*routing.Route, len(req.Routes))
for i, rpcroute := range req.Routes {
route, err := unmarshallRoute(rpcroute, graph)
if err != nil {
return nil, err
}
routes[i] = route
}
} else {
route, err := unmarshallRoute(req.Route, graph)
if err != nil {
return nil, err
}
routes[i] = route
routes = []*routing.Route{route}
}
return &rpcPaymentRequest{