pub trait Rpc: Sync + Clone {
Show 20 methods
// Required method
fn post(
&self,
route: &str,
body: Vec<u8>,
) -> impl Send + Future<Output = Result<Vec<u8>, RpcError>>;
// Provided methods
fn rpc_call<Params: Send + Serialize + Debug, Response: DeserializeOwned + Debug>(
&self,
route: &str,
params: Option<Params>,
) -> impl Send + Future<Output = Result<Response, RpcError>> { ... }
fn json_rpc_call<Response: DeserializeOwned + Debug>(
&self,
method: &str,
params: Option<Value>,
) -> impl Send + Future<Output = Result<Response, RpcError>> { ... }
fn bin_call(
&self,
route: &str,
params: Vec<u8>,
) -> impl Send + Future<Output = Result<Vec<u8>, RpcError>> { ... }
fn get_hardfork_version(
&self,
) -> impl Send + Future<Output = Result<u8, RpcError>> { ... }
fn get_height(&self) -> impl Send + Future<Output = Result<usize, RpcError>> { ... }
fn get_transactions(
&self,
hashes: &[[u8; 32]],
) -> impl Send + Future<Output = Result<Vec<Transaction>, RpcError>> { ... }
fn get_pruned_transactions(
&self,
hashes: &[[u8; 32]],
) -> impl Send + Future<Output = Result<Vec<Transaction<Pruned>>, RpcError>> { ... }
fn get_transaction(
&self,
tx: [u8; 32],
) -> impl Send + Future<Output = Result<Transaction, RpcError>> { ... }
fn get_pruned_transaction(
&self,
tx: [u8; 32],
) -> impl Send + Future<Output = Result<Transaction<Pruned>, RpcError>> { ... }
fn get_block_hash(
&self,
number: usize,
) -> impl Send + Future<Output = Result<[u8; 32], RpcError>> { ... }
fn get_block(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<Block, RpcError>> { ... }
fn get_block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<Block, RpcError>> { ... }
fn get_scannable_block(
&self,
block: Block,
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>> { ... }
fn get_scannable_block_by_hash(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>> { ... }
fn get_scannable_block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>> { ... }
fn get_fee_rate(
&self,
priority: FeePriority,
) -> impl Send + Future<Output = Result<FeeRate, RpcError>> { ... }
fn publish_transaction(
&self,
tx: &Transaction,
) -> impl Send + Future<Output = Result<(), RpcError>> { ... }
fn generate_blocks<const ADDR_BYTES: u128>(
&self,
address: &Address<ADDR_BYTES>,
block_count: usize,
) -> impl Send + Future<Output = Result<(Vec<[u8; 32]>, usize), RpcError>> { ... }
fn get_o_indexes(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<Vec<u64>, RpcError>> { ... }
}
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§
Provided Methods§
Sourcefn rpc_call<Params: Send + Serialize + Debug, Response: DeserializeOwned + Debug>(
&self,
route: &str,
params: Option<Params>,
) -> impl Send + Future<Output = Result<Response, RpcError>>
fn rpc_call<Params: Send + Serialize + Debug, Response: DeserializeOwned + Debug>( &self, route: &str, params: Option<Params>, ) -> impl Send + Future<Output = Result<Response, RpcError>>
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
.
Sourcefn json_rpc_call<Response: DeserializeOwned + Debug>(
&self,
method: &str,
params: Option<Value>,
) -> impl Send + Future<Output = Result<Response, RpcError>>
fn json_rpc_call<Response: DeserializeOwned + Debug>( &self, method: &str, params: Option<Value>, ) -> impl Send + Future<Output = Result<Response, RpcError>>
Perform a JSON-RPC call with the specified method with the provided parameters.
Sourcefn bin_call(
&self,
route: &str,
params: Vec<u8>,
) -> impl Send + Future<Output = Result<Vec<u8>, RpcError>>
fn bin_call( &self, route: &str, params: Vec<u8>, ) -> impl Send + Future<Output = Result<Vec<u8>, RpcError>>
Perform a binary call to the specified route with the provided parameters.
Sourcefn get_hardfork_version(
&self,
) -> impl Send + Future<Output = Result<u8, RpcError>>
fn get_hardfork_version( &self, ) -> impl Send + Future<Output = Result<u8, RpcError>>
Get the active blockchain protocol version.
This is specifically the major version within the most recent block header.
Sourcefn get_height(&self) -> impl Send + Future<Output = Result<usize, RpcError>>
fn get_height(&self) -> impl Send + Future<Output = Result<usize, RpcError>>
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.
Sourcefn get_transactions(
&self,
hashes: &[[u8; 32]],
) -> impl Send + Future<Output = Result<Vec<Transaction>, RpcError>>
fn get_transactions( &self, hashes: &[[u8; 32]], ) -> impl Send + Future<Output = Result<Vec<Transaction>, RpcError>>
Get the specified transactions.
The received transactions will be hashed in order to verify the correct transactions were returned.
Sourcefn get_pruned_transactions(
&self,
hashes: &[[u8; 32]],
) -> impl Send + Future<Output = Result<Vec<Transaction<Pruned>>, RpcError>>
fn get_pruned_transactions( &self, hashes: &[[u8; 32]], ) -> impl Send + Future<Output = Result<Vec<Transaction<Pruned>>, RpcError>>
Get the specified transactions in their pruned format.
Sourcefn get_transaction(
&self,
tx: [u8; 32],
) -> impl Send + Future<Output = Result<Transaction, RpcError>>
fn get_transaction( &self, tx: [u8; 32], ) -> impl Send + Future<Output = Result<Transaction, RpcError>>
Get the specified transaction.
The received transaction will be hashed in order to verify the correct transaction was returned.
Sourcefn get_pruned_transaction(
&self,
tx: [u8; 32],
) -> impl Send + Future<Output = Result<Transaction<Pruned>, RpcError>>
fn get_pruned_transaction( &self, tx: [u8; 32], ) -> impl Send + Future<Output = Result<Transaction<Pruned>, RpcError>>
Get the specified transaction in its pruned format.
Sourcefn get_block_hash(
&self,
number: usize,
) -> impl Send + Future<Output = Result<[u8; 32], RpcError>>
fn get_block_hash( &self, number: usize, ) -> impl Send + Future<Output = Result<[u8; 32], RpcError>>
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).
Sourcefn get_block(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<Block, RpcError>>
fn get_block( &self, hash: [u8; 32], ) -> impl Send + Future<Output = Result<Block, RpcError>>
Get a block from the node by its hash.
The received block will be hashed in order to verify the correct block was returned.
Sourcefn get_block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<Block, RpcError>>
fn get_block_by_number( &self, number: usize, ) -> impl Send + Future<Output = Result<Block, RpcError>>
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).
Sourcefn get_scannable_block(
&self,
block: Block,
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
fn get_scannable_block( &self, block: Block, ) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
Get a block’s scannable form.
Sourcefn get_scannable_block_by_hash(
&self,
hash: [u8; 32],
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
fn get_scannable_block_by_hash( &self, hash: [u8; 32], ) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
Get a block’s scannable form by its hash.
Sourcefn get_scannable_block_by_number(
&self,
number: usize,
) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
fn get_scannable_block_by_number( &self, number: usize, ) -> impl Send + Future<Output = Result<ScannableBlock, RpcError>>
Get a block’s scannable form by its number.
Sourcefn get_fee_rate(
&self,
priority: FeePriority,
) -> impl Send + Future<Output = Result<FeeRate, RpcError>>
fn get_fee_rate( &self, priority: FeePriority, ) -> impl Send + Future<Output = Result<FeeRate, RpcError>>
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.
Sourcefn publish_transaction(
&self,
tx: &Transaction,
) -> impl Send + Future<Output = Result<(), RpcError>>
fn publish_transaction( &self, tx: &Transaction, ) -> impl Send + Future<Output = Result<(), RpcError>>
Publish a transaction.
Sourcefn generate_blocks<const ADDR_BYTES: u128>(
&self,
address: &Address<ADDR_BYTES>,
block_count: usize,
) -> impl Send + Future<Output = Result<(Vec<[u8; 32]>, usize), RpcError>>
fn generate_blocks<const ADDR_BYTES: u128>( &self, address: &Address<ADDR_BYTES>, block_count: usize, ) -> impl Send + Future<Output = Result<(Vec<[u8; 32]>, usize), RpcError>>
Generate blocks, with the specified address receiving the block reward.
Returns the hashes of the generated blocks and the last block’s number.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.