Skip to content

Commit

Permalink
Assert that RPCArg names are equal to CRPCCommand ones (blockchain)
Browse files Browse the repository at this point in the history
Summary:
> This is split out from #18531 to just touch some RPC methods. Description from the main pr:
> Motivation
>
> RPCArg names in the rpc help are currently only used for documentation. However, in the future they could be used to teach the server the named arguments. Named arguments are currently registered by the CRPCCommands and duplicate the RPCArg names from the documentation. This redundancy is fragile, and has lead to errors in the past (despite having linters to catch those kind of errors). See section "bugs found" for a list of bugs that have been found as a result of the changes here.
>
> Changes
> The changes here add an assert in the CRPCCommand constructor that the RPCArg names are identical to the ones in the CRPCCommand.

This is a backport of [[bitcoin/bitcoin#19849 | core#19849]] [1/2]
bitcoin/bitcoin@fa80c81

Test Plan: `ninja all check-all`

Reviewers: #bitcoin_abc, Fabien

Reviewed By: #bitcoin_abc, Fabien

Differential Revision: https://reviews.bitcoinabc.org/D10298
  • Loading branch information
PiRK committed Oct 12, 2021
1 parent e13ecc8 commit bf542dc
Show file tree
Hide file tree
Showing 3 changed files with 1,322 additions and 1,251 deletions.
3 changes: 2 additions & 1 deletion src/rest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,8 @@ static bool rest_chaininfo(Config &config, const util::Ref &context,
case RetFormat::JSON: {
JSONRPCRequest jsonRequest(context);
jsonRequest.params = UniValue(UniValue::VARR);
UniValue chainInfoObject = getblockchaininfo(config, jsonRequest);
UniValue chainInfoObject =
getblockchaininfo().HandleRequest(config, jsonRequest);
std::string strJSON = chainInfoObject.write() + "\n";
req->WriteHeader("Content-Type", "application/json");
req->WriteReply(HTTP_OK, strJSON);
Expand Down
Loading

0 comments on commit bf542dc

Please sign in to comment.