rpcserver: Fix Error message returned by processRequest

When processRequest can't find a rpc command, standardCmdResult returns
a `btcjson.ErrRPCMethodNotFound` but it gets ignored and a
`btcjson.ErrRPCInvalidRequest` is returned instead.

This makes processRequest return the right error message.
This commit is contained in:
Gustavo Chain 2021-03-09 10:37:31 +01:00 committed by John C. Vernaleo
parent d08785547a
commit 556620fea6

View file

@ -4066,9 +4066,13 @@ func (s *rpcServer) processRequest(request *btcjson.Request, isAdmin bool, close
result, err = s.standardCmdResult(parsedCmd,
closeChan)
if err != nil {
jsonErr = &btcjson.RPCError{
Code: btcjson.ErrRPCInvalidRequest.Code,
Message: "Invalid request: malformed",
if rpcErr, ok := err.(*btcjson.RPCError); ok {
jsonErr = rpcErr
} else {
jsonErr = &btcjson.RPCError{
Code: btcjson.ErrRPCInvalidRequest.Code,
Message: "Invalid request: malformed",
}
}
}
}