forked from lthn/blockchain
fixed multiple compilation problems
This commit is contained in:
parent
fed1df53f0
commit
3b7e038064
11 changed files with 146 additions and 122 deletions
|
|
@ -4,6 +4,10 @@
|
|||
// Distributed under the MIT/X11 software license, see the accompanying
|
||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||
|
||||
#include <cstdlib>
|
||||
#if defined(WIN32)
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#include <thread>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/program_options.hpp>
|
||||
|
|
@ -22,11 +26,10 @@
|
|||
#include "string_coding.h"
|
||||
#include "wallet/wrap_service.h"
|
||||
#include "common/general_purpose_commands_defs.h"
|
||||
#include <cstdlib>
|
||||
|
||||
#if defined(WIN32)
|
||||
#include <crtdbg.h>
|
||||
#endif
|
||||
#include "wallet/wallet_helpers.h"
|
||||
|
||||
|
||||
|
||||
using namespace std;
|
||||
using namespace epee;
|
||||
|
|
@ -695,7 +698,7 @@ void simple_wallet::on_tor_status_change(const std::string& state)
|
|||
message_writer(epee::log_space::console_color_yellow, true, std::string("[TOR]: ")) << human_message;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
void simple_wallet::on_mw_get_wallets(std::vector<wallet_public::wallet_entry_info>& wallets)
|
||||
void simple_wallet::on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets)
|
||||
{
|
||||
wallets.resize(1);
|
||||
tools::get_wallet_info(*m_wallet, wallets[0].wi);
|
||||
|
|
@ -1893,7 +1896,7 @@ bool simple_wallet::generate_ionic_swap_proposal(const std::vector<std::string>
|
|||
}
|
||||
|
||||
transaction tx_template = AUTO_VAL_INIT(tx_template);
|
||||
bool r = m_wallet->create_ionic_swap_proposal(proposal, destination_addr, tx_template);
|
||||
r = m_wallet->create_ionic_swap_proposal(proposal, destination_addr, tx_template);
|
||||
if (!r)
|
||||
{
|
||||
fail_msg_writer() << "Failed to create ionic_swap proposal";
|
||||
|
|
@ -2352,7 +2355,8 @@ int main(int argc, char* argv[])
|
|||
if (daemon_address.empty())
|
||||
daemon_address = std::string("http://") + daemon_host + ":" + std::to_string(daemon_port);
|
||||
|
||||
tools::wallet2 wal;
|
||||
std::shared_ptr<tools::wallet2> wallet_ptr(new tools::wallet2());
|
||||
tools::wallet2& wal = *wallet_ptr;
|
||||
//try to open it
|
||||
while (true)
|
||||
{
|
||||
|
|
@ -2408,7 +2412,7 @@ int main(int argc, char* argv[])
|
|||
}
|
||||
}
|
||||
|
||||
tools::wallet_rpc_server wrpc(wal);
|
||||
tools::wallet_rpc_server wrpc(wallet_ptr);
|
||||
bool r = wrpc.init(vm);
|
||||
CHECK_AND_ASSERT_MES(r, EXIT_FAILURE, "Failed to initialize wallet rpc server");
|
||||
|
||||
|
|
|
|||
|
|
@ -111,7 +111,7 @@ namespace currency
|
|||
virtual void on_message(i_wallet2_callback::message_severity severity, const std::string& m) override;
|
||||
virtual void on_tor_status_change(const std::string& state) override;
|
||||
|
||||
virtual void on_mw_get_wallets(std::vector<wallet_public::wallet_entry_info>& wallets) override;
|
||||
virtual void on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets) override;
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id) override;
|
||||
//----------------------------------------------------------
|
||||
|
||||
|
|
|
|||
|
|
@ -209,9 +209,9 @@ public:
|
|||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
typedef wallet_public::wallet_info wallet_info;
|
||||
typedef tools::wallet_public::wallet_info wallet_info;
|
||||
|
||||
typedef wallet_public::wallet_entry_info wallet_entry_info;
|
||||
typedef tools::wallet_public::wallet_entry_info wallet_entry_info;
|
||||
|
||||
|
||||
|
||||
|
|
@ -709,48 +709,9 @@ public:
|
|||
};
|
||||
|
||||
|
||||
struct asset_funds
|
||||
{
|
||||
crypto::public_key asset_id;
|
||||
uint64_t amount;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(asset_id)
|
||||
KV_SERIALIZE(amount)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct ionic_swap_proposal_info
|
||||
{
|
||||
std::vector<asset_funds> from;
|
||||
std::vector<asset_funds> to;
|
||||
uint64_t mixins;
|
||||
uint64_t fee;
|
||||
uint64_t expiration_time;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
|
||||
KV_SERIALIZE(from)
|
||||
KV_SERIALIZE(to)
|
||||
KV_SERIALIZE(mixins)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(expiration_time)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct create_ionic_swap_proposal_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
ionic_swap_proposal_info proposal;
|
||||
std::string destination_add;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(proposal)
|
||||
KV_SERIALIZE(destination_add)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
typedef tools::wallet_public::asset_funds asset_funds;
|
||||
typedef tools::wallet_public::ionic_swap_proposal_info ionic_swap_proposal_info;
|
||||
typedef tools::wallet_public::create_ionic_swap_proposal_request create_ionic_swap_proposal_request;
|
||||
|
||||
struct address_validation_response
|
||||
{
|
||||
|
|
|
|||
|
|
@ -4880,7 +4880,7 @@ bool wallet2::check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& o
|
|||
return false;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::create_ionic_swap_proposal(const view::ionic_swap_proposal_info& proposal_details, const currency::account_public_address& destination_addr, transaction& tx_template)
|
||||
bool wallet2::create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal_details, const currency::account_public_address& destination_addr, currency::transaction& tx_template)
|
||||
{
|
||||
crypto::secret_key one_time_key = AUTO_VAL_INIT(one_time_key);
|
||||
std::vector<uint64_t> selected_transfers_for_template;
|
||||
|
|
@ -4892,7 +4892,7 @@ bool wallet2::create_ionic_swap_proposal(const view::ionic_swap_proposal_info& p
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::build_ionic_swap_template(const view::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
|
||||
bool wallet2::build_ionic_swap_template(const wallet_public::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
|
||||
currency::transaction& template_tx,
|
||||
std::vector<uint64_t>& selected_transfers,
|
||||
crypto::secret_key& one_time_key)
|
||||
|
|
@ -4939,7 +4939,7 @@ bool wallet2::build_ionic_swap_template(const view::ionic_swap_proposal_info& pr
|
|||
return true;
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::get_ionic_swap_proposal_info(const std::string&raw_tx_template, view::ionic_swap_proposal_info& proposal)
|
||||
bool wallet2::get_ionic_swap_proposal_info(const std::string&raw_tx_template, wallet_public::ionic_swap_proposal_info& proposal)
|
||||
{
|
||||
currency::transaction tx;
|
||||
bool r = parse_and_validate_tx_from_blob(raw_tx_template, tx);
|
||||
|
|
@ -4947,16 +4947,16 @@ bool wallet2::get_ionic_swap_proposal_info(const std::string&raw_tx_template, vi
|
|||
return get_ionic_swap_proposal_info(tx, proposal);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, view::ionic_swap_proposal_info& proposal)
|
||||
bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, wallet_public::ionic_swap_proposal_info& proposal)
|
||||
{
|
||||
crypto::key_derivation derivation = AUTO_VAL_INIT(derivation);
|
||||
std::vector<wallet_out_info> outs;
|
||||
uint64_t tx_money_got_in_outs = 0;
|
||||
r = lookup_acc_outs(m_account.get_keys(), tx, outs, tx_money_got_in_outs, derivation);
|
||||
bool r = lookup_acc_outs(m_account.get_keys(), tx, outs, tx_money_got_in_outs, derivation);
|
||||
THROW_IF_FALSE_WALLET_INT_ERR_EX(r, "Failed to lookup_acc_outs for tx: " << get_transaction_hash(tx));
|
||||
|
||||
std::unordered_map<crypto::public_key, uint64_t> ammounts_to;
|
||||
std::unordered_map<crypto::public_key, uint64_t> ammounts_from;
|
||||
std::unordered_map<crypto::hash, uint64_t> ammounts_to;
|
||||
std::unordered_map<crypto::hash, uint64_t> ammounts_from;
|
||||
std::vector<bool> third_party_outs;
|
||||
size_t i = 0;
|
||||
for (const auto& o : outs)
|
||||
|
|
@ -4971,7 +4971,7 @@ bool wallet2::get_ionic_swap_proposal_info(const currency::transaction tx, view:
|
|||
if (!third_party_outs[i])
|
||||
continue;
|
||||
|
||||
crypto::public_key asset_id = AUTO_VAL_INIT(asset_id);
|
||||
crypto::hash asset_id = AUTO_VAL_INIT(asset_id);
|
||||
uint64_t amount = 0;
|
||||
//TODO decode output info
|
||||
//get_amout_and_asset_id()
|
||||
|
|
@ -5022,10 +5022,10 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
|
|||
msc.tx_for_mode_separate = tx_template;
|
||||
|
||||
|
||||
r = get_ionic_swap_proposal_info(tx, msc.proposal);
|
||||
bool r = get_ionic_swap_proposal_info(tx_template, msc.proposal);
|
||||
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, "Failed to get info from proposal");
|
||||
|
||||
std::unordered_map<crypto::public_key, wallet_public::asset_balance_entry_base> balances;
|
||||
std::unordered_map<crypto::hash, wallet_public::asset_balance_entry_base> balances;
|
||||
uint64_t mined = 0;
|
||||
this->balance(balances, mined);
|
||||
//validate balances needed
|
||||
|
|
@ -5036,7 +5036,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
|
|||
{
|
||||
return false;
|
||||
}
|
||||
if (item.asset_id == currency::null_pkey)
|
||||
if (item.asset_id == currency::null_hash)
|
||||
{
|
||||
native_amount_required = item.amount;
|
||||
}
|
||||
|
|
@ -5047,7 +5047,7 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
|
|||
if (msc.proposal.fee < m_core_runtime_config.tx_default_fee)
|
||||
{
|
||||
additional_fee = m_core_runtime_config.tx_default_fee - msc.proposal.fee;
|
||||
if (balances[currency::null_pkey].unlocked < additional_fee + native_amount_required)
|
||||
if (balances[currency::null_hash].unlocked < additional_fee + native_amount_required)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
|
@ -5057,7 +5057,8 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
|
|||
|
||||
construct_tx_param construct_param = get_default_construct_tx_param();
|
||||
construct_param.fee = additional_fee;
|
||||
//crypto::secret_key one_time_key = contr_it->second.proposal.tx_onetime_secret_key;
|
||||
|
||||
assert(0); crypto::secret_key one_time_key = currency::null_skey; //TODO: add transfer of secrete onetime key to proposal
|
||||
construct_param.crypt_address = m_account.get_public_address();
|
||||
construct_param.flags = TX_FLAG_SIGNATURE_MODE_SEPARATE;
|
||||
construct_param.mark_tx_as_complete = true;
|
||||
|
|
@ -5066,17 +5067,18 @@ bool wallet2::accept_ionic_swap_proposal(const currency::transaction& tx_templat
|
|||
currency::finalize_tx_param ftp = AUTO_VAL_INIT(ftp);
|
||||
ftp.tx_version = this->get_current_tx_version();
|
||||
prepare_transaction(construct_param, ftp, msc);
|
||||
mark_transfers_as_spent(ftp.selected_transfers, std::string("contract <") + epee::string_tools::pod_to_hex(contract_id) + "> has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(tx)) + ">");
|
||||
|
||||
try
|
||||
{
|
||||
finalize_transaction(ftp, tx, one_time_key, true);
|
||||
finalize_transaction(ftp, result_tx, one_time_key, true);
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
clear_transfers_from_flag(ftp.selected_transfers, WALLET_TRANSFER_DETAIL_FLAG_SPENT, std::string("exception in finalize_transaction, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(tx)));
|
||||
clear_transfers_from_flag(ftp.selected_transfers, WALLET_TRANSFER_DETAIL_FLAG_SPENT, std::string("exception in finalize_transaction, tx: ") + epee::string_tools::pod_to_hex(get_transaction_hash(result_tx)));
|
||||
throw;
|
||||
}
|
||||
mark_transfers_as_spent(ftp.selected_transfers, std::string("Proposal has been accepted with tx <" + epee::string_tools::pod_to_hex(get_transaction_hash(result_tx))) + ">");
|
||||
|
||||
|
||||
return true;
|
||||
}
|
||||
|
|
@ -5093,7 +5095,7 @@ bool wallet2::sign_buffer(const std::string& buff, crypto::signature& sig)
|
|||
bool wallet2::validate_sign(const std::string& buff, const crypto::signature& sig, const crypto::public_key& pkey)
|
||||
{
|
||||
crypto::hash h = crypto::cn_fast_hash(buff.data(), buff.size());
|
||||
return crypto::check_signature(h, sig, pkey);
|
||||
return crypto::check_signature(h, pkey, sig);
|
||||
}
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
bool wallet2::encrypt_buffer(const std::string& buff, std::string& res_buff)
|
||||
|
|
|
|||
|
|
@ -129,7 +129,7 @@ namespace tools
|
|||
|
||||
//mw api
|
||||
virtual void on_mw_get_wallets(std::vector<wallet_public::wallet_entry_info>& wallets) {}
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id) {}
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id) { return true; }
|
||||
};
|
||||
|
||||
struct tx_dust_policy
|
||||
|
|
@ -550,7 +550,7 @@ namespace tools
|
|||
//i_wallet2_callback* callback() const { return m_wcallback; }
|
||||
//void callback(i_wallet2_callback* callback) { m_callback = callback; }
|
||||
void callback(std::shared_ptr<i_wallet2_callback> callback) { m_wcallback = callback; m_do_rise_transfer = (callback != nullptr); }
|
||||
i_wallet2_callback* get_callback() { return m_wcallback; }
|
||||
i_wallet2_callback* get_callback() { return m_wcallback.get(); }
|
||||
void set_do_rise_transfer(bool do_rise) { m_do_rise_transfer = do_rise; }
|
||||
|
||||
bool has_related_alias_entry_unconfirmed(const currency::transaction& tx);
|
||||
|
|
@ -928,13 +928,13 @@ namespace tools
|
|||
bool check_htlc_redeemed(const crypto::hash& htlc_tx_id, std::string& origin, crypto::hash& redeem_tx_id);
|
||||
|
||||
// ionic swaps:
|
||||
bool create_ionic_swap_proposal(const view::ionic_swap_proposal_info& proposal, const currency::account_public_address& destination_addr, transaction& tx_template);
|
||||
bool build_ionic_swap_template(const view::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
|
||||
bool create_ionic_swap_proposal(const wallet_public::ionic_swap_proposal_info& proposal, const currency::account_public_address& destination_addr, currency::transaction& tx_template);
|
||||
bool build_ionic_swap_template(const wallet_public::ionic_swap_proposal_info& proposal_detais, const currency::account_public_address& destination_addr,
|
||||
currency::transaction& template_tx,
|
||||
std::vector<uint64_t>& selected_transfers_for_template,
|
||||
crypto::secret_key& one_time_key);
|
||||
bool get_ionic_swap_proposal_info(const std::string&raw_tx_template, view::ionic_swap_proposal_info& proposal);
|
||||
bool get_ionic_swap_proposal_info(const currency::transaction tx, view::ionic_swap_proposal_info& proposal);
|
||||
bool get_ionic_swap_proposal_info(const std::string&raw_tx_template, wallet_public::ionic_swap_proposal_info& proposal);
|
||||
bool get_ionic_swap_proposal_info(const currency::transaction tx, wallet_public::ionic_swap_proposal_info& proposal);
|
||||
bool accept_ionic_swap_proposal(const std::string&raw_tx_template, currency::transaction& result_tx);
|
||||
bool accept_ionic_swap_proposal(const currency::transaction& tx_template, currency::transaction& result_tx);
|
||||
|
||||
|
|
|
|||
|
|
@ -17,6 +17,10 @@ public:
|
|||
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) {}
|
||||
virtual void on_tor_status_change(size_t wallet_id, const std::string& state) {}
|
||||
|
||||
virtual void on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets) {}
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id) { return true; }
|
||||
|
||||
};
|
||||
|
||||
struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
|
||||
|
|
@ -45,6 +49,16 @@ struct i_wallet_to_i_backend_adapter: public tools::i_wallet2_callback
|
|||
m_pbackend->on_tor_status_change(m_wallet_id, state);
|
||||
}
|
||||
|
||||
virtual void on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets)
|
||||
{
|
||||
m_pbackend->on_mw_get_wallets(wallets);
|
||||
}
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id)
|
||||
{
|
||||
return m_pbackend->on_mw_select_wallet(wallet_id);
|
||||
}
|
||||
|
||||
|
||||
private:
|
||||
i_backend_wallet_callback* m_pbackend;
|
||||
size_t m_wallet_id;
|
||||
|
|
|
|||
|
|
@ -1178,11 +1178,56 @@ namespace wallet_public
|
|||
};
|
||||
};
|
||||
|
||||
|
||||
|
||||
struct asset_funds
|
||||
{
|
||||
crypto::hash asset_id;
|
||||
uint64_t amount;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(asset_id)
|
||||
KV_SERIALIZE(amount)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct ionic_swap_proposal_info
|
||||
{
|
||||
std::vector<asset_funds> from;
|
||||
std::vector<asset_funds> to;
|
||||
uint64_t mixins;
|
||||
uint64_t fee;
|
||||
uint64_t expiration_time;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
|
||||
KV_SERIALIZE(from)
|
||||
KV_SERIALIZE(to)
|
||||
KV_SERIALIZE(mixins)
|
||||
KV_SERIALIZE(fee)
|
||||
KV_SERIALIZE(expiration_time)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
struct create_ionic_swap_proposal_request
|
||||
{
|
||||
uint64_t wallet_id;
|
||||
ionic_swap_proposal_info proposal;
|
||||
std::string destination_add;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallet_id)
|
||||
KV_SERIALIZE(proposal)
|
||||
KV_SERIALIZE(destination_add)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
|
||||
struct COMMAND_IONIC_SWAP_GENERATE_PROPOSAL
|
||||
{
|
||||
struct request
|
||||
{
|
||||
view::ionic_swap_proposal_info proposal;
|
||||
ionic_swap_proposal_info proposal;
|
||||
std::string destination_address;
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(proposal)
|
||||
|
|
@ -1215,7 +1260,7 @@ namespace wallet_public
|
|||
|
||||
struct response
|
||||
{
|
||||
view::ionic_swap_proposal_info proposal;
|
||||
ionic_swap_proposal_info proposal;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(proposal)
|
||||
|
|
@ -1291,7 +1336,7 @@ namespace wallet_public
|
|||
|
||||
struct response
|
||||
{
|
||||
std::vector<view::wallet_entry_info> wallets;
|
||||
std::vector<wallet_entry_info> wallets;
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(wallets)
|
||||
|
|
@ -1373,11 +1418,10 @@ namespace wallet_public
|
|||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(buff)
|
||||
END_KV_SERIALIZE_MAP()
|
||||
};
|
||||
|
||||
};
|
||||
|
||||
struct response
|
||||
{
|
||||
{
|
||||
std::string res_buff; //base64 encoded encrypted data
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(res_buff)
|
||||
|
|
|
|||
|
|
@ -56,16 +56,16 @@ namespace tools
|
|||
command_line::add_arg(desc, arg_deaf_mode);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
wallet_rpc_server::wallet_rpc_server(std::shared_ptr<wallet2*> wptr)
|
||||
wallet_rpc_server::wallet_rpc_server(std::shared_ptr<wallet2> wptr)
|
||||
: m_pwallet(wptr)
|
||||
, m_do_mint(false)
|
||||
, m_deaf(false)
|
||||
, m_last_wallet_store_height(0)
|
||||
{}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
std::shared_ptr<wallet2*> wallet_rpc_server::get_wallet()
|
||||
std::shared_ptr<wallet2> wallet_rpc_server::get_wallet()
|
||||
{
|
||||
return std::shared_ptr<wallet2*>(m_pwallet);
|
||||
return std::shared_ptr<wallet2>(m_pwallet);
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::run(bool do_mint, bool offline_mode, const currency::account_public_address& miner_address)
|
||||
|
|
@ -931,7 +931,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
currency::account_public_address destination_addr = AUTO_VAL_INIT(destination_addr);
|
||||
currency::payment_id_t integrated_payment_id;
|
||||
|
|
@ -960,7 +960,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::request& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
std::string raw_tx_template;
|
||||
bool r = epee::string_tools::parse_hexstr_to_binbuff(req.hex_raw_proposal, raw_tx_template);
|
||||
|
|
@ -980,7 +980,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
|
||||
std::string raw_tx_template;
|
||||
|
|
@ -1004,7 +1004,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_mw_get_wallets(const wallet_public::COMMAND_MW_GET_WALLETS& req, wallet_public::COMMAND_MW_GET_WALLETS::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_mw_get_wallets(const wallet_public::COMMAND_MW_GET_WALLETS::request& req, wallet_public::COMMAND_MW_GET_WALLETS::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
i_wallet2_callback* pcallback = get_wallet()->get_callback();
|
||||
if (!pcallback)
|
||||
|
|
@ -1017,7 +1017,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::on_mw_select_wallet(const wallet_public::COMMAND_MW_SELECT_WALLET& req, wallet_public::COMMAND_MW_SELECT_WALLET::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_mw_select_wallet(const wallet_public::COMMAND_MW_SELECT_WALLET::request& req, wallet_public::COMMAND_MW_SELECT_WALLET::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
i_wallet2_callback* pcallback = get_wallet()->get_callback();
|
||||
if (!pcallback)
|
||||
|
|
@ -1030,14 +1030,14 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool on_sign_message(const wallet_public::COMMAND_SIGN_MESSAGE& req, wallet_public::COMMAND_SIGN_MESSAGE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_sign_message(const wallet_public::COMMAND_SIGN_MESSAGE::request& req, wallet_public::COMMAND_SIGN_MESSAGE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
std::string buff = epee::string_encoding::base64_decode(req.buff);
|
||||
get_wallet()->sign_buffer(buff, res.sig);
|
||||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool on_validate_signature(const wallet_public::COMMAND_VALIDATE_SIGNATURE& req, wallet_public::COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_validate_signature(const wallet_public::COMMAND_VALIDATE_SIGNATURE::request& req, wallet_public::COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
std::string buff = epee::string_encoding::base64_decode(req.buff);
|
||||
bool r = get_wallet()->validate_sign(buff, req.sig, req.pkey);
|
||||
|
|
@ -1050,7 +1050,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool on_encrypt_data(const wallet_public::COMMAND_ENCRYPT_DATA& req, wallet_public::COMMAND_ENCRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_encrypt_data(const wallet_public::COMMAND_ENCRYPT_DATA::request& req, wallet_public::COMMAND_ENCRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
std::string buff = epee::string_encoding::base64_decode(req.buff);
|
||||
bool r = get_wallet()->encrypt_buffer(buff, res.res_buff);
|
||||
|
|
@ -1058,7 +1058,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool on_decrypt_data(const wallet_public::COMMAND_DECRYPT_DATA& req, wallet_public::COMMAND_DECRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
bool wallet_rpc_server::on_decrypt_data(const wallet_public::COMMAND_DECRYPT_DATA::request& req, wallet_public::COMMAND_DECRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx)
|
||||
{
|
||||
std::string buff = epee::string_encoding::base64_decode(req.buff);
|
||||
bool r = get_wallet()->encrypt_buffer(buff, res.res_buff);
|
||||
|
|
@ -1066,7 +1066,7 @@ namespace tools
|
|||
return true;
|
||||
}
|
||||
//------------------------------------------------------------------------------------------------------------------------------
|
||||
bool wallet_rpc_server::reset_active_wallet(std::shared_ptr<wallet2*> w)
|
||||
bool wallet_rpc_server::reset_active_wallet(std::shared_ptr<wallet2> w)
|
||||
{
|
||||
m_pwallet = w;
|
||||
return true;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ namespace tools
|
|||
public:
|
||||
typedef epee::net_utils::connection_context_base connection_context;
|
||||
|
||||
wallet_rpc_server(std::shared_ptr<wallet2*> wptr);
|
||||
wallet_rpc_server(std::shared_ptr<wallet2> wptr);
|
||||
|
||||
const static command_line::arg_descriptor<std::string> arg_rpc_bind_port;
|
||||
const static command_line::arg_descriptor<std::string> arg_rpc_bind_ip;
|
||||
|
|
@ -128,23 +128,23 @@ namespace tools
|
|||
bool on_redeem_htlc(const wallet_public::COMMAND_REDEEM_HTLC::request& req, wallet_public::COMMAND_REDEEM_HTLC::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_check_htlc_redeemed(const wallet_public::COMMAND_CHECK_HTLC_REDEEMED::request& req, wallet_public::COMMAND_CHECK_HTLC_REDEEMED::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
bool on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_ionic_swap_generate_proposal(const wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_GENERATE_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_ionic_swap_get_proposal_info(const wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::request& req, wallet_public::COMMAND_IONIC_SWAP_GET_PROPOSAL_INFO::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_ionic_swap_accept_proposal(const wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::request& req, wallet_public::COMMAND_IONIC_SWAP_ACCEPT_PROPOSAL::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
bool on_mw_get_wallets(const wallet_public::COMMAND_MW_GET_WALLETS& req, wallet_public::COMMAND_MW_GET_WALLETS::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_mw_select_wallet(const wallet_public::COMMAND_MW_SELECT_WALLET& req, wallet_public::COMMAND_MW_SELECT_WALLET::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_mw_get_wallets(const wallet_public::COMMAND_MW_GET_WALLETS::request& req, wallet_public::COMMAND_MW_GET_WALLETS::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_mw_select_wallet(const wallet_public::COMMAND_MW_SELECT_WALLET::request& req, wallet_public::COMMAND_MW_SELECT_WALLET::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
bool on_sign_message(const wallet_public::COMMAND_SIGN_MESSAGE& req, wallet_public::COMMAND_SIGN_MESSAGE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_validate_signature(const wallet_public::COMMAND_VALIDATE_SIGNATURE& req, wallet_public::COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_encrypt_data(const wallet_public::COMMAND_ENCRYPT_DATA& req, wallet_public::COMMAND_ENCRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_decrypt_data(const wallet_public::COMMAND_DECRYPT_DATA& req, wallet_public::COMMAND_DECRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_sign_message(const wallet_public::COMMAND_SIGN_MESSAGE::request& req, wallet_public::COMMAND_SIGN_MESSAGE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_validate_signature(const wallet_public::COMMAND_VALIDATE_SIGNATURE::request& req, wallet_public::COMMAND_VALIDATE_SIGNATURE::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_encrypt_data(const wallet_public::COMMAND_ENCRYPT_DATA::request& req, wallet_public::COMMAND_ENCRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
bool on_decrypt_data(const wallet_public::COMMAND_DECRYPT_DATA::request& req, wallet_public::COMMAND_DECRYPT_DATA::response& res, epee::json_rpc::error& er, connection_context& cntx);
|
||||
|
||||
|
||||
|
||||
std::shared_ptr<wallet2*> get_wallet();
|
||||
std::shared_ptr<wallet2> get_wallet();
|
||||
|
||||
bool reset_active_wallet(std::shared_ptr<wallet2*> w);
|
||||
bool reset_active_wallet(std::shared_ptr<wallet2> w);
|
||||
|
||||
bool handle_command_line(const boost::program_options::variables_map& vm);
|
||||
|
||||
|
|
|
|||
|
|
@ -780,7 +780,7 @@ void wallets_manager::init_wallet_entry(wallet_vs_options& wo, uint64_t id)
|
|||
wo.m_pproxy_diagnostig_info = m_rpc_proxy->get_proxy_diagnostic_info();
|
||||
wo.pview = m_pview;
|
||||
wo.has_related_alias_in_unconfirmed = false;
|
||||
wo.rpc_wrapper.reset(new tools::wallet_rpc_server(*wo.w.unlocked_get().get()));
|
||||
wo.rpc_wrapper.reset(new tools::wallet_rpc_server(wo.w.unlocked_get()));
|
||||
if (m_remote_node_mode)
|
||||
wo.core_conf = currency::get_default_core_runtime_config();
|
||||
else
|
||||
|
|
@ -854,23 +854,24 @@ std::string wallets_manager::get_fav_offers(const std::list<bc_services::offer_i
|
|||
#endif
|
||||
}
|
||||
|
||||
std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, const view::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex)
|
||||
std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, const tools::wallet_public::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
try {
|
||||
currency::account_public_address dest_account = AUTO_VAL_INIT(dest_account);
|
||||
if (!currency::get_account_address_from_str(proposal.destination_add))
|
||||
if (!currency::get_account_address_from_str(dest_account, proposal.destination_add))
|
||||
{
|
||||
return API_RETURN_CODE_BAD_ARG;
|
||||
}
|
||||
|
||||
bool r = wo.w->get()->create_ionic_swap_proposal(proposal, dest_account);
|
||||
currency::transaction tx_template = AUTO_VAL_INIT(tx_template);
|
||||
bool r = wo.w->get()->create_ionic_swap_proposal(proposal.proposal, dest_account, tx_template);
|
||||
if (!r)
|
||||
{
|
||||
return API_RETURN_CODE_FAIL;
|
||||
}
|
||||
else
|
||||
{
|
||||
result_proposal_hex = epee::string_tools::buff_to_hex_nodelimer(t_serializable_object_to_blob(tx_template));
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -879,11 +880,9 @@ std::string wallets_manager::create_ionic_swap_proposal(uint64_t wallet_id, cons
|
|||
return API_RETURN_CODE_FAIL;
|
||||
}
|
||||
return API_RETURN_CODE_OK;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, ionic_swap_proposal_info& proposal)
|
||||
std::string wallets_manager::get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, tools::wallet_public::ionic_swap_proposal_info& proposal)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
try {
|
||||
|
|
@ -906,7 +905,7 @@ std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_
|
|||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
|
||||
std::string wallets_manager::accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template, currency::transaction& result_tx)
|
||||
std::string wallets_manager::accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, currency::transaction& result_tx)
|
||||
{
|
||||
GET_WALLET_OPT_BY_ID(wallet_id, wo);
|
||||
try {
|
||||
|
|
@ -2002,7 +2001,7 @@ void wallets_manager::on_tor_status_change(size_t wallet_id, const std::string&
|
|||
m_pview->update_tor_status(tsu);
|
||||
}
|
||||
|
||||
void wallets_manager::on_mw_get_wallets(std::vector<wallet_public::wallet_entry_info>& wallets)
|
||||
void wallets_manager::on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets)
|
||||
{
|
||||
std::list<view::open_wallet_response> opened_wallets;
|
||||
this->get_opened_wallets(opened_wallets);
|
||||
|
|
@ -2022,7 +2021,8 @@ bool wallets_manager::on_mw_select_wallet(uint64_t wallet_id)
|
|||
if (it == m_wallets.end())
|
||||
return false;
|
||||
auto& wo = it->second;
|
||||
m_wallet_rpc_server.reset_active_wallet(wo.w);
|
||||
//m_wallet_rpc_server.reset_active_wallet(wo.w);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -136,8 +136,8 @@ public:
|
|||
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 create_ionic_swap_proposal(uint64_t wallet_id, const view::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex);
|
||||
std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, ionic_swap_proposal_info& proposal);
|
||||
std::string create_ionic_swap_proposal(uint64_t wallet_id, const tools::wallet_public::create_ionic_swap_proposal_request& proposal, std::string& result_proposal_hex);
|
||||
std::string get_ionic_swap_proposal_info(uint64_t wallet_id, std::string&raw_tx_template_hex, tools::wallet_public::ionic_swap_proposal_info& proposal);
|
||||
std::string accept_ionic_swap_proposal(uint64_t wallet_id, std::string&raw_tx_template_hex, currency::transaction& result_tx);
|
||||
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);
|
||||
|
|
@ -193,7 +193,7 @@ private:
|
|||
virtual void on_transfer_canceled(size_t wallet_id, const tools::wallet_public::wallet_transfer_info& wti);
|
||||
virtual void on_tor_status_change(size_t wallet_id, const std::string& state);
|
||||
|
||||
virtual void on_mw_get_wallets(std::vector<wallet_public::wallet_entry_info>& wallets) override;
|
||||
virtual void on_mw_get_wallets(std::vector<tools::wallet_public::wallet_entry_info>& wallets) override;
|
||||
virtual bool on_mw_select_wallet(uint64_t wallet_id) override;
|
||||
|
||||
//--------
|
||||
|
|
@ -228,7 +228,6 @@ private:
|
|||
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;
|
||||
tools::wallet_rpc_server m_wallet_rpc_server; //optional initialization
|
||||
#endif
|
||||
|
||||
bool m_remote_node_mode;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue