lnd
lnd copied to clipboard
GRPC and REST endpoints differ for QueryRoutes (missing route_hints param for REST)
Background
The GRPC and REST endpoints for the QueryRoutes endpoint should be identical, but the REST endpoint is missing the route_hints param:
GRPC: https://api.lightning.community/#queryroutes
REST: https://api.lightning.community/#v1-graph-routes
Expected behaviour
allow the /v1/graph/routes endpoint to pass in a route_hints param.
Don't know if there is any reason why it is like that. I could commit a PR if it wanted.
REST is just a generic proxy for the gRPC interface. So all the fields are there. This seems to be a problem in the API docs generator. I'm pretty sure you can use the route_hints parameter, it just doesn't show up in the docs.
Or are you saying the REST interface doesn't accept the route_hints parameter? Then it might be a problem with the gRPC/REST proxy library.
I tried passing "route_hints" via REST, however, i'm pretty sure it needs to be encoded and or passed via some special case due to its "array of array of objects" structure.. I'm just not sure how it would be structured and the docs do not describe it. this issue could possibly be just an improvement to the docs to explain how to pass it properly.
Ah, i just found this in the API docs:
When using REST, the
dest_custom_recordsmap type can be set by appending&dest_custom_records[<record_number>]=<record_data_base64_url_encoded>to the URL. Unfortunately this map type doesn't appear in the REST API documentation because of a bug in thegrpc-gatewaylibrary.
So I guess that same bug is affecting route_hints as well. I'll add an update to the docs to also mention that.
Can you try if this works?
&route_hints[0].hop_hints[0].node_id=asdf&route_hints[1].hop_hints[0].node_id=xyz
Closing this issue as this is a problem of the API docs and not lnd itself (setting route hints does work in REST, the API doc generator just doesn't render the parameter correctly).
We are going to look at overhauling the API docs generator to fix this issue (along with a few other known bugs).
Closing this issue as this is a problem of the API docs and not lnd itself
@guggero are you sure this is not a problem with LND? I was not able to set routing hints by following your suggestion.
You gave the dest_custom_records example, however the variable types are not the same:
message QueryRoutesRequest {
...
map<uint64, bytes> dest_custom_records = 13;
...
repeated lnrpc.RouteHint route_hints = 16;
}
After looking at the code (mainly grpc-gateway) I can see support to parse list and maps:

However, routing hints is neither a list nor a map, in the end I think the code will end up throwing an error here:

When testing I have this error response:
{
"code": 3,
"message": "parsing list \"route_hints\": unsupported message type: \"lnrpc.RouteHint\"",
"details": []
}
Can you please double check this again? @razorman8669 did you manage to find a solution on your side? Maybe I'm missing something...
@AzulPretoBranco I ended up reimplementing our system using GRPC because I needed the functionality quicker and could not get it working through REST. In the end, it seemed that REST was not ideal for working with complex situations such as specifying route hints (array of array of objects) as query parameters.
@AzulPretoBranco to be honest, I never really tried it out myself. I just assumed that you'd need to specify the correct encoding in the URL to pass a list, very similar to how the maps work.
But you are right, the current version of grpc-gateway doesn't support adding lists with non-primitive members to the request URI.
I'm going to add a secondary REST mapping for POST, where encoding works differently (JSON) and should be way easier to use.
@guggero thanks so much, I will try this again when the new code is released.