Skip to content

Commit

Permalink
rpcserver: Fix Error message returned by processRequest
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Gustavo Chain committed Mar 9, 2021
1 parent d087855 commit d376b91
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions rpcserver.go
Original file line number Diff line number Diff line change
Expand Up @@ -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",
}
}
}
}
Expand Down

0 comments on commit d376b91

Please sign in to comment.