Skip to content

Commit

Permalink
[RPC] Return method name with 'Method not found' errors
Browse files Browse the repository at this point in the history
  • Loading branch information
random-zebra committed Apr 8, 2021
1 parent cb4e939 commit 7f4b2a4
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 5 deletions.
5 changes: 2 additions & 3 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -233,8 +233,7 @@ UniValue setgenerate(const JSONRPCRequest& request)
"\nTurn off generation\n" + HelpExampleCli("setgenerate", "false") +
"\nUsing json rpc\n" + HelpExampleRpc("setgenerate", "true, 1"));

if (pwalletMain == NULL)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found (disabled)");
EnsureWallet();

if (Params().IsRegTestNet())
throw JSONRPCError(RPC_INVALID_REQUEST, "Use the generate method instead of setgenerate on regtest");
Expand Down Expand Up @@ -832,4 +831,4 @@ void RegisterMiningRPCCommands(CRPCTable &tableRPC)
{
for (unsigned int vcidx = 0; vcidx < ARRAYLEN(commands); vcidx++)
tableRPC.appendCommand(commands[vcidx].name, &commands[vcidx]);
}
}
2 changes: 1 addition & 1 deletion src/rpc/server.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -430,7 +430,7 @@ UniValue CRPCTable::execute(const JSONRPCRequest &request) const
// Find method
const CRPCCommand* pcmd = tableRPC[request.strMethod];
if (!pcmd)
throw JSONRPCError(RPC_METHOD_NOT_FOUND, "Method not found");
throw JSONRPCError(RPC_METHOD_NOT_FOUND, strprintf("Method not found: %s", request.strMethod));

g_rpcSignals.PreCommand(*pcmd);

Expand Down
2 changes: 1 addition & 1 deletion test/functional/wallet_disable.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def set_test_params(self):

def run_test (self):
# Make sure wallet is really disabled
assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo)
assert_raises_rpc_error(-32601, 'Method not found: getwalletinfo', self.nodes[0].getwalletinfo)
x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
assert(x['isvalid'] == False)
x = self.nodes[0].validateaddress('xwMWGTnBNUmGxMm8vfAdbL45bWXyVTYctd')
Expand Down

0 comments on commit 7f4b2a4

Please sign in to comment.