lnd icon indicating copy to clipboard operation
lnd copied to clipboard

rpcperm: rpc state/status interceptor should return gRPC error codes

Open Roasbeef opened this issue 4 years ago • 2 comments

As is, the current status interceptors that return an error if the wallet unlocker endpoints are hit while the wallet is already unlocked: https://github.com/lightningnetwork/lnd/blob/master/rpcperms/interceptor.go#L508

However, since they return "normal" Go errors, callers are forced to do string matching against the returned errors.

Instead, we should be returning a gRPC status error code. When picking an error code, we should take care to ensure we don't collide with one of the pre-built error codes the gRPC library uses.

Roasbeef avatar Jul 29 '21 03:07 Roasbeef

Hi @Roasbeef! I'd like to work on this issue, I wanted to make sure that we are completely "replacing" the normal go-errors with no exceptions? i.e: Will always return gRPC status error codes?

DarthBenro008 avatar Aug 03 '21 07:08 DarthBenro008

I wanted to make sure that we are completely "replacing" the normal go-errors with no exceptions? i.e: Will always return gRPC status error codes?

No harm in replacing wrapping all the errors with grpc codes IMO. In the case where we have an unexpected state, we probably don't need to add an error code because no code will map to Unknown anyway (which is what I'd set for that case).

One consideration here is that we don't want to break string matching, so we should keep the text of the errors as they currently are.

carlaKC avatar Aug 03 '21 07:08 carlaKC