Trait snarkos_rpc::RpcFunctions[][src]

pub trait RpcFunctions {
Show 15 methods fn get_block<'life0, 'async_trait>(
        &'life0 self,
        block_hash_string: String
    ) -> Pin<Box<dyn Future<Output = Result<BlockInfo, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_block_count<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<u32, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_best_block_hash<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_block_hash<'life0, 'async_trait>(
        &'life0 self,
        block_height: u32
    ) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_raw_transaction<'life0, 'async_trait>(
        &'life0 self,
        transaction_id: String
    ) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_transaction_info<'life0, 'async_trait>(
        &'life0 self,
        transaction_id: String
    ) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn decode_raw_transaction<'life0, 'async_trait>(
        &'life0 self,
        transaction_bytes: String
    ) -> Pin<Box<dyn Future<Output = Result<TransactionInfo, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn send_raw_transaction<'life0, 'async_trait>(
        &'life0 self,
        transaction_bytes: String
    ) -> Pin<Box<dyn Future<Output = Result<String, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn validate_raw_transaction<'life0, 'async_trait>(
        &'life0 self,
        transaction_bytes: String
    ) -> Pin<Box<dyn Future<Output = Result<bool, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_connection_count<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<usize, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_peer_info<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<PeerInfo, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_node_info<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<NodeInfo, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_node_stats<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<NodeStats, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_block_template<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<BlockTemplate, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
fn get_network_graph<'life0, 'async_trait>(
        &'life0 self
    ) -> Pin<Box<dyn Future<Output = Result<NetworkGraph, RpcError>> + Send + 'async_trait>>
    where
        'life0: 'async_trait,
        Self: 'async_trait
;
}
Expand description

Definition of public RPC endpoints.

Required methods

Returns information about a block from a block hash.

Arguments
ParameterTypeRequiredDescription
block_hashstringYesThe block hash of the requested block
Response
ParameterTypeDescription
confirmationsnumberThe number of confirmations for this block
difficulty_targetnumberThe difficulty of the block
hashstringThe block hash (same as provided)
heightnumberThe block height
merkle_rootnumberThe Merkle root of the transactions in the block
noncenumberThe nonce for solving the PoSW puzzle
pedersen_merkle_root_hashnumberThe Merkle root of the transactions in the block using a Pedersen hash
previous_block_hashstringThe block hash of the parent block
proofstringThe Proof of Succinct Work
sizenumberThe size of the block in bytes
timenumberThe block time
transactionsarrayThe list of transaction ids included in the block
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblock", "params": ["caf49293d36f0215cfb3296dbc871a0ef5e5dcfc61f91cd0c9ac2c730f84d853"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the number of blocks in the best valid chain.

Arguments

None

Response
ParameterTypeDescription
resultnumberThe number of blocks in the best valid chain
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblockcount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the block hash of the head of the best valid chain.

Arguments

None

Response
ParameterTypeDescription
resultstringThe block hash of the most recent valid block
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getbestblockhash", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the block hash of a block at the given block height in the best valid chain.

Arguments
ParameterTypeRequiredDescription
block_heightnumberYesThe block height of the requested block hash
Response
ParameterTypeDescription
resultstringThe block hash of the block at the given block height
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblockhash", "params": [100] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns hex encoded bytes of a transaction from its transaction id.

Arguments
ParameterTypeRequiredDescription
transaction_idstringYesThe transaction id of the requested transaction hex
Response
ParameterTypeDescription
resultstringThe hex-encoded transaction bytes
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getrawtransaction", "params": ["83fc73b8a104d7cdabe514ec4ddfeb7fd6284ff8e0a757d25d8479ed0ffe608b"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns information about a transaction from a transaction id.

Arguments
ParameterTypeRequiredDescription
transaction_idstringYesThe transaction id of the requested transaction info
Response
ParameterTypeDescription
txidstringThe transaction id
sizenumberThe size of the transaction in bytes
old_serial_numbersarrayThe list of old record serial numbers
new_commitmentsarrayThe list of new record commitments
memostringThe transaction memo
network_idnumberThe transaction network id
digeststringThe merkle tree digest
transaction_proofstringThe transaction zero knowledge proof
program_commitmentstringThe program verification key commitment
local_data_rootstringThe local data root
value_balancenumberThe transaction value balance
signaturesarrayThe list of transaction signatures
encrypted_recordsarrayThe list of new encrypted records
transaction_metadataobjectThe transaction metadata
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "gettransactioninfo", "params": ["83fc73b8a104d7cdabe514ec4ddfeb7fd6284ff8e0a757d25d8479ed0ffe608b"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns information about a transaction from serialized transaction bytes.

Arguments
ParameterTypeRequiredDescription
transaction_bytesstringYesThe raw transaction hex to decode
Response
ParameterTypeDescription
txidstringThe transaction id
sizenumberThe size of the transaction in bytes
old_serial_numbersarrayThe list of old record serial numbers
new_commitmentsarrayThe list of new record commitments
memostringThe transaction memo
network_idnumberThe transaction network id
digeststringThe merkle tree digest
transaction_proofstringThe transaction zero knowledge proof
program_commitmentstringThe program verification key commitment
local_data_rootstringThe local data root
value_balancenumberThe transaction value balance
signaturesarrayThe list of transaction signatures
encrypted_recordsarrayThe list of new encrypted records
transaction_metadataobjectThe transaction metadata
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "decoderawtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Send raw transaction bytes to this node to be added into the mempool. If valid, the transaction will be stored and propagated to all peers.

Arguments
ParameterTypeRequiredDescription
transaction_bytesstringYesThe raw transaction hex to broadcast
Response
ParameterTypeDescription
resultstringThe transaction id of the sent transaction
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "sendtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Validate and return if the transaction is valid.

Arguments
ParameterTypeRequiredDescription
transaction_bytesstringYesThe raw transaction hex to validate
Response
ParameterTypeDescription
resultbooleanCheck that the transaction is valid
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "validaterawtransaction", "params": ["transaction_hexstring"] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the number of connected peers this node has.

Arguments

None

Response
ParameterTypeDescription
resultnumberThe number of connected nodes
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getconnectioncount", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the node’s connected peers.

Arguments

None

Response
ParameterTypeDescription
peersarrayThe list of connected peer IPs
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getpeerinfo", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns information about the node.

Arguments

None

Response
ParameterTypeDescription
node_typeNodeTypeFlag indicating the node type
is_minerboolFlag indicating if the node is a miner
is_syncingboolFlag indicating if the node currently syncing
launchedtimestampThe timestamp of when the node was launched
listening_addrSocketAddrThe configured listening address of the node
versionstringThe version of the client binary
min_peersnumberThe minimum desired number of connected peers
max_peersnumberThe maximum allowed number of connected peers
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnodeinfo", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns statistics related to the node.

Arguments

None

Response
ParameterTypeDescription
blocks.heightu32The current block height of the node
blocks.minedu32The number of blocks the node has mined
blocks.inbound_processing_timef64The average processing time of an inbound block in seconds
blocks.commit_timef64The block verification and commit time in seconds
blocks.duplicatesu64The number of duplicate blocks received
blocks.duplicates_syncu64The number of duplicate sync blocks received
connections.all_acceptedu64The number of connection requests the node has received
connections.all_initiatedu64The number of connection requests the node has made
connections.all_rejectedu64The number of connection requests the node has rejected
connections.average_durationf64The average connection duration in seconds
connections.connected_peersu32The number of currently connected peers
connections.connecting_peersu32The number of currently connecting peers
connections.disconnected_peersu32The number of known disconnected peers
handshakes.failures_initu64The number of failed handshakes as the initiator
handshakes.failures_respu64The number of failed handshakes as the responder
handshakes.successes_initu64The number of successful handshakes as the initiator
handshakes.successes_respu64The number of successful handshakes as the responder
handshakes.timeouts_initu64The number of handshake timeouts as the initiator
handshakes.timeouts_respu64The number of handshake timeouts as the responder
inbound.all_successesu64The number of successfully processed inbound messages
inbound.all_failuresu64The number of inbound messages that couldn’t be processed
inbound.blocksu64The number of all received Block messages
inbound.getblocksu64The number of all received GetBlocks messages
inbound.getmemorypoolu64The number of all received GetMemoryPool messages
inbound.getpeersu64The number of all received GetPeers messages
inbound.getsyncu64The number of all received GetSync messages
inbound.memorypoolu64The number of all received MemoryPool messages
inbound.peersu64The number of all received Peers messages
inbound.pingsu64The number of all received Ping messages
inbound.pongsu64The number of all received Pong messages
inbound.syncsu64The number of all received Sync messages
inbound.syncblocksu64The number of all received SyncBlock messages
inbound.transactionsu64The number of all received Transaction messages
inbound.unknownu64The number of all received Unknown messages
internal_rtt.getpeerf64The average internal RTT (query to response) for GetPeer messages in seconds
internal_rtt.getsyncf64The average internal RTT for GetSync messages in seconds
internal_rtt.getblocksf64The average internal RTT for GetBlocks messages in seconds
internal_rtt.getmemorypoolf64The average internal RTT for GetMemoryPool messages in seconds
misc.rpc_requestsf64The number of RPC requests received by the node
outbound.all_successesu64The number of successfully sent messages
outbound.all_failuresu64The number of failures to send messages
queues.consensusu64The number of queued consensus requests
queues.inboundu64The number of messages queued in the common inbound channel
queues.outboundu64The number of messages queued in the individual outbound channels
queues.peer_eventsu64The number of queued peer events
queues.storageu64The number of queued storage requests
queues.sync_itemsu64The number of queued sync items
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnodestats", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the current mempool and consensus information known by this node.

Arguments

None

Response
ParameterTypeDescription
previous_block_hashstringThe hash of current highest block
block_heightnumberThe height of the next block
timenumberThe current timestamp
difficulty_targetnumberThe block difficulty target
transactionsarrayThe list of raw transactions to include in the block
coinbase_valuenumberThe amount spendable by the coinbase transaction
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getblocktemplate", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Returns the network graph crawled by this node (if it is a crawler).

Arguments

None

Response
ParameterTypeDescription
node_countusizeThe number of nodes known by the node
connection_countusizeThe number of connection known by the node
densityf64The density of the known network
algebraic_connectivityf64The algebraic connectivity, aka the fiedler eigenvalue of the known network
degree_centrality_deltaf64The difference between the largest and the smallest peer count in the network
potential_tipOptionThe crawler’s best guess at the canon block height and member addresses
potential_forksarrayThe crawler’s best guess at the forks in the network
edgesarrayThe list of connections known by the node
verticesarrayThe list of nodes known by the node
edges[i].sourceSocketAddrOne side of the crawled connection
edges[i].targetSocketAddrThe other side of the crawled connection
vertices[i].addrSocketAddrThe recorded address of the crawled node
vertices[i].is_beaconboolIndicates whether the node is a beacon
vertices[i].is_sync_providerboolIndicates whether the node is a sync provider
vertices[i].degree_centralityu16The node’s degree centrality, aka its connection count
vertices[i].eigenvector_centralityf64The node’s eigenvector centrality, indicates its relative importance in the network
vertices[i].fiedler_valuef64The node’s fiedler value, can be used to partition the network graph
Example
curl --data-binary '{"jsonrpc": "2.0", "id":"documentation", "method": "getnetworkgraph", "params": [] }' -H 'content-type: application/json' http://127.0.0.1:3030/

Implementors