danicoin/src/wallet/wallet_rpc_server.h

86 lines
3.4 KiB
C
Raw Normal View History

2015-05-27 12:08:46 +00:00
// Copyright (c) 2012-2015, The CryptoNote developers, The Bytecoin developers
2014-08-13 10:38:35 +00:00
//
// This file is part of Bytecoin.
//
// Bytecoin is free software: you can redistribute it and/or modify
// it under the terms of the GNU Lesser General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Bytecoin is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU Lesser General Public License for more details.
//
// You should have received a copy of the GNU Lesser General Public License
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
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>
#include "wallet_rpc_server_commans_defs.h"
#include "Wallet.h"
2015-05-27 12:08:46 +00:00
#include "SyncWallet.h"
#include "Common/command_line.h"
#include "rpc/HttpServer.h"
#include <Logging/LoggerRef.h>
2014-04-02 16:00:17 +00:00
namespace tools
{
/************************************************************************/
/* */
/************************************************************************/
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,
CryptoNote::IWallet &w,
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;
CryptoNote::IWallet& m_wallet;
CryptoNote::SyncWallet m_syncWallet;
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
};
}