RPC

monerod's daemon RPC has three kinds of RPC calls:

  1. JSON-RPC 2.0 methods, called at the /json_rpc endpoint
  2. JSON (but not JSON-RPC 2.0) methods called at their own endpoints, e.g. /get_height
  3. Binary (epee) RPC methods called at their own endpoints ending in .bin, e.g. /get_blocks.bin

Cuprate's RPC aims to mirror monerod's as much as it practically can.

This includes, but is not limited to:

  • Using the same endpoints
  • Receiving the same request data
  • Sending the same response data
  • Responding with the same HTTP status codes
  • Following internal behavior (e.g. /pop_blocks)

Not all monerod behavior can always be followed, however.

Some are not followed on purpose, some cannot be followed due to technical limitations, and some cannot be due to the behavior being monerod specific such as the /set_log_categories endpoint which uses monerod's logging categories.

Both subtle and large differences between Cuprate's RPC and monerod's RPC are documented in the Differences with monerod section.

Main RPC components

The main components that make up Cuprate's RPC are noted below, alongside the equivalent monerod code and other notes.

Cuprate cratemonerod (rough) equivalentPurposeNotes
cuprate-json-rpcjsonrpc_structs.h, http_server_handlers_map2.hJSON-RPC 2.0 implementationmonerod's JSON-RPC 2.0 handling is spread across a few files. The first defines some data structures, the second contains macros that (essentially) implement JSON-RPC 2.0.
cuprate-rpc-typescore_rpc_server_commands_defs.hRPC request/response type definitions and (de)serialization
cuprate-rpc-interfacecore_rpc_server.hRPC interface, routing, endpoints
cuprate-rpc-handlercore_rpc_server.cppRPC request/response handlingThese are the "inner handler" functions that turn requests into responses
Last change: 2024-11-18, commit: e8598a0