danicoin/src/Wallet/WalletRpcServer.h

71 lines
2.8 KiB
C
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
2014-04-02 16:00:17 +00:00
2014-04-29 16:26:45 +00:00
#pragma once
2014-04-02 16:00:17 +00:00
#include <future>
2014-04-02 16:00:17 +00:00
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
2015-07-30 15:22:07 +00:00
#include "WalletRpcServerCommandsDefinitions.h"
#include "WalletLegacy/WalletLegacy.h"
#include "Common/CommandLine.h"
#include "Rpc/HttpServer.h"
2015-05-27 12:08:46 +00:00
#include <Logging/LoggerRef.h>
2015-07-30 15:22:07 +00:00
namespace Tools
2014-04-02 16:00:17 +00:00
{
/************************************************************************/
/* */
/************************************************************************/
2015-05-27 12:08:46 +00:00
class wallet_rpc_server : CryptoNote::HttpServer
2014-04-02 16:00:17 +00:00
{
public:
2015-05-27 12:08:46 +00:00
wallet_rpc_server(
System::Dispatcher& dispatcher,
Logging::ILogger& log,
2015-07-30 15:22:07 +00:00
CryptoNote::IWalletLegacy &w,
2015-05-27 12:08:46 +00:00
CryptoNote::INode &n,
CryptoNote::Currency& currency,
const std::string& walletFilename);
2014-04-02 16:00:17 +00:00
static void init_options(boost::program_options::options_description& desc);
bool init(const boost::program_options::variables_map& vm);
2015-05-27 12:08:46 +00:00
2014-04-02 16:00:17 +00:00
bool run();
2015-05-27 12:08:46 +00:00
void send_stop_signal();
static const command_line::arg_descriptor<uint16_t> arg_rpc_bind_port;
static const command_line::arg_descriptor<std::string> arg_rpc_bind_ip;
2014-04-02 16:00:17 +00:00
2015-05-27 12:08:46 +00:00
private:
2014-04-02 16:00:17 +00:00
2015-05-27 12:08:46 +00:00
virtual void processRequest(const CryptoNote::HttpRequest& request, CryptoNote::HttpResponse& response) override;
2014-04-02 16:00:17 +00:00
2015-05-27 12:08:46 +00:00
//json_rpc
bool on_getbalance(const wallet_rpc::COMMAND_RPC_GET_BALANCE::request& req, wallet_rpc::COMMAND_RPC_GET_BALANCE::response& res);
bool on_transfer(const wallet_rpc::COMMAND_RPC_TRANSFER::request& req, wallet_rpc::COMMAND_RPC_TRANSFER::response& res);
bool on_store(const wallet_rpc::COMMAND_RPC_STORE::request& req, wallet_rpc::COMMAND_RPC_STORE::response& res);
bool on_get_payments(const wallet_rpc::COMMAND_RPC_GET_PAYMENTS::request& req, wallet_rpc::COMMAND_RPC_GET_PAYMENTS::response& res);
bool on_get_transfers(const wallet_rpc::COMMAND_RPC_GET_TRANSFERS::request& req, wallet_rpc::COMMAND_RPC_GET_TRANSFERS::response& res);
bool on_get_height(const wallet_rpc::COMMAND_RPC_GET_HEIGHT::request& req, wallet_rpc::COMMAND_RPC_GET_HEIGHT::response& res);
bool on_reset(const wallet_rpc::COMMAND_RPC_RESET::request& req, wallet_rpc::COMMAND_RPC_RESET::response& res);
2014-04-02 16:00:17 +00:00
2015-05-27 12:08:46 +00:00
bool handle_command_line(const boost::program_options::variables_map& vm);
2014-04-02 16:00:17 +00:00
2015-05-27 12:08:46 +00:00
Logging::LoggerRef logger;
2015-07-30 15:22:07 +00:00
CryptoNote::IWalletLegacy& m_wallet;
2015-05-27 12:08:46 +00:00
CryptoNote::INode& m_node;
uint16_t m_port;
std::string m_bind_ip;
CryptoNote::Currency& m_currency;
const std::string m_walletFilename;
2015-05-27 12:08:46 +00:00
System::Dispatcher& m_dispatcher;
System::Event m_stopComplete;
2014-04-02 16:00:17 +00:00
};
}