forked from lthn/blockchain
added missing files, fixed build
This commit is contained in:
parent
adba06c610
commit
b52391aa3b
6 changed files with 2816 additions and 4 deletions
151
src/wallet/core_fast_rpc_proxy.h
Normal file
151
src/wallet/core_fast_rpc_proxy.h
Normal file
|
|
@ -0,0 +1,151 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry 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 "rpc/core_rpc_server.h"
|
||||
#include "wallet/core_rpc_proxy.h"
|
||||
#include "currency_core/alias_helper.h"
|
||||
namespace tools
|
||||
{
|
||||
class core_fast_rpc_proxy: public i_core_proxy
|
||||
{
|
||||
public:
|
||||
core_fast_rpc_proxy(currency::core_rpc_server& rpc_srv) :m_rpc(rpc_srv)
|
||||
{}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
virtual bool set_connection_addr(const std::string& url) override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES(const currency::COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::request& req, currency::COMMAND_RPC_GET_TX_GLOBAL_OUTPUTS_INDEXES::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_indexes(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_BLOCKS_FAST(const currency::COMMAND_RPC_GET_BLOCKS_FAST::request& req, currency::COMMAND_RPC_GET_BLOCKS_FAST::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_blocks(req, res, m_cntxt_stub);
|
||||
}
|
||||
bool call_COMMAND_RPC_GET_BLOCKS_DIRECT(const currency::COMMAND_RPC_GET_BLOCKS_DIRECT::request& rqt, currency::COMMAND_RPC_GET_BLOCKS_DIRECT::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_get_blocks_direct(rqt, rsp, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_INFO(const currency::COMMAND_RPC_GET_INFO::request& req, currency::COMMAND_RPC_GET_INFO::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_info(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_TX_POOL(const currency::COMMAND_RPC_GET_TX_POOL::request& req, currency::COMMAND_RPC_GET_TX_POOL::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_tx_pool(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_ALIASES_BY_ADDRESS(const currency::COMMAND_RPC_GET_ALIASES_BY_ADDRESS::request& req, currency::COMMAND_RPC_GET_ALIASES_BY_ADDRESS::response& res) override
|
||||
{
|
||||
return m_rpc.on_alias_by_address(req, res, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS(const currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::request& req, currency::COMMAND_RPC_GET_RANDOM_OUTPUTS_FOR_AMOUNTS::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_random_outs(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_SEND_RAW_TX(const currency::COMMAND_RPC_SEND_RAW_TX::request& req, currency::COMMAND_RPC_SEND_RAW_TX::response& res) override
|
||||
{
|
||||
return m_rpc.on_send_raw_tx(req, res, m_cntxt_stub);
|
||||
}
|
||||
bool call_COMMAND_RPC_FORCE_RELAY_RAW_TXS(const currency::COMMAND_RPC_FORCE_RELAY_RAW_TXS::request& req, currency::COMMAND_RPC_FORCE_RELAY_RAW_TXS::response& res ) override
|
||||
{
|
||||
return m_rpc.on_force_relaey_raw_txs(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
virtual bool check_connection() override
|
||||
{
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_ALL_ALIASES(currency::COMMAND_RPC_GET_ALL_ALIASES::response& res) override
|
||||
{
|
||||
currency::COMMAND_RPC_GET_ALL_ALIASES::request req = AUTO_VAL_INIT(req);
|
||||
return m_rpc.on_get_all_aliases(req, res, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_ALIAS_DETAILS(const currency::COMMAND_RPC_GET_ALIAS_DETAILS::request& req, currency::COMMAND_RPC_GET_ALIAS_DETAILS::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_alias_details(req, res, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_ALIAS_REWARD(const currency::COMMAND_RPC_GET_ALIAS_REWARD::request& req, currency::COMMAND_RPC_GET_ALIAS_REWARD::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_alias_reward(req, res, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_TRANSACTIONS(const currency::COMMAND_RPC_GET_TRANSACTIONS::request& req, currency::COMMAND_RPC_GET_TRANSACTIONS::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_get_transactions(req, rsp, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_COMMAND_RPC_CHECK_KEYIMAGES(const currency::COMMAND_RPC_CHECK_KEYIMAGES::request& req, currency::COMMAND_RPC_CHECK_KEYIMAGES::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_check_keyimages(req, rsp, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_SCAN_POS(const currency::COMMAND_RPC_SCAN_POS::request& req, currency::COMMAND_RPC_SCAN_POS::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_scan_pos(req, rsp, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GETBLOCKTEMPLATE(const currency::COMMAND_RPC_GETBLOCKTEMPLATE::request& req, currency::COMMAND_RPC_GETBLOCKTEMPLATE::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_getblocktemplate(req, rsp, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_SUBMITBLOCK(const currency::COMMAND_RPC_SUBMITBLOCK::request& req, currency::COMMAND_RPC_SUBMITBLOCK::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_submitblock(req, rsp, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_SUBMITBLOCK2(const currency::COMMAND_RPC_SUBMITBLOCK2::request& req, currency::COMMAND_RPC_SUBMITBLOCK2::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_submitblock2(req, rsp, m_err_stub, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_POS_MINING_DETAILS(const currency::COMMAND_RPC_GET_POS_MINING_DETAILS::request& req, currency::COMMAND_RPC_GET_POS_MINING_DETAILS::response& rsp) override
|
||||
{
|
||||
return m_rpc.on_get_pos_mining_details(req, rsp, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_BLOCKS_DETAILS(const currency::COMMAND_RPC_GET_BLOCKS_DETAILS::request& req, currency::COMMAND_RPC_GET_BLOCKS_DETAILS::response& res) override
|
||||
{
|
||||
return m_rpc.on_rpc_get_blocks_details(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN(const currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::request& req, currency::COMMAND_RPC_GET_CURRENT_CORE_TX_EXPIRATION_MEDIAN::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_current_core_tx_expiration_median(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool call_COMMAND_RPC_GET_POOL_INFO(const currency::COMMAND_RPC_GET_POOL_INFO::request& req, currency::COMMAND_RPC_GET_POOL_INFO::response& res) override
|
||||
{
|
||||
return m_rpc.on_get_pool_info(req, res, m_cntxt_stub);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
virtual bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id) override
|
||||
{
|
||||
return tools::get_transfer_address(adr_str, addr, payment_id, this);
|
||||
}
|
||||
|
||||
private:
|
||||
currency::core_rpc_server& m_rpc;
|
||||
currency::core_rpc_server::connection_context m_cntxt_stub;
|
||||
epee::json_rpc::error m_err_stub;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
|
@ -8,12 +8,16 @@
|
|||
#include "currency_core/currency_config.h"
|
||||
#include "version.h"
|
||||
#include "currency_core/currency_format_utils.h"
|
||||
//#include "wallets_manager.h"
|
||||
|
||||
//TODO: global objects, need refactoring. Just temporary solution
|
||||
std::map<int64_t, plain_wallet::plain_wallet_api_impl*> ginstances;
|
||||
epee::critical_section ginstances_lock;
|
||||
std::atomic<int64_t> gcounter(1);
|
||||
std::atomic<bool> glogs_initialized(false);
|
||||
std::atomic<bool> glogs_initialized(false);
|
||||
|
||||
#define HOME_FOLDER "Documents"
|
||||
#define WALLETS_FOLDER_NAME "wallets"
|
||||
|
||||
#define GENERAL_INTERNAL_ERRROR_INSTANCE "GENERAL_INTERNAL_ERROR: WALLET INSTNACE NOT FOUND"
|
||||
|
||||
|
|
@ -29,7 +33,8 @@ std::atomic<bool> glogs_initialized(false);
|
|||
CRITICAL_REGION_END();
|
||||
|
||||
|
||||
|
||||
//TODO: global object, subject to refactoring
|
||||
//wallets_manager gwm;
|
||||
|
||||
namespace plain_wallet
|
||||
{
|
||||
|
|
@ -42,7 +47,10 @@ namespace plain_wallet
|
|||
|
||||
std::string get_wallets_folder()
|
||||
{
|
||||
return get_bundle_root_dir() + "/Documents";
|
||||
std::string path = get_bundle_root_dir() + "/" + HOME_FOLDER + "/" + WALLETS_FOLDER_NAME;
|
||||
boost::system::error_code ec;
|
||||
boost::filesystem::create_directories(path, ec);
|
||||
return path;
|
||||
}
|
||||
|
||||
std::string print_money(int64_t amount)
|
||||
|
|
@ -53,7 +61,7 @@ namespace plain_wallet
|
|||
void initialize_logs()
|
||||
{
|
||||
std::string log_dir = get_bundle_root_dir();
|
||||
log_dir += "/Documents";
|
||||
log_dir += "/" HOME_FOLDER;
|
||||
epee::log_space::get_set_log_detalisation_level(true, LOG_LEVEL_2);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_CONSOLE, NULL, NULL);
|
||||
epee::log_space::log_singletone::add_logger(LOGGER_FILE, "plain_wallet.log", log_dir.c_str());
|
||||
|
|
|
|||
766
src/wallet/view_iface.h
Normal file
766
src/wallet/view_iface.h
Normal file
|
|
@ -0,0 +1,766 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry 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 <stdint.h>
|
||||
// #include <QObject>
|
||||
// #ifndef Q_MOC_RUN
|
||||
#include "warnings.h"
|
||||
|
||||
PUSH_VS_WARNINGS
|
||||
DISABLE_VS_WARNINGS(4100)
|
||||
DISABLE_VS_WARNINGS(4503)
|
||||
#include "serialization/keyvalue_serialization.h"
|
||||
#include "storages/portable_storage_template_helper.h"
|
||||
#include "rpc/core_rpc_server_commands_defs.h"
|
||||
#include "wallet/wallet_public_structs_defs.h"
|
||||
#include "currency_core/offers_services_helpers.h"
|
||||
#include "currency_core/basic_api_response_codes.h"
|
||||
POP_VS_WARNINGS
|
||||
|
||||
//#endif
|
||||
|
||||
namespace view
|
||||
{
|
||||
|
||||
/*slots structures*/
|
||||
struct transfer_destination
|
||||
{
|
||||
std::string address;
|
||||
std::string amount;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE(amount)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct transfer_params
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
std::list<transfer_destination> destinations;
|
||||
uint64_t mixin_count;
|
||||
uint64_t lock_time;
|
||||
std::string payment_id;
|
||||
std::string comment;
|
||||
uint64_t fee;
|
||||
bool push_payer;
|
||||
bool hide_receiver;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(destinations)
|
||||
KV_SERIALIZE(mixin_count)
|
||||
KV_SERIALIZE(lock_time)
|
||||
KV_SERIALIZE(payment_id)
|
||||
KV_SERIALIZE(comment)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(push_payer)
|
||||
KV_SERIALIZE(hide_receiver)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct transfer_response
|
||||
{
|
||||
bool success;
|
||||
std::string tx_hash;
|
||||
uint64_t tx_blob_size;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(success)
|
||||
KV_SERIALIZE(tx_hash)
|
||||
KV_SERIALIZE(tx_blob_size)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
enum ui_last_build_displaymode
|
||||
{
|
||||
ui_lb_dm_actual = 0,
|
||||
ui_lb_dm_new = 1,
|
||||
ui_lb_dm_new_alert_calm = 2,
|
||||
ui_lb_dm_new_alert_urgent = 3,
|
||||
ui_lb_dm_new_alert_critical = 4
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct block_info
|
||||
{
|
||||
uint64_t date;
|
||||
uint64_t h;
|
||||
std::string type;
|
||||
std::string diff;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(date)
|
||||
KV_SERIALIZE(h)
|
||||
KV_SERIALIZE(type)
|
||||
KV_SERIALIZE(diff)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct switch_view_info
|
||||
{
|
||||
enum ui_views
|
||||
{
|
||||
ui_view_dashboard = 1,
|
||||
ui_view_wallet = 2
|
||||
};
|
||||
|
||||
int view;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(view)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
/*signal structures*/
|
||||
struct daemon_status_info
|
||||
{
|
||||
public:
|
||||
|
||||
uint64_t daemon_network_state;
|
||||
uint64_t synchronization_start_height;
|
||||
uint64_t max_net_seen_height;
|
||||
uint64_t height;
|
||||
uint64_t out_connections_count;
|
||||
uint64_t inc_connections_count;
|
||||
int64_t net_time_delta_median;
|
||||
int64_t synchronized_connections_count;
|
||||
std::string pos_difficulty;
|
||||
std::string pow_difficulty;
|
||||
uint64_t hashrate;
|
||||
uint64_t last_build_displaymode;
|
||||
uint64_t alias_count;
|
||||
std::string last_build_available;
|
||||
//std::list<block_info> last_blocks;
|
||||
bool is_pos_allowed;
|
||||
uint64_t expiration_median_timestamp;
|
||||
bool is_disconnected;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(daemon_network_state)
|
||||
KV_SERIALIZE(synchronization_start_height)
|
||||
KV_SERIALIZE(synchronized_connections_count)
|
||||
KV_SERIALIZE(max_net_seen_height)
|
||||
KV_SERIALIZE(height)
|
||||
KV_SERIALIZE(out_connections_count)
|
||||
KV_SERIALIZE(inc_connections_count)
|
||||
KV_SERIALIZE(net_time_delta_median)
|
||||
KV_SERIALIZE(pos_difficulty)
|
||||
KV_SERIALIZE(pow_difficulty)
|
||||
KV_SERIALIZE(hashrate)
|
||||
KV_SERIALIZE(last_build_displaymode)
|
||||
KV_SERIALIZE(last_build_available)
|
||||
//KV_SERIALIZE(last_blocks)
|
||||
KV_SERIALIZE(alias_count)
|
||||
KV_SERIALIZE(is_pos_allowed)
|
||||
KV_SERIALIZE(expiration_median_timestamp)
|
||||
KV_SERIALIZE(is_disconnected)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct wallet_status_info
|
||||
{
|
||||
enum state
|
||||
{
|
||||
wallet_state_synchronizing = 1,
|
||||
wallet_state_ready = 2,
|
||||
wallet_state_error = 3
|
||||
};
|
||||
|
||||
|
||||
uint64_t wallet_id;
|
||||
uint64_t wallet_state;
|
||||
bool is_mining;
|
||||
bool is_alias_operations_available;
|
||||
uint64_t balance;
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t awaiting_in;
|
||||
uint64_t awaiting_out;
|
||||
uint64_t minied_total;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(wallet_state)
|
||||
KV_SERIALIZE(is_mining)
|
||||
KV_SERIALIZE(is_alias_operations_available)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(awaiting_in)
|
||||
KV_SERIALIZE(awaiting_out)
|
||||
KV_SERIALIZE(minied_total)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct wallet_info
|
||||
{
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t balance;
|
||||
uint64_t mined_total;
|
||||
std::string address;
|
||||
std::string tracking_hey;
|
||||
std::string path;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(mined_total)
|
||||
KV_SERIALIZE(address)
|
||||
KV_SERIALIZE(tracking_hey)
|
||||
KV_SERIALIZE(path)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct wallet_entry_info
|
||||
{
|
||||
wallet_info wi;
|
||||
uint64_t wallet_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wi)
|
||||
KV_SERIALIZE(wallet_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct wallet_id_obj
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct request_mining_estimate
|
||||
{
|
||||
uint64_t amount_coins;
|
||||
uint64_t time;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(amount_coins)
|
||||
KV_SERIALIZE(time)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct response_mining_estimate
|
||||
{
|
||||
uint64_t final_amount;
|
||||
uint64_t all_coins_and_pos_diff_rate;
|
||||
std::vector<uint64_t> days_estimate;
|
||||
std::string error_code;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(final_amount)
|
||||
KV_SERIALIZE(all_coins_and_pos_diff_rate)
|
||||
KV_SERIALIZE(days_estimate)
|
||||
KV_SERIALIZE(error_code)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct backup_keys_request
|
||||
{
|
||||
|
||||
uint64_t wallet_id;
|
||||
std::string path;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(path)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct system_filedialog_request
|
||||
{
|
||||
std::string default_dir;
|
||||
std::string caption;
|
||||
std::string filemask;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(caption)
|
||||
KV_SERIALIZE(filemask)
|
||||
KV_SERIALIZE(default_dir)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct system_filedialog_response
|
||||
{
|
||||
std::string error_code;
|
||||
std::string path;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(error_code)
|
||||
KV_SERIALIZE(path)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct push_offer_param
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
bc_services::offer_details_ex od;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(od)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct cancel_offer_param
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
crypto::hash tx_id;
|
||||
uint64_t no;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING_N(tx_id, "id")
|
||||
KV_SERIALIZE_N(no, "oi")
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct transfer_event_info
|
||||
{
|
||||
tools::wallet_public::wallet_transfer_info ti;
|
||||
uint64_t unlocked_balance;
|
||||
uint64_t balance;
|
||||
uint64_t total_mined;
|
||||
uint64_t wallet_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(ti)
|
||||
KV_SERIALIZE(unlocked_balance)
|
||||
KV_SERIALIZE(balance)
|
||||
KV_SERIALIZE(total_mined)
|
||||
KV_SERIALIZE(wallet_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct transfers_array
|
||||
{
|
||||
std::vector<tools::wallet_public::wallet_transfer_info> unconfirmed;
|
||||
std::vector<tools::wallet_public::wallet_transfer_info> history;
|
||||
uint64_t total_history_items;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(unconfirmed)
|
||||
KV_SERIALIZE(history)
|
||||
KV_SERIALIZE(total_history_items)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
struct open_wallet_request
|
||||
{
|
||||
std::string pass;
|
||||
std::string path;
|
||||
uint64_t txs_to_return;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(pass)
|
||||
KV_SERIALIZE(path)
|
||||
KV_SERIALIZE(txs_to_return)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct get_recent_transfers_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
uint64_t offset;
|
||||
uint64_t count;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(offset)
|
||||
KV_SERIALIZE(count)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct reset_pass_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
std::string pass;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(pass)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct restore_wallet_request
|
||||
{
|
||||
std::string pass;
|
||||
std::string path;
|
||||
std::string restore_key;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(pass)
|
||||
KV_SERIALIZE(path)
|
||||
KV_SERIALIZE(restore_key)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct open_wallet_response
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
transfers_array recent_history;
|
||||
wallet_info wi;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(recent_history)
|
||||
KV_SERIALIZE(wi)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct wallets_summary_info
|
||||
{
|
||||
std::list<wallet_entry_info> wallets;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallets)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct header_entry
|
||||
{
|
||||
std::string field;
|
||||
std::string val;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(field)
|
||||
KV_SERIALIZE(val)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct request_uri_params
|
||||
{
|
||||
std::string method;
|
||||
std::string data;
|
||||
std::vector<header_entry > headers;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(method)
|
||||
KV_SERIALIZE(data)
|
||||
KV_SERIALIZE(headers)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct password_data
|
||||
{
|
||||
std::string pass;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(pass)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct alias_set
|
||||
{
|
||||
std::list<currency::alias_rpc_details> aliases;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(aliases)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct request_alias_param
|
||||
{
|
||||
currency::alias_rpc_details alias;
|
||||
uint64_t wallet_id;
|
||||
uint64_t fee;
|
||||
uint64_t reward;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(alias)
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(reward)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct start_backend_params
|
||||
{
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct wallet_sync_progres_param
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
uint64_t progress;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(progress)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct get_restore_info_response
|
||||
{
|
||||
std::string restore_key;
|
||||
std::string error_code;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(restore_key)
|
||||
KV_SERIALIZE(error_code)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct get_alias_coast_response
|
||||
{
|
||||
std::string error_code;
|
||||
uint64_t coast;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(coast)
|
||||
KV_SERIALIZE(error_code)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct print_text_param
|
||||
{
|
||||
std::string html_text;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(html_text)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct get_fav_offers_request
|
||||
{
|
||||
std::list<bc_services::offer_id> ids;
|
||||
bc_services::core_offers_filter filter;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(ids)
|
||||
KV_SERIALIZE(filter)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct set_localization_request
|
||||
{
|
||||
std::vector<std::string> strings;
|
||||
std::string language_title;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(strings)
|
||||
KV_SERIALIZE(language_title)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct wallet_and_contract_id_param
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
crypto::hash contract_id;
|
||||
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE_POD_AS_HEX_STRING(contract_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct release_contract_param : public wallet_and_contract_id_param
|
||||
{
|
||||
std::string release_type;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(release_type)
|
||||
KV_CHAIN_BASE(wallet_and_contract_id_param)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
struct contract_and_fee_param : public wallet_and_contract_id_param
|
||||
{
|
||||
uint64_t fee;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(fee)
|
||||
KV_CHAIN_BASE(wallet_and_contract_id_param)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
struct crequest_cancel_contract_param : public contract_and_fee_param
|
||||
{
|
||||
uint64_t expiration_period;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(expiration_period)
|
||||
KV_CHAIN_BASE(contract_and_fee_param)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct create_proposal_param_gui : public tools::wallet_public::create_proposal_param
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_CHAIN_BASE(tools::wallet_public::create_proposal_param)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct address_validation_response
|
||||
{
|
||||
std::string error_code;
|
||||
std::string payment_id;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(error_code)
|
||||
KV_SERIALIZE(payment_id)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct gui_options
|
||||
{
|
||||
bool use_debug_mode;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(use_debug_mode)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
|
||||
};
|
||||
|
||||
struct print_log_params
|
||||
{
|
||||
std::string msg;
|
||||
int log_level;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(msg)
|
||||
KV_SERIALIZE(log_level)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct api_response
|
||||
{
|
||||
// std::string request_id;
|
||||
std::string error_code;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
// KV_SERIALIZE(request_id)
|
||||
KV_SERIALIZE(error_code)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
template<typename t_type>
|
||||
struct api_response_t
|
||||
{
|
||||
std::string error_code;
|
||||
t_type response_data;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(error_code)
|
||||
KV_SERIALIZE(response_data)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
template<typename t_type>
|
||||
struct api_request_t
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
t_type req_data;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(req_data)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
struct api_void
|
||||
{
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
template<typename t_type>
|
||||
struct struct_with_one_t_type
|
||||
{
|
||||
t_type v;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(v)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
#define API_RETURN_CODE_OK BASIC_RESPONSE_STATUS_OK
|
||||
#define API_RETURN_CODE_FAIL BASIC_RESPONSE_STATUS_FAILED
|
||||
#define API_RETURN_CODE_NOT_FOUND BASIC_RESPONSE_STATUS_NOT_FOUND
|
||||
#define API_RETURN_CODE_ACCESS_DENIED "ACCESS_DENIED"
|
||||
#define API_RETURN_CODE_INTERNAL_ERROR "INTERNAL_ERROR"
|
||||
#define API_RETURN_CODE_NOT_ENOUGH_MONEY "NOT_ENOUGH_MONEY"
|
||||
#define API_RETURN_CODE_INTERNAL_ERROR_QUE_FULL "INTERNAL_ERROR_QUE_FULL"
|
||||
#define API_RETURN_CODE_BAD_ARG "BAD_ARG"
|
||||
#define API_RETURN_CODE_BAD_ARG_EMPTY_DESTINATIONS "BAD_ARG_EMPTY_DESTINATIONS"
|
||||
#define API_RETURN_CODE_BAD_ARG_WRONG_FEE "BAD_ARG_WRONG_FEE"
|
||||
#define API_RETURN_CODE_BAD_ARG_INVALID_ADDRESS "BAD_ARG_INVALID_ADDRESS"
|
||||
#define API_RETURN_CODE_BAD_ARG_WRONG_AMOUNT "BAD_ARG_WRONG_AMOUNT"
|
||||
#define API_RETURN_CODE_BAD_ARG_WRONG_PAYMENT_ID "BAD_ARG_WRONG_PAYMENT_ID"
|
||||
#define API_RETURN_CODE_WRONG_PASSWORD "WRONG_PASSWORD"
|
||||
#define API_RETURN_CODE_WALLET_WRONG_ID "WALLET_WRONG_ID"
|
||||
#define API_RETURN_CODE_WALLET_WATCH_ONLY_NOT_SUPPORTED "WALLET_WATCH_ONLY_NOT_SUPPORTED"
|
||||
#define API_RETURN_CODE_FILE_NOT_FOUND "FILE_NOT_FOUND"
|
||||
#define API_RETURN_CODE_ALREADY_EXISTS "ALREADY_EXISTS"
|
||||
#define API_RETURN_CODE_CANCELED "CANCELED"
|
||||
#define API_RETURN_CODE_FILE_RESTORED "FILE_RESTORED"
|
||||
#define API_RETURN_CODE_TRUE "TRUE"
|
||||
#define API_RETURN_CODE_FALSE "FALSE"
|
||||
#define API_RETURN_CODE_CORE_BUSY "CORE_BUSY"
|
||||
#define API_RETURN_CODE_OVERFLOW "OVERFLOW"
|
||||
|
||||
#define API_MAX_ALIASES_COUNT 10000
|
||||
|
||||
struct i_view
|
||||
{
|
||||
virtual bool update_daemon_status(const daemon_status_info& info){ return true; }
|
||||
virtual bool on_backend_stopped(){ return true; }
|
||||
virtual bool show_msg_box(const std::string& message){ return true; }
|
||||
virtual bool update_wallet_status(const wallet_status_info& wsi){ return true; }
|
||||
virtual bool update_wallets_info(const wallets_summary_info& wsi){ return true; }
|
||||
virtual bool money_transfer(const transfer_event_info& wsi){ return true; }
|
||||
virtual bool wallet_sync_progress(const view::wallet_sync_progres_param& p){ return true; }
|
||||
virtual bool init(const std::string& path){ return true; }
|
||||
virtual bool pos_block_found(const currency::block& block_found){ return true; }
|
||||
virtual bool money_transfer_cancel(const transfer_event_info& wsi){ return true; }
|
||||
virtual bool set_options(const gui_options& opt){ return true; }
|
||||
};
|
||||
|
||||
}
|
||||
45
src/wallet/wallet_id_adapter.h
Normal file
45
src/wallet/wallet_id_adapter.h
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry 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 "wallet/wallet2.h"
|
||||
|
||||
class i_backend_wallet_callback
|
||||
{
|
||||
public:
|
||||
virtual void on_new_block(size_t wallet_id, uint64_t /*height*/, const currency::block& /*block*/) {}
|
||||
virtual void on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) {}
|
||||
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/) {}
|
||||
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/) {}
|
||||
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti) {}
|
||||
};
|
||||
|
||||
struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
|
||||
{
|
||||
i_wallet_to_i_backend_adapter(i_backend_wallet_callback* pbackend, size_t wallet_id) :m_pbackend(pbackend),
|
||||
m_wallet_id(wallet_id)
|
||||
{}
|
||||
|
||||
virtual void on_new_block(uint64_t height, const currency::block& block) {
|
||||
m_pbackend->on_new_block(m_wallet_id, height, block);
|
||||
}
|
||||
virtual void on_transfer2(const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined) {
|
||||
m_pbackend->on_transfer2(m_wallet_id, wti, balance, unlocked_balance, total_mined);
|
||||
}
|
||||
virtual void on_pos_block_found(const currency::block& wti) {
|
||||
m_pbackend->on_pos_block_found(m_wallet_id, wti);
|
||||
}
|
||||
virtual void on_sync_progress(const uint64_t& progress) {
|
||||
m_pbackend->on_sync_progress(m_wallet_id, progress);
|
||||
}
|
||||
virtual void on_transfer_canceled(const tools::wallet_public::wallet_transfer_info& wti) {
|
||||
m_pbackend->on_transfer_canceled(m_wallet_id, wti);
|
||||
}
|
||||
private:
|
||||
i_backend_wallet_callback* m_pbackend;
|
||||
size_t m_wallet_id;
|
||||
};
|
||||
1644
src/wallet/wallets_manager.cpp
Normal file
1644
src/wallet/wallets_manager.cpp
Normal file
File diff suppressed because it is too large
Load diff
198
src/wallet/wallets_manager.h
Normal file
198
src/wallet/wallets_manager.h
Normal file
|
|
@ -0,0 +1,198 @@
|
|||
// Copyright (c) 2014-2018 Zano Project
|
||||
// Copyright (c) 2014-2018 The Louisdor Project
|
||||
// Copyright (c) 2012-2013 The Boolberry 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 <boost/program_options.hpp>
|
||||
#include "warnings.h"
|
||||
PUSH_VS_WARNINGS
|
||||
DISABLE_VS_WARNINGS(4100)
|
||||
DISABLE_VS_WARNINGS(4503)
|
||||
#include "include_base_utils.h"
|
||||
#include "version.h"
|
||||
|
||||
using namespace epee;
|
||||
|
||||
#include "console_handler.h"
|
||||
#include "p2p/net_node.h"
|
||||
#include "currency_core/checkpoints_create.h"
|
||||
#include "currency_core/currency_core.h"
|
||||
#include "currency_core/bc_offers_service.h"
|
||||
#include "rpc/core_rpc_server.h"
|
||||
#include "currency_protocol/currency_protocol_handler.h"
|
||||
#include "daemon/daemon_commands_handler.h"
|
||||
//#include "common/miniupnp_helper.h"
|
||||
#include "view_iface.h"
|
||||
#include "core_fast_rpc_proxy.h"
|
||||
#include "wallet/wallet2.h"
|
||||
#include "wallet_id_adapter.h"
|
||||
|
||||
POP_VS_WARNINGS
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
|
||||
//TODO: need refactoring here. (template classes can't be used in BOOST_CLASS_VERSION)
|
||||
BOOST_CLASS_VERSION(nodetool::node_server<currency::t_currency_protocol_handler<currency::core> >, CURRENT_P2P_STORAGE_ARCHIVE_VER);
|
||||
|
||||
struct wallet_lock_time_watching_policy
|
||||
{
|
||||
static void watch_lock_time(uint64_t lock_time);
|
||||
};
|
||||
|
||||
|
||||
class wallets_manager : public i_backend_wallet_callback
|
||||
{
|
||||
|
||||
public:
|
||||
struct wallet_vs_options
|
||||
{
|
||||
currency::core_runtime_config core_conf;
|
||||
epee::locked_object<std::shared_ptr<tools::wallet2>, wallet_lock_time_watching_policy> w;
|
||||
std::atomic<bool> do_mining;
|
||||
std::atomic<bool> major_stop;
|
||||
std::atomic<bool> stop_for_refresh; //use separate var for passing to "refresh" member function,
|
||||
//because it can be changed there due to internal interruption logis
|
||||
|
||||
std::atomic<bool> break_mining_loop;
|
||||
std::atomic<uint64_t> wallet_state;
|
||||
std::atomic<uint64_t> last_wallet_synch_height;
|
||||
std::atomic<uint64_t>* plast_daemon_height;
|
||||
std::atomic<uint64_t>* plast_daemon_network_state;
|
||||
std::atomic<bool>* plast_daemon_is_disconnected;
|
||||
std::atomic<bool> has_related_alias_in_unconfirmed;
|
||||
std::atomic<bool> need_to_update_wallet_info;
|
||||
view::i_view* pview;
|
||||
uint64_t wallet_id;
|
||||
epee::locked_object<std::list<bc_services::offer_details_ex>> offers;
|
||||
|
||||
std::thread miner_thread;
|
||||
void worker_func();
|
||||
std::string get_log_prefix() const { return std::string("[") + epee::string_tools::num_to_string_fast(wallet_id) + ":" + w->get()->get_log_prefix() + "]"; }
|
||||
~wallet_vs_options();
|
||||
};
|
||||
|
||||
wallets_manager();
|
||||
~wallets_manager();
|
||||
bool init(int argc, char* argv[], view::i_view* pview_handler);
|
||||
bool start();
|
||||
bool stop();
|
||||
bool send_stop_signal();
|
||||
std::string open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr);
|
||||
std::string generate_wallet(const std::wstring& path, const std::string& password, view::open_wallet_response& owr);
|
||||
std::string restore_wallet(const std::wstring& path, const std::string& password, const std::string& restore_key, view::open_wallet_response& owr);
|
||||
std::string run_wallet(uint64_t wallet_id);
|
||||
std::string get_recent_transfers(size_t wallet_id, uint64_t offset, uint64_t count, view::transfers_array& tr_hist);
|
||||
std::string get_wallet_info(size_t wallet_id, view::wallet_info& wi);
|
||||
std::string get_contracts(size_t wallet_id, std::vector<tools::wallet_public::escrow_contract_details>& contracts);
|
||||
std::string create_proposal(const view::create_proposal_param_gui& cpp);
|
||||
std::string accept_proposal(size_t wallet_id, const crypto::hash& contract_id);
|
||||
std::string release_contract(size_t wallet_id, const crypto::hash& contract_id, const std::string& contract_over_type);
|
||||
std::string request_cancel_contract(size_t wallet_id, const crypto::hash& contract_id, uint64_t fee, uint64_t expiration_period);
|
||||
std::string accept_cancel_contract(size_t wallet_id, const crypto::hash& contract_id);
|
||||
|
||||
std::string get_wallet_info(wallet_vs_options& w, view::wallet_info& wi);
|
||||
std::string close_wallet(size_t wallet_id);
|
||||
std::string push_offer(size_t wallet_id, const bc_services::offer_details_ex& od, currency::transaction& res_tx);
|
||||
std::string cancel_offer(const view::cancel_offer_param& co, currency::transaction& res_tx);
|
||||
std::string push_update_offer(const bc_services::update_offer_details& uo, currency::transaction& res_tx);
|
||||
//std::string get_all_offers(currency::COMMAND_RPC_GET_OFFERS_EX::response& od);
|
||||
std::string get_offers_ex(const bc_services::core_offers_filter& cof, std::list<bc_services::offer_details_ex>& offers, uint64_t& total_count);
|
||||
std::string get_aliases(view::alias_set& al_set);
|
||||
std::string get_alias_info_by_address(const std::string& addr, currency::alias_rpc_details& res_details);
|
||||
std::string get_alias_info_by_name(const std::string& name, currency::alias_rpc_details& res_details);
|
||||
std::string request_alias_registration(const currency::alias_rpc_details& al, uint64_t wallet_id, uint64_t fee, currency::transaction& res_tx, uint64_t reward);
|
||||
std::string request_alias_update(const currency::alias_rpc_details& al, uint64_t wallet_id, uint64_t fee, currency::transaction& res_tx, uint64_t reward);
|
||||
std::string get_alias_coast(const std::string& a, uint64_t& coast);
|
||||
std::string validate_address(const std::string& addr, std::string& payment_id);
|
||||
std::string resync_wallet(uint64_t wallet_id);
|
||||
std::string start_pos_mining(uint64_t wallet_id);
|
||||
std::string stop_pos_mining(uint64_t wallet_id);
|
||||
std::string check_available_sources(uint64_t wallet_id, std::list<uint64_t>& amounts);
|
||||
std::string get_mining_history(uint64_t wallet_id, tools::wallet_public::mining_history& wrpc);
|
||||
std::string get_wallet_restore_info(uint64_t wallet_id, std::string& restore_key);
|
||||
std::string backup_wallet(uint64_t wallet_id, const std::wstring& path);
|
||||
std::string reset_wallet_password(uint64_t wallet_id, const std::string& pass);
|
||||
std::string is_wallet_password_valid(uint64_t wallet_id, const std::string& pass);
|
||||
std::string get_my_offers(const bc_services::core_offers_filter& filter, std::list<bc_services::offer_details_ex>& offers);
|
||||
std::string get_fav_offers(const std::list<bc_services::offer_id>& hashes, const bc_services::core_offers_filter& filter, std::list<bc_services::offer_details_ex>& offers);
|
||||
std::string get_tx_pool_info(currency::COMMAND_RPC_GET_POOL_INFO::response& res);
|
||||
uint64_t get_default_fee();
|
||||
std::string get_mining_estimate(uint64_t amuont_coins,
|
||||
uint64_t time,
|
||||
uint64_t& estimate_result,
|
||||
uint64_t& all_coins_and_pos_diff_rate,
|
||||
std::vector<uint64_t>& days);
|
||||
std::string is_pos_allowed();
|
||||
void toggle_pos_mining();
|
||||
std::string transfer(size_t wallet_id, const view::transfer_params& tp, currency::transaction& res_tx);
|
||||
std::string get_config_folder();
|
||||
std::string is_valid_brain_restore_data(const std::string& brain_text);
|
||||
void subscribe_to_core_events(currency::i_core_event_handler* pevents_handler);
|
||||
void unsubscribe_to_core_events();
|
||||
void get_gui_options(view::gui_options& opt);
|
||||
std::string get_wallet_log_prefix(size_t wallet_id) const;
|
||||
bool is_qt_logs_enabled() const { return m_qt_logs_enbaled; }
|
||||
|
||||
private:
|
||||
void main_worker(const po::variables_map& vm);
|
||||
bool init_local_daemon();
|
||||
bool deinit_local_daemon();
|
||||
bool update_state_info();
|
||||
bool update_wallets();
|
||||
void loop();
|
||||
//bool get_transfer_address(const std::string& adr_str, currency::account_public_address& addr, std::string& payment_id);
|
||||
bool get_last_blocks(view::daemon_status_info& dsi);
|
||||
void update_wallets_info();
|
||||
void init_wallet_entry(wallet_vs_options& wo, uint64_t id);
|
||||
static void prepare_wallet_status_info(wallet_vs_options& wo, view::wallet_status_info& wsi);
|
||||
//----- i_backend_wallet_callback ------
|
||||
virtual void on_new_block(size_t wallet_id, uint64_t height, const currency::block& block);
|
||||
virtual void on_transfer2(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti, uint64_t balance, uint64_t unlocked_balance, uint64_t total_mined);
|
||||
virtual void on_pos_block_found(size_t wallet_id, const currency::block& /*block*/);
|
||||
virtual void on_sync_progress(size_t wallet_id, const uint64_t& /*percents*/);
|
||||
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti);
|
||||
|
||||
std::thread m_main_worker_thread;
|
||||
std::atomic<bool> m_stop_singal_sent;
|
||||
view::i_view m_view_stub;
|
||||
view::i_view* m_pview;
|
||||
std::shared_ptr<tools::i_core_proxy> m_rpc_proxy;
|
||||
mutable critical_section m_wallets_lock;
|
||||
po::variables_map m_vm;
|
||||
|
||||
std::atomic<uint64_t> m_last_daemon_height;
|
||||
std::atomic<uint64_t> m_last_daemon_network_state;
|
||||
std::atomic<bool> m_last_daemon_is_disconnected;
|
||||
// std::atomic<uint64_t> m_last_wallet_synch_height;
|
||||
std::atomic<uint64_t> m_wallet_id_counter;
|
||||
|
||||
std::string m_data_dir;
|
||||
view::gui_options m_ui_opt;
|
||||
|
||||
//daemon stuff
|
||||
bc_services::bc_offers_service m_offers_service;
|
||||
currency::core m_ccore;
|
||||
currency::t_currency_protocol_handler<currency::core> m_cprotocol;
|
||||
nodetool::node_server<currency::t_currency_protocol_handler<currency::core> > m_p2psrv;
|
||||
currency::core_rpc_server m_rpc_server;
|
||||
|
||||
bool m_remote_node_mode;
|
||||
bool m_qt_logs_enbaled;
|
||||
std::atomic<bool> m_is_pos_allowed;
|
||||
|
||||
|
||||
std::map<size_t, wallet_vs_options> m_wallets;
|
||||
std::vector<std::string> m_wallet_log_prefixes;
|
||||
mutable critical_section m_wallet_log_prefixes_lock;
|
||||
};
|
||||
|
||||
|
||||
|
||||
|
||||
Loading…
Add table
Reference in a new issue