The types

Cuprate has a crate that defines all the types related to RPC: cuprate-rpc-types.

The main purpose of this crate is to port the types used in monerod's RPC and to re-implement (de)serialization for those types, whether that be JSON, epee, or a custom mix.

The bulk majority of these types are request & response types, i.e. the inputs Cuprate's RPC is expecting from users, and the output it will respond with.

Example

To showcase an example of the kinds of types defined in this crate, here is a request type:

#![allow(unused)]
fn main() {
#[serde(transparent)]
#[repr(transparent)]
struct OnGetBlockHashRequest {
	block_height: [u64; 1],
}
}

This is the input (params) expected in the on_get_block_hash method.

As seen above, the type itself encodes some properties, such as being (de)serialized transparently, and the input being an array with 1 length, rather than a single u64. This is to match the behavior of monerod.

An example JSON form of this type would be:

{
  "jsonrpc": "2.0",
  "id": "0",
  "method": "on_get_block_hash",
  "params": [912345] // <- This can (de)serialize as a `OnGetBlockHashRequest`
}
Last change: 2024-10-02, commit: a003e05