2020-07-01 08:12:24 +00:00
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct RPCPayload {
|
|
|
|
pub jsonrpc: String,
|
|
|
|
pub id: String,
|
|
|
|
pub method: Option<String>,
|
|
|
|
pub params: Option<RPCParams>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for RPCPayload {
|
|
|
|
fn default() -> RPCPayload {
|
|
|
|
RPCPayload {
|
|
|
|
jsonrpc: "2.0".to_string(),
|
|
|
|
id: "0".to_string(),
|
|
|
|
method: None,
|
|
|
|
params: None,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct RPCParams {
|
|
|
|
pub hash: Option<String>,
|
|
|
|
pub txs_hashes: Option<Vec<String>>,
|
|
|
|
pub height: Option<String>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Default for RPCParams {
|
|
|
|
fn default() -> RPCParams {
|
|
|
|
RPCParams {
|
|
|
|
hash: None,
|
|
|
|
txs_hashes: None,
|
|
|
|
height: None
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetInfo {
|
2020-07-03 01:56:14 +00:00
|
|
|
pub jsonrpc: Option<String>,
|
|
|
|
pub id: Option<String>,
|
|
|
|
pub result: Option<GetInfoResult>
|
2020-07-01 08:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetInfoResult {
|
|
|
|
pub alt_blocks_count: u32,
|
|
|
|
pub block_size_limit: u32,
|
|
|
|
pub block_size_median: u32,
|
|
|
|
pub block_weight_limit: u32,
|
|
|
|
pub block_weight_median: u64,
|
|
|
|
pub bootstrap_daemon_address: String,
|
|
|
|
pub credits: u32,
|
|
|
|
pub cumulative_difficulty: u64,
|
|
|
|
pub cumulative_difficulty_top64: u32,
|
|
|
|
pub database_size: u64,
|
|
|
|
pub difficulty: u64,
|
|
|
|
pub difficulty_top64: u32,
|
|
|
|
pub free_space: u64,
|
|
|
|
pub grey_peerlist_size: u32,
|
|
|
|
pub height: u32,
|
|
|
|
pub height_without_bootstrap: u32,
|
|
|
|
pub incoming_connections_count: u32,
|
|
|
|
pub mainnet: bool,
|
|
|
|
pub nettype: String,
|
|
|
|
pub offline: bool,
|
|
|
|
pub outgoing_connections_count: u32,
|
|
|
|
pub rpc_connections_count: u32,
|
|
|
|
pub stagenet: bool,
|
|
|
|
pub start_time: u32,
|
|
|
|
pub status: String,
|
|
|
|
pub target: u32,
|
|
|
|
pub target_height: u32,
|
|
|
|
pub testnet: bool,
|
|
|
|
pub top_block_hash: String,
|
|
|
|
pub top_hash: String,
|
|
|
|
pub tx_count: u32,
|
|
|
|
pub tx_pool_size: u32,
|
|
|
|
pub untrusted: bool,
|
|
|
|
pub update_available: bool,
|
|
|
|
pub version: String,
|
|
|
|
pub was_bootstrap_ever_used: bool,
|
|
|
|
pub white_peerlist_size: u32,
|
|
|
|
pub wide_cumulative_difficulty: String,
|
|
|
|
pub wide_difficulty: String
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct BlockByHeaderHash {
|
|
|
|
pub id: String,
|
|
|
|
pub jsonrpc: String,
|
|
|
|
pub result: BlockByHeaderHashResult
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct BlockByHeaderHashResult {
|
|
|
|
pub status: String,
|
|
|
|
pub untrusted: bool,
|
|
|
|
pub block_header: BlockHeader
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct BlockHeader {
|
|
|
|
pub block_size: u32,
|
|
|
|
pub depth: u32,
|
|
|
|
pub difficulty: u64,
|
|
|
|
pub hash: String,
|
|
|
|
pub height: u32,
|
|
|
|
pub major_version: u8,
|
|
|
|
pub minor_version: u8,
|
|
|
|
pub miner_tx_hash: Option<String>,
|
|
|
|
pub nonce: u32,
|
|
|
|
pub num_txes: u32,
|
|
|
|
pub orphan_status: bool,
|
|
|
|
pub prev_hash: String,
|
|
|
|
pub reward: u64,
|
|
|
|
pub timestamp: i64
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetTransactions {
|
|
|
|
pub txs: Vec<GetTransactionsTxs>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetTransactionsTxs {
|
|
|
|
pub block_height: Option<u32>,
|
|
|
|
pub block_timestamp: Option<i64>,
|
|
|
|
pub double_spend_seen: bool,
|
|
|
|
pub in_pool: bool,
|
|
|
|
pub output_indices: Option<Vec<u32>>,
|
|
|
|
pub as_json: String,
|
|
|
|
pub as_json_full: Option<TransactionJSON>
|
|
|
|
}
|
|
|
|
|
|
|
|
impl GetTransactionsTxs {
|
|
|
|
pub fn process(&mut self) {
|
|
|
|
self.as_json_full = Some(serde_json::from_str(&self.as_json).unwrap())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetBlock {
|
2020-07-03 01:56:14 +00:00
|
|
|
pub id: i32,
|
2020-07-01 08:12:24 +00:00
|
|
|
pub jsonrpc: String,
|
|
|
|
pub result: GetBlockResult
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetBlockResult {
|
|
|
|
pub block_header: BlockHeader,
|
|
|
|
pub credits: u8,
|
|
|
|
pub miner_tx_hash: String,
|
|
|
|
pub tx_hashes: Option<Vec<String>>,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct GetTransactionPool {
|
|
|
|
pub credits: u32,
|
|
|
|
pub spent_key_images: Option<Vec<SpentKeyImages>>,
|
|
|
|
pub status: String,
|
|
|
|
pub top_hash: String,
|
2020-07-03 04:52:21 +00:00
|
|
|
pub transactions: Vec<Transactions>
|
2020-07-01 08:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct SpentKeyImages {
|
|
|
|
pub id_hash: String,
|
|
|
|
pub txs_hashes: Vec<String>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct Transactions {
|
|
|
|
pub blob_size: u32,
|
|
|
|
pub do_not_relay: bool,
|
|
|
|
pub double_spend_seen: bool,
|
|
|
|
pub fee: u64,
|
|
|
|
pub id_hash: String,
|
|
|
|
pub kept_by_block: bool,
|
|
|
|
pub last_failed_height: u32,
|
|
|
|
pub last_failed_id_hash: String,
|
|
|
|
pub last_relayed_time: i64,
|
|
|
|
pub max_used_block_height: u32,
|
|
|
|
pub max_used_block_id_hash: String,
|
|
|
|
pub receive_time: i64,
|
|
|
|
pub relayed: bool,
|
|
|
|
pub tx_blob: String,
|
|
|
|
pub tx_json: String,
|
|
|
|
pub tx_json_full: Option<TransactionJSON>,
|
|
|
|
pub weight: u32
|
|
|
|
}
|
|
|
|
|
|
|
|
impl Transactions {
|
|
|
|
pub fn process(&mut self) {
|
|
|
|
self.tx_json_full = Some(serde_json::from_str(&self.tx_json).unwrap())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct TransactionJSON {
|
|
|
|
pub version: u32,
|
|
|
|
pub unlock_time: u64,
|
|
|
|
pub vin: Vec<TransactionInputs>,
|
|
|
|
pub vout: Vec<TransactionOutputs>,
|
|
|
|
pub extra: Vec<u32>,
|
2020-07-03 01:56:14 +00:00
|
|
|
pub rct_signatures: Option<RingSignatures>
|
2020-07-01 08:12:24 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct TransactionInputs {
|
|
|
|
pub key: Option<PreviousTransactionKey>
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct PreviousTransactionKey {
|
|
|
|
pub amount: u64,
|
|
|
|
pub key_offsets: Vec<u32>,
|
|
|
|
pub k_image: String
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct TransactionOutputs {
|
|
|
|
pub amount: u64,
|
|
|
|
pub target: OutputStealthAddress
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct OutputStealthAddress {
|
|
|
|
pub key: String
|
|
|
|
}
|
|
|
|
|
2020-07-03 04:56:34 +00:00
|
|
|
#[allow(non_snake_case)]
|
2020-07-01 08:12:24 +00:00
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct RingSignatures {
|
|
|
|
pub r#type: u32,
|
|
|
|
pub txnFee: Option<u64>,
|
|
|
|
pub outPk: Option<Vec<String>>
|
|
|
|
}
|
2020-07-03 03:52:50 +00:00
|
|
|
|
|
|
|
#[derive(Serialize, Deserialize, Hash, Eq, PartialEq, Debug, Clone)]
|
|
|
|
pub struct QRData {
|
|
|
|
pub tx_amount: String,
|
|
|
|
pub tx_description: String,
|
|
|
|
pub recipient_name: String,
|
|
|
|
pub tx_payment_id: String
|
|
|
|
}
|