Trait monero_rpc::Rpc

source ·
pub trait Rpc:
    Sync
    + Clone
    + Debug {
Show 17 methods // Required method fn post<'life0, 'life1, 'async_trait>( &'life0 self, route: &'life1 str, body: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait; // Provided methods fn rpc_call<'life0, 'life1, 'async_trait, Params, Response>( &'life0 self, route: &'life1 str, params: Option<Params>, ) -> Pin<Box<dyn Future<Output = Result<Response, RpcError>> + Send + 'async_trait>> where Params: 'async_trait + Send + Serialize + Debug, Response: 'async_trait + DeserializeOwned + Debug, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn json_rpc_call<'life0, 'life1, 'async_trait, Response>( &'life0 self, method: &'life1 str, params: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<Response, RpcError>> + Send + 'async_trait>> where Response: 'async_trait + DeserializeOwned + Debug, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn bin_call<'life0, 'life1, 'async_trait>( &'life0 self, route: &'life1 str, params: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_hardfork_version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u8, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_height<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_transactions<'life0, 'life1, 'async_trait>( &'life0 self, hashes: &'life1 [[u8; 32]], ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_pruned_transactions<'life0, 'life1, 'async_trait>( &'life0 self, hashes: &'life1 [[u8; 32]], ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction<Pruned>>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_transaction<'life0, 'async_trait>( &'life0 self, tx: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Transaction, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_pruned_transaction<'life0, 'async_trait>( &'life0 self, tx: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Transaction<Pruned>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_block_hash<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<[u8; 32], RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_block<'life0, 'async_trait>( &'life0 self, hash: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Block, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_block_by_number<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<Block, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn get_fee_rate<'life0, 'async_trait>( &'life0 self, priority: FeePriority, ) -> Pin<Box<dyn Future<Output = Result<FeeRate, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... } fn publish_transaction<'life0, 'life1, 'async_trait>( &'life0 self, tx: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn generate_blocks<'life0, 'life1, 'async_trait, const ADDR_BYTES: u128>( &'life0 self, address: &'life1 Address<ADDR_BYTES>, block_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<[u8; 32]>, usize), RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait { ... } fn get_o_indexes<'life0, 'async_trait>( &'life0 self, hash: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, RpcError>> + Send + 'async_trait>> where Self: 'async_trait, 'life0: 'async_trait { ... }
}
Expand description

An RPC connection to a Monero daemon.

This is abstract such that users can use an HTTP library (which being their choice), a Tor/i2p-based transport, or even a memory buffer an external service somehow routes.

While no implementors are directly provided, monero-simple-request-rpc is recommended.

Required Methods§

source

fn post<'life0, 'life1, 'async_trait>( &'life0 self, route: &'life1 str, body: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a POST request to the specified route with the specified body.

The implementor is left to handle anything such as authentication.

Provided Methods§

source

fn rpc_call<'life0, 'life1, 'async_trait, Params, Response>( &'life0 self, route: &'life1 str, params: Option<Params>, ) -> Pin<Box<dyn Future<Output = Result<Response, RpcError>> + Send + 'async_trait>>
where Params: 'async_trait + Send + Serialize + Debug, Response: 'async_trait + DeserializeOwned + Debug, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a RPC call to the specified route with the provided parameters.

This is NOT a JSON-RPC call. They use a route of “json_rpc” and are available via json_rpc_call.

source

fn json_rpc_call<'life0, 'life1, 'async_trait, Response>( &'life0 self, method: &'life1 str, params: Option<Value>, ) -> Pin<Box<dyn Future<Output = Result<Response, RpcError>> + Send + 'async_trait>>
where Response: 'async_trait + DeserializeOwned + Debug, Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a JSON-RPC call with the specified method with the provided parameters.

source

fn bin_call<'life0, 'life1, 'async_trait>( &'life0 self, route: &'life1 str, params: Vec<u8>, ) -> Pin<Box<dyn Future<Output = Result<Vec<u8>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Perform a binary call to the specified route with the provided parameters.

source

fn get_hardfork_version<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<u8, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the active blockchain protocol version.

This is specifically the major version within the most recent block header.

source

fn get_height<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = Result<usize, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the height of the Monero blockchain.

The height is defined as the amount of blocks on the blockchain. For a blockchain with only its genesis block, the height will be 1.

source

fn get_transactions<'life0, 'life1, 'async_trait>( &'life0 self, hashes: &'life1 [[u8; 32]], ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the specified transactions.

The received transactions will be hashed in order to verify the correct transactions were returned.

source

fn get_pruned_transactions<'life0, 'life1, 'async_trait>( &'life0 self, hashes: &'life1 [[u8; 32]], ) -> Pin<Box<dyn Future<Output = Result<Vec<Transaction<Pruned>>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Get the specified transactions in their pruned format.

source

fn get_transaction<'life0, 'async_trait>( &'life0 self, tx: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Transaction, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the specified transaction.

The received transaction will be hashed in order to verify the correct transaction was returned.

source

fn get_pruned_transaction<'life0, 'async_trait>( &'life0 self, tx: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Transaction<Pruned>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the specified transaction in its pruned format.

source

fn get_block_hash<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<[u8; 32], RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the hash of a block from the node.

number is the block’s zero-indexed position on the blockchain (0 for the genesis block, height - 1 for the latest block).

source

fn get_block<'life0, 'async_trait>( &'life0 self, hash: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Block, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a block from the node by its hash.

The received block will be hashed in order to verify the correct block was returned.

source

fn get_block_by_number<'life0, 'async_trait>( &'life0 self, number: usize, ) -> Pin<Box<dyn Future<Output = Result<Block, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get a block from the node by its number.

number is the block’s zero-indexed position on the blockchain (0 for the genesis block, height - 1 for the latest block).

source

fn get_fee_rate<'life0, 'async_trait>( &'life0 self, priority: FeePriority, ) -> Pin<Box<dyn Future<Output = Result<FeeRate, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the currently estimated fee rate from the node.

This may be manipulated to unsafe levels and MUST be sanity checked.

This MUST NOT be expected to be deterministic in any way.

source

fn publish_transaction<'life0, 'life1, 'async_trait>( &'life0 self, tx: &'life1 Transaction, ) -> Pin<Box<dyn Future<Output = Result<(), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Publish a transaction.

source

fn generate_blocks<'life0, 'life1, 'async_trait, const ADDR_BYTES: u128>( &'life0 self, address: &'life1 Address<ADDR_BYTES>, block_count: usize, ) -> Pin<Box<dyn Future<Output = Result<(Vec<[u8; 32]>, usize), RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Generate blocks, with the specified address receiving the block reward.

Returns the hashes of the generated blocks and the last block’s number.

source

fn get_o_indexes<'life0, 'async_trait>( &'life0 self, hash: [u8; 32], ) -> Pin<Box<dyn Future<Output = Result<Vec<u64>, RpcError>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get the output indexes of the specified transaction.

Object Safety§

This trait is not object safe.

Implementors§