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 CRPCCommand
s 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
.
Future work
Here or follow up, makes sense to also assert type of returned UniValue?
Sure, but let’s not get ahead of ourselves. I am going to submit any further works as follow-ups, including:
- Removing the CRPCCommand arguments, now that they are asserted to be equal and thus redundant
- Removing all python regex linters on the args, now that RPCMan can be used to generate any output, including the cli.cpp table
- Auto-formatting and sanity checking the RPCExamples with RPCMan
- Checking passed-in json in self-check. Removing redundant checks
- Checking returned json against documentation to avoid regressions or false documentation
- Compile the RPC documentation at compile-time to ensure it doesn’t change at runtime and is completely static