bitcoin/src/rpc
MarcoFalke 357488f660
Merge #16240: JSONRPCRequest-aware RPCHelpMan
b6fb617aaa rpc: switch to using RPCHelpMan.Check() (Karl-Johan Alm)
c7a9fc234f Make the RPCHelpMan aware of JSONRPCRequest and add Check() helper (Karl-Johan Alm)
5c5e32bbe3 rpc: migrate JSONRPCRequest functionality into request.cpp (Karl-Johan Alm)
0ab8ba1ac6 rpc: fix RPC help requirements for getblocktemplate (Karl-Johan Alm)

Pull request description:

  Every single RPC call has a helper-section at the start, which throws a help string if the user asks for help or if the user provided too few/many arguments.

  ```C++
  const RPCHelpMan help{...};
  if (request.fHelp || !help.IsValidNumArgs(request.params.size())) {
      throw std::runtime_error(help.ToString());
  }
  ```

  or (older version)

  ```C++
  if (request.fHelp || request.params.size() < min || request.params.size() > max)
      throw std::runtime_error(
          RPCHelpMan{...}.ToString()
      );
  ```

  It seems like an obvious improvement, and less copy-pasting, to make `RPCHelpMan` aware of `JSONRPCRequest`, and to let it handle the checks instead. Both of the above become

  ```C++
  RPCHelpMan{...}.Check(request);
  ```

  which means we save roughly 3 lines per RPC command, and the `RPCHelpMan` instance is never referenced afterwards, so the approach is a tiny fraction cleaner.

  This is a complete update, sans a few special case locations that had special rules. 623 lines turn into 284 (which includes the addition to `RPCHelpMan`).

ACKs for top commit:
  laanwj:
    code rview and lightly tested ACK b6fb617aaa
  MarcoFalke:
    ACK b6fb617aaa, looked at the diff, verified move-only where applicable

Tree-SHA512: eb73f47f812512905b852e313281d1c8df803db40a6188aa39d5a7586631664db6764491152a8a96769946c796dc56d38c6e3a66ddd06ba3fb9d20050e6274e1
2019-07-09 19:31:52 -04:00
..
blockchain.cpp Merge #16240: JSONRPCRequest-aware RPCHelpMan 2019-07-09 19:31:52 -04:00
blockchain.h rpc: Add lock annotations to block{,header}ToJSON 2019-05-02 14:33:26 -04:00
client.cpp [RPC] add new utxoupdatepsbt arguments to the CRPCCommand and CPRCConvertParam tables 2019-07-04 08:02:23 -04:00
client.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
mining.cpp Merge #16240: JSONRPCRequest-aware RPCHelpMan 2019-07-09 19:31:52 -04:00
misc.cpp rpc: switch to using RPCHelpMan.Check() 2019-07-08 09:53:52 +09:00
net.cpp rpc: switch to using RPCHelpMan.Check() 2019-07-08 09:53:52 +09:00
protocol.h rpc: migrate JSONRPCRequest functionality into request.cpp 2019-07-05 11:22:02 +09:00
rawtransaction.cpp Merge #16240: JSONRPCRequest-aware RPCHelpMan 2019-07-09 19:31:52 -04:00
rawtransaction_util.cpp rpc: migrate JSONRPCRequest functionality into request.cpp 2019-07-05 11:22:02 +09:00
rawtransaction_util.h rpc: Remove dependency on interfaces::Chain in SignTransaction 2019-04-17 08:17:17 -04:00
register.h Update copyright headers to 2018 2018-07-27 07:15:02 -04:00
request.cpp rpc: migrate JSONRPCRequest functionality into request.cpp 2019-07-05 11:22:02 +09:00
request.h rpc: migrate JSONRPCRequest functionality into request.cpp 2019-07-05 11:22:02 +09:00
server.cpp Merge #16240: JSONRPCRequest-aware RPCHelpMan 2019-07-09 19:31:52 -04:00
server.h rpc: migrate JSONRPCRequest functionality into request.cpp 2019-07-05 11:22:02 +09:00
util.cpp Merge #15427: Add support for descriptors to utxoupdatepsbt 2019-07-02 16:53:22 +02:00
util.h Merge #16240: JSONRPCRequest-aware RPCHelpMan 2019-07-09 19:31:52 -04:00