lnrpc: deprecate multiple routes sendtoroute

This commit is contained in:
Joost Jager committed 2019-02-04 13:07:30 +01:00
1 parent 5a4951affd
commit 17645fefdf
4 files changed
+597 -557

No files matched your search

+17 -5
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{