added curl examples for RPCs

This commit is contained in:
Svyatoslav Nikolsky 2016-12-13 14:26:16 +03:00
parent 3b31ef9216
commit 9ff3879e20
3 changed files with 11 additions and 0 deletions

View File

@ -11,21 +11,27 @@ build_rpc_trait! {
/// Parity-bitcoin blockchain data interface.
pub trait BlockChain {
/// Get hash of best block.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getbestblockhash", "params": [], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getbestblockhash")]
fn best_block_hash(&self) -> Result<H256, Error>;
/// Get hash of block at given height.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getblockhash", "params": [0], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getblockhash")]
fn block_hash(&self, u32) -> Result<H256, Error>;
/// Get proof-of-work difficulty as a multiple of the minimum difficulty
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getdifficulty", "params": [], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getdifficulty")]
fn difficulty(&self) -> Result<f64, Error>;
/// Get information on given block.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getblock", "params": ["000000000019d6689c085ae165831e934ff763ae46a2a6c172b3f1b60a8ce26f"], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getblock")]
fn block(&self, H256, Trailing<bool>) -> Result<GetBlockResponse, Error>;
/// Get details about an unspent transaction output.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "gettxout", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b", 0], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "gettxout")]
fn transaction_out(&self, H256, u32, Trailing<bool>) -> Result<GetTxOutResponse, Error>;
/// Get statistics about the unspent transaction output set.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "gettxoutsetinfo", "params": [], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "gettxoutsetinfo")]
fn transaction_out_set_info(&self) -> Result<GetTxOutSetInfoResponse, Error>;
}

View File

@ -6,6 +6,7 @@ build_rpc_trait! {
/// Partiy-bitcoin miner data interface.
pub trait Miner {
/// Get block template for mining.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getblocktemplate", "params": [{"capabilities": ["coinbasetxn", "workid", "coinbase/append"]}], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getblocktemplate")]
fn get_block_template(&self, BlockTemplateRequest) -> Result<BlockTemplate, Error>;
}

View File

@ -12,15 +12,19 @@ build_rpc_trait! {
/// Partiy-bitcoin raw data interface.
pub trait Raw {
/// Adds transaction to the memory pool && relays it to the peers.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "sendrawtransaction", "params": ["01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "sendrawtransaction")]
fn send_raw_transaction(&self, RawTransaction) -> Result<H256, Error>;
/// Create a transaction spending the given inputs and creating new outputs.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "createrawtransaction", "params": [[{"txid":"4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b","vout":0}],{"1A1zP1eP5QGefi2DMPTfTL5SLmv7DivfNa":0.01}], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "createrawtransaction")]
fn create_raw_transaction(&self, Vec<TransactionInput>, Vec<TransactionOutput>, Trailing<u32>) -> Result<RawTransaction, Error>;
/// Return an object representing the serialized, hex-encoded transaction.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "decoderawtransaction", "params": ["01000000010000000000000000000000000000000000000000000000000000000000000000ffffffff4d04ffff001d0104455468652054696d65732030332f4a616e2f32303039204368616e63656c6c6f72206f6e206272696e6b206f66207365636f6e64206261696c6f757420666f722062616e6b73ffffffff0100f2052a01000000434104678afdb0fe5548271967f1a67130b7105cd6a828e03909a67962e0ea1f61deb649f6bc3f4cef38c4f35504e51ec112de5c384df7ba0b8d578a4c702b6bf11d5fac00000000"], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "decoderawtransaction")]
fn decode_raw_transaction(&self, RawTransaction) -> Result<Transaction, Error>;
/// Return the raw transaction data.
/// @curl-example: curl --data-binary '{"jsonrpc": "2.0", "method": "getrawtransaction", "params": ["4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b"], "id":1 }' -H 'content-type: application/json;' http://127.0.0.1:8332/
#[rpc(name = "getrawtransaction")]
fn get_raw_transaction(&self, H256, Trailing<bool>) -> Result<GetRawTransactionResponse, Error>;
}