mirror of
https://git.wownero.com/wownero/wownero.git
synced 2024-08-15 01:03:23 +00:00
344 lines
7.2 KiB
C
344 lines
7.2 KiB
C
|
// Copyright (c) 2012-2013 The Cryptonote developers
|
||
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||
|
|
||
|
#pragma once
|
||
|
#include "cryptonote_protocol/cryptonote_protocol_defs.h"
|
||
|
#include "cryptonote_core/cryptonote_basic.h"
|
||
|
#include "crypto/hash.h"
|
||
|
|
||
|
namespace cryptonote
|
||
|
{
|
||
|
//-----------------------------------------------
|
||
|
#define CORE_RPC_STATUS_OK "OK"
|
||
|
|
||
|
struct COMMAND_RPC_GET_HEIGHT
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
uint64_t height;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(height)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
struct COMMAND_RPC_GET_KNOWN_BLOCK_IDS
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::list<std::string> main;
|
||
|
std::list<std::string> alt;
|
||
|
std::list<std::string> invalid;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(main)
|
||
|
KV_SERIALIZE(alt)
|
||
|
KV_SERIALIZE(invalid)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
struct COMMAND_RPC_GET_BLOCKS_FAST
|
||
|
{
|
||
|
|
||
|
struct request
|
||
|
{
|
||
|
std::list<crypto::hash> block_ids; //*first 10 blocks id goes sequential, next goes in pow(2,n) offset, like 2, 4, 8, 16, 32, 64 and so on, and the last one is always genesis block */
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(block_ids)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::list<block_complete_entry> blocks;
|
||
|
uint64_t start_height;
|
||
|
uint64_t current_height;
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(blocks)
|
||
|
KV_SERIALIZE(start_height)
|
||
|
KV_SERIALIZE(current_height)
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_GET_TRANSACTIONS
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
std::list<std::string> txs_hashes;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(txs_hashes)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::list<std::string> txs_as_hex; //transactions blobs as hex
|
||
|
std::list<std::string> missed_tx; //not found transactions
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(txs_as_hex)
|
||
|
KV_SERIALIZE(missed_tx)
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
crypto::hash txid;
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE_VAL_POD_AS_BLOB(txid)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::vector<uint64_t> o_indexes;
|
||
|
std::string status;
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(o_indexes)
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
std::list<uint64_t> amounts;
|
||
|
uint64_t outs_count;
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(amounts)
|
||
|
KV_SERIALIZE(outs_count)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
#pragma pack (push, 1)
|
||
|
struct out_entry
|
||
|
{
|
||
|
uint64_t global_amount_index;
|
||
|
crypto::public_key out_key;
|
||
|
};
|
||
|
#pragma pack(pop)
|
||
|
|
||
|
struct outs_for_amount
|
||
|
{
|
||
|
uint64_t amount;
|
||
|
std::list<out_entry> outs;
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(amount)
|
||
|
KV_SERIALIZE_CONTAINER_POD_AS_BLOB(outs)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::vector<outs_for_amount> outs;
|
||
|
std::string status;
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(outs)
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_SEND_RAW_TX
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
std::string tx_as_hex;
|
||
|
|
||
|
request() {}
|
||
|
explicit request(const transaction &);
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(tx_as_hex)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_START_MINING
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
std::string miner_address;
|
||
|
uint64_t threads_count;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(miner_address)
|
||
|
KV_SERIALIZE(threads_count)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_GET_INFO
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::string status;
|
||
|
uint64_t height;
|
||
|
uint64_t difficulty;
|
||
|
uint64_t tx_count;
|
||
|
uint64_t tx_pool_size;
|
||
|
uint64_t alt_blocks_count;
|
||
|
uint64_t outgoing_connections_count;
|
||
|
uint64_t incoming_connections_count;
|
||
|
uint64_t white_peerlist_size;
|
||
|
uint64_t grey_peerlist_size;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(status)
|
||
|
KV_SERIALIZE(height)
|
||
|
KV_SERIALIZE(difficulty)
|
||
|
KV_SERIALIZE(tx_count)
|
||
|
KV_SERIALIZE(tx_pool_size)
|
||
|
KV_SERIALIZE(alt_blocks_count)
|
||
|
KV_SERIALIZE(outgoing_connections_count)
|
||
|
KV_SERIALIZE(incoming_connections_count)
|
||
|
KV_SERIALIZE(white_peerlist_size)
|
||
|
KV_SERIALIZE(grey_peerlist_size)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
//-----------------------------------------------
|
||
|
struct COMMAND_RPC_STOP_MINING
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
//
|
||
|
struct COMMAND_RPC_GETBLOCKCOUNT
|
||
|
{
|
||
|
typedef std::list<std::string> request;
|
||
|
|
||
|
typedef uint64_t response;
|
||
|
};
|
||
|
|
||
|
struct COMMAND_RPC_GETBLOCKHASH
|
||
|
{
|
||
|
typedef std::vector<uint64_t> request;
|
||
|
|
||
|
typedef std::string response;
|
||
|
};
|
||
|
|
||
|
|
||
|
struct COMMAND_RPC_GETBLOCKTEMPLATE
|
||
|
{
|
||
|
struct request
|
||
|
{
|
||
|
uint64_t reserve_size; //max 255 bytes
|
||
|
std::string wallet_address;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(reserve_size)
|
||
|
KV_SERIALIZE(wallet_address)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
uint64_t difficulty;
|
||
|
uint64_t height;
|
||
|
uint64_t reserved_offset;
|
||
|
blobdata blocktemplate_blob;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(difficulty)
|
||
|
KV_SERIALIZE(height)
|
||
|
KV_SERIALIZE(reserved_offset)
|
||
|
KV_SERIALIZE(blocktemplate_blob)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
struct COMMAND_RPC_SUBMITBLOCK
|
||
|
{
|
||
|
typedef std::vector<std::string> request;
|
||
|
|
||
|
struct response
|
||
|
{
|
||
|
std::string status;
|
||
|
|
||
|
BEGIN_KV_SERIALIZE_MAP()
|
||
|
KV_SERIALIZE(status)
|
||
|
END_KV_SERIALIZE_MAP()
|
||
|
};
|
||
|
};
|
||
|
|
||
|
|
||
|
|
||
|
}
|
||
|
|