Open kornpow opened 2 years ago
Related:
Perhaps a more generic/general approach would be useful so we don't end up with a different error code system for the different RPCs?
I think a general approach that can be applied project-wide would help a lot of people.
What do you think about PATH 2
in my issue? I think it would be helpful to allow BuildRoute
to focus more on just the tedium of building a route if it exists, rather than throwing errors which would be bubbled up anyways in SendToRoute
I think it would make sense to allow enabling a "sandbox" mode that just builds the route without checking some of the liquidity or availability constraints. I would put it behind a flag in the RPC just to preserve backward compatibility with apps that rely on the checks and to avoid users getting potentially unusable routes without knowing why.
Another approach to building routes if you don't care about the external data is to just derive the route yourself rather than doing it via API
Background
I would like to propose adding more structured error codes to the BuildRoute rpc, similar to what is available in SendToRouteV2. When building rebalancing software, you are often building routes, probing, and then deciding what route to actually send to. SendToRouteV2 provides nice error messaging, which allows me to be able to determine if there is no liquidity in a route, or if the probe has succeded. No Liquidity:
TEMPORARY_CHANNEL_FAILURE
Probe Succeeded:INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
Example SendToRouteV2 probing command.
Yields
INCORRECT_OR_UNKNOWN_PAYMENT_DETAILS
error.Example BuildRoute rpc with lack of structured errors
Piece of code which generates this error code: https://github.com/lightningnetwork/lnd/blob/master/routing/router.go#L2691
Potential Different Error Types:
I've listed the errors in order of things to check first to things to check last:
ROUTE_DOESNT_EXIST
- the route "physically doesnt exist"ROUTE_CHAN_DISABLED
- the route "exists", but one of the hops is disabledVIOLATED_CHANNEL_SIZE_CONSTRAINT
- you cant send larger than your channel sizeVIOLATED_MIN_HTLC_CONSTRAINT
- for example, sending 1 msat when defaultMIN_HTLC
is 1000msatVIOLATED_MAX_HTLC_CONSTRAINT
- people might actually set this to communicate liquidityConclusion
PATH 1:
Having these error codes will allow for building better programs for rebalancing liquidity. Currently when the
status = StatusCode.UNKNOWN
error is thrown, I am rather clueless until I do some digging why the route really failed to build.PATH 2:
I also think it could be valid for
BuildRoute
to be far more lax about these above constaints. What is the harm ofBuildRoute
building an impossible route (disabled channel, sending too much, etc), as long as the hops exist on the graph. Once you send to it, it would error out anyways... This actually could make a lot of sense, since many of the failure cases I outline above, are standard spec errors anyways. In this case, the structured error codes forBuildRoute
could be simplyROUTE_DOESNT_EXIST
.Your environment
lnd
LND 0.15.0-beta