aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/common/boost_serialization_helper.h25
-rw-r--r--src/cryptonote_core/account.cpp2
-rw-r--r--src/cryptonote_core/blockchain.cpp34
-rw-r--r--src/cryptonote_core/blockchain.h7
-rw-r--r--src/cryptonote_core/cryptonote_boost_serialization.h9
-rw-r--r--src/daemon/command_parser_executor.cpp11
-rw-r--r--src/daemon/command_parser_executor.h2
-rw-r--r--src/daemon/command_server.cpp5
-rw-r--r--src/daemon/rpc_command_executor.cpp33
-rw-r--r--src/daemon/rpc_command_executor.h2
-rw-r--r--src/p2p/net_node.inl32
-rw-r--r--src/p2p/net_peerlist.h3
-rw-r--r--src/rpc/core_rpc_server.cpp18
-rw-r--r--src/rpc/core_rpc_server.h2
-rw-r--r--src/rpc/core_rpc_server_commands_defs.h35
-rw-r--r--src/simplewallet/simplewallet.cpp23
-rw-r--r--src/wallet/api/wallet_manager.cpp8
-rw-r--r--src/wallet/api/wallet_manager.h1
-rw-r--r--src/wallet/wallet2.cpp34
-rw-r--r--src/wallet/wallet2.h7
-rw-r--r--src/wallet/wallet2_api.h3
21 files changed, 260 insertions, 36 deletions
diff --git a/src/common/boost_serialization_helper.h b/src/common/boost_serialization_helper.h
index bf0023471..88dccbde7 100644
--- a/src/common/boost_serialization_helper.h
+++ b/src/common/boost_serialization_helper.h
@@ -30,8 +30,9 @@
#pragma once
-#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
+#include <boost/archive/portable_binary_oarchive.hpp>
+#include <boost/archive/portable_binary_iarchive.hpp>
namespace tools
@@ -75,7 +76,7 @@ namespace tools
return false;
#endif
- boost::archive::binary_oarchive a(data_file);
+ boost::archive::portable_binary_oarchive a(data_file);
a << obj;
if (data_file.fail())
return false;
@@ -99,9 +100,23 @@ namespace tools
data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
if(data_file.fail())
return false;
- boost::archive::binary_iarchive a(data_file);
-
- a >> obj;
+ try
+ {
+ // first try reading in portable mode
+ boost::archive::portable_binary_iarchive a(data_file);
+ a >> obj;
+ }
+ catch(...)
+ {
+ // if failed, try reading in unportable mode
+ boost::filesystem::copy_file(file_path, file_path + ".unportable", boost::filesystem::copy_option::overwrite_if_exists);
+ data_file.close();
+ data_file.open( file_path, std::ios_base::binary | std::ios_base::in);
+ if(data_file.fail())
+ return false;
+ boost::archive::binary_iarchive a(data_file);
+ a >> obj;
+ }
return !data_file.fail();
CATCH_ENTRY_L0("unserialize_obj_from_file", false);
}
diff --git a/src/cryptonote_core/account.cpp b/src/cryptonote_core/account.cpp
index c3f2b4446..89ad4184c 100644
--- a/src/cryptonote_core/account.cpp
+++ b/src/cryptonote_core/account.cpp
@@ -28,8 +28,6 @@
//
// Parts of this file are originally copyright (c) 2012-2013 The Cryptonote developers
-#include <boost/archive/binary_oarchive.hpp>
-#include <boost/archive/binary_iarchive.hpp>
#include <fstream>
#include "include_base_utils.h"
diff --git a/src/cryptonote_core/blockchain.cpp b/src/cryptonote_core/blockchain.cpp
index 70b2ccc79..a23d51126 100644
--- a/src/cryptonote_core/blockchain.cpp
+++ b/src/cryptonote_core/blockchain.cpp
@@ -30,8 +30,6 @@
#include <algorithm>
#include <cstdio>
-#include <boost/archive/binary_oarchive.hpp>
-#include <boost/archive/binary_iarchive.hpp>
#include <boost/filesystem.hpp>
#include "include_base_utils.h"
@@ -3880,6 +3878,38 @@ std::map<uint64_t, std::tuple<uint64_t, uint64_t, uint64_t>> Blockchain:: get_ou
return m_db->get_output_histogram(amounts, unlocked, recent_cutoff);
}
+std::list<std::pair<Blockchain::block_extended_info,uint64_t>> Blockchain::get_alternative_chains() const
+{
+ std::list<std::pair<Blockchain::block_extended_info,uint64_t>> chains;
+
+ for (const auto &i: m_alternative_chains)
+ {
+ const crypto::hash &top = i.first;
+ bool found = false;
+ for (const auto &j: m_alternative_chains)
+ {
+ if (j.second.bl.prev_id == top)
+ {
+ found = true;
+ break;
+ }
+ }
+ if (!found)
+ {
+ uint64_t length = 1;
+ auto h = i.second.bl.prev_id;
+ blocks_ext_by_hash::const_iterator prev;
+ while ((prev = m_alternative_chains.find(h)) != m_alternative_chains.end())
+ {
+ h = prev->second.bl.prev_id;
+ ++length;
+ }
+ chains.push_back(std::make_pair(i.second, length));
+ }
+ }
+ return chains;
+}
+
void Blockchain::cancel()
{
m_cancel = true;
diff --git a/src/cryptonote_core/blockchain.h b/src/cryptonote_core/blockchain.h
index 9afc22657..245dc6e73 100644
--- a/src/cryptonote_core/blockchain.h
+++ b/src/cryptonote_core/blockchain.h
@@ -844,6 +844,13 @@ namespace cryptonote
void block_longhash_worker(const uint64_t height, const std::vector<block> &blocks,
std::unordered_map<crypto::hash, crypto::hash> &map) const;
+ /**
+ * @brief returns a set of known alternate chains
+ *
+ * @return a list of chains
+ */
+ std::list<std::pair<block_extended_info,uint64_t>> get_alternative_chains() const;
+
void cancel();
private:
diff --git a/src/cryptonote_core/cryptonote_boost_serialization.h b/src/cryptonote_core/cryptonote_boost_serialization.h
index 663ef5070..7423b222a 100644
--- a/src/cryptonote_core/cryptonote_boost_serialization.h
+++ b/src/cryptonote_core/cryptonote_boost_serialization.h
@@ -38,7 +38,8 @@
#include <boost/foreach.hpp>
#include <boost/serialization/is_bitwise_serializable.hpp>
#include <boost/archive/binary_iarchive.hpp>
-#include <boost/archive/binary_oarchive.hpp>
+#include <boost/archive/portable_binary_iarchive.hpp>
+#include <boost/archive/portable_binary_oarchive.hpp>
#include "cryptonote_basic.h"
#include "common/unordered_containers_boost_serialization.h"
#include "crypto/crypto.h"
@@ -230,7 +231,8 @@ namespace boost
// a & x.senderPk; // not serialized, as we do not use it in monero currently
}
- inline void serializeOutPk(boost::archive::binary_iarchive &a, rct::ctkeyV &outPk_, const boost::serialization::version_type ver)
+ template <class Archive>
+ inline typename std::enable_if<Archive::is_loading::value, void>::type serializeOutPk(Archive &a, rct::ctkeyV &outPk_, const boost::serialization::version_type ver)
{
rct::keyV outPk;
a & outPk;
@@ -242,7 +244,8 @@ namespace boost
}
}
- inline void serializeOutPk(boost::archive::binary_oarchive &a, rct::ctkeyV &outPk_, const boost::serialization::version_type ver)
+ template <class Archive>
+ inline typename std::enable_if<Archive::is_saving::value, void>::type serializeOutPk(Archive &a, rct::ctkeyV &outPk_, const boost::serialization::version_type ver)
{
rct::keyV outPk(outPk_.size());
for (size_t n = 0; n < outPk_.size(); ++n)
diff --git a/src/daemon/command_parser_executor.cpp b/src/daemon/command_parser_executor.cpp
index 88b77f76d..f07ef1616 100644
--- a/src/daemon/command_parser_executor.cpp
+++ b/src/daemon/command_parser_executor.cpp
@@ -482,4 +482,15 @@ bool t_command_parser_executor::print_coinbase_tx_sum(const std::vector<std::str
return m_executor.print_coinbase_tx_sum(height, count);
}
+bool t_command_parser_executor::alt_chain_info(const std::vector<std::string>& args)
+{
+ if(args.size())
+ {
+ std::cout << "No parameters allowed" << std::endl;
+ return false;
+ }
+
+ return m_executor.alt_chain_info();
+}
+
} // namespace daemonize
diff --git a/src/daemon/command_parser_executor.h b/src/daemon/command_parser_executor.h
index 93b1fab56..cc929db00 100644
--- a/src/daemon/command_parser_executor.h
+++ b/src/daemon/command_parser_executor.h
@@ -119,6 +119,8 @@ public:
bool output_histogram(const std::vector<std::string>& args);
bool print_coinbase_tx_sum(const std::vector<std::string>& args);
+
+ bool alt_chain_info(const std::vector<std::string>& args);
};
} // namespace daemonize
diff --git a/src/daemon/command_server.cpp b/src/daemon/command_server.cpp
index 729b19cbf..88c49d111 100644
--- a/src/daemon/command_server.cpp
+++ b/src/daemon/command_server.cpp
@@ -225,6 +225,11 @@ t_command_server::t_command_server(
, std::bind(&t_command_parser_executor::print_coinbase_tx_sum, &m_parser, p::_1)
, "Print sum of coinbase transactions (start height, block count)"
);
+ m_command_lookup.set_handler(
+ "alt_chain_info"
+ , std::bind(&t_command_parser_executor::alt_chain_info, &m_parser, p::_1)
+ , "Print information about alternative chains"
+ );
}
bool t_command_server::process_command_str(const std::string& cmd)
diff --git a/src/daemon/rpc_command_executor.cpp b/src/daemon/rpc_command_executor.cpp
index 65b42cc47..41b1fad24 100644
--- a/src/daemon/rpc_command_executor.cpp
+++ b/src/daemon/rpc_command_executor.cpp
@@ -1367,5 +1367,38 @@ bool t_rpc_command_executor::print_coinbase_tx_sum(uint64_t height, uint64_t cou
return true;
}
+bool t_rpc_command_executor::alt_chain_info()
+{
+ cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::request req;
+ cryptonote::COMMAND_RPC_GET_ALTERNATE_CHAINS::response res;
+ epee::json_rpc::error error_resp;
+
+ std::string fail_message = "Unsuccessful";
+
+ if (m_is_rpc)
+ {
+ if (!m_rpc_client->json_rpc_request(req, res, "get_alternate_chains", fail_message.c_str()))
+ {
+ return true;
+ }
+ }
+ else
+ {
+ if (!m_rpc_server->on_get_alternate_chains(req, res, error_resp))
+ {
+ tools::fail_msg_writer() << fail_message.c_str();
+ return true;
+ }
+ }
+
+ tools::msg_writer() << boost::lexical_cast<std::string>(res.chains.size()) << " alternate chains found:";
+ for (const auto chain: res.chains)
+ {
+ tools::msg_writer() << chain.length << " blocks long, branching at height " << (chain.height - chain.length + 1)
+ << ", difficulty " << chain.difficulty << ": " << chain.block_hash;
+ }
+ return true;
+}
+
}// namespace daemonize
diff --git a/src/daemon/rpc_command_executor.h b/src/daemon/rpc_command_executor.h
index c1c99155b..a6c712c04 100644
--- a/src/daemon/rpc_command_executor.h
+++ b/src/daemon/rpc_command_executor.h
@@ -137,6 +137,8 @@ public:
bool output_histogram(uint64_t min_count, uint64_t max_count);
bool print_coinbase_tx_sum(uint64_t height, uint64_t count);
+
+ bool alt_chain_info();
};
} // namespace daemonize
diff --git a/src/p2p/net_node.inl b/src/p2p/net_node.inl
index 442c42517..f32e7a435 100644
--- a/src/p2p/net_node.inl
+++ b/src/p2p/net_node.inl
@@ -137,14 +137,34 @@ namespace nodetool
{
try
{
- boost::archive::binary_iarchive a(p2p_data);
+ // first try reading in portable mode
+ boost::archive::portable_binary_iarchive a(p2p_data);
a >> *this;
}
- catch (const std::exception &e)
+ catch (...)
{
- LOG_ERROR("Failed to load p2p config file, falling back to default config");
- m_peerlist = peerlist_manager(); // it was probably half clobbered by the failed load
- make_default_config();
+ // if failed, try reading in unportable mode
+ boost::filesystem::copy_file(state_file_path, state_file_path + ".unportable", boost::filesystem::copy_option::overwrite_if_exists);
+ p2p_data.close();
+ p2p_data.open( state_file_path , std::ios_base::binary | std::ios_base::in);
+ if(!p2p_data.fail())
+ {
+ try
+ {
+ boost::archive::binary_iarchive a(p2p_data);
+ a >> *this;
+ }
+ catch (const std::exception &e)
+ {
+ LOG_ERROR("Failed to load p2p config file, falling back to default config");
+ m_peerlist = peerlist_manager(); // it was probably half clobbered by the failed load
+ make_default_config();
+ }
+ }
+ else
+ {
+ make_default_config();
+ }
}
}else
{
@@ -645,7 +665,7 @@ namespace nodetool
return false;
};
- boost::archive::binary_oarchive a(p2p_data);
+ boost::archive::portable_binary_oarchive a(p2p_data);
a << *this;
return true;
CATCH_ENTRY_L0("blockchain_storage::save", false);
diff --git a/src/p2p/net_peerlist.h b/src/p2p/net_peerlist.h
index c19ecf65f..fa69abd6e 100644
--- a/src/p2p/net_peerlist.h
+++ b/src/p2p/net_peerlist.h
@@ -36,8 +36,9 @@
#include <boost/foreach.hpp>
//#include <boost/bimap.hpp>
//#include <boost/bimap/multiset_of.hpp>
-#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
+#include <boost/archive/portable_binary_oarchive.hpp>
+#include <boost/archive/portable_binary_iarchive.hpp>
#include <boost/serialization/version.hpp>
#include <boost/multi_index_container.hpp>
diff --git a/src/rpc/core_rpc_server.cpp b/src/rpc/core_rpc_server.cpp
index 5bf500733..c2ff63fc7 100644
--- a/src/rpc/core_rpc_server.cpp
+++ b/src/rpc/core_rpc_server.cpp
@@ -1337,6 +1337,24 @@ namespace cryptonote
return true;
}
//------------------------------------------------------------------------------------------------------------------------------
+ bool core_rpc_server::on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp)
+ {
+ try
+ {
+ std::list<std::pair<Blockchain::block_extended_info, uint64_t>> chains = m_core.get_blockchain_storage().get_alternative_chains();
+ for (const auto &i: chains)
+ {
+ res.chains.push_back(COMMAND_RPC_GET_ALTERNATE_CHAINS::chain_info{epee::string_tools::pod_to_hex(get_block_hash(i.first.bl)), i.first.height, i.second, i.first.cumulative_difficulty});
+ }
+ res.status = CORE_RPC_STATUS_OK;
+ }
+ catch (...)
+ {
+ res.status = "Error retrieving alternate chains";
+ }
+ return true;
+ }
+ //------------------------------------------------------------------------------------------------------------------------------
bool core_rpc_server::on_out_peers(const COMMAND_RPC_OUT_PEERS::request& req, COMMAND_RPC_OUT_PEERS::response& res)
{
// TODO
diff --git a/src/rpc/core_rpc_server.h b/src/rpc/core_rpc_server.h
index b7f6cdd60..0c0668f3b 100644
--- a/src/rpc/core_rpc_server.h
+++ b/src/rpc/core_rpc_server.h
@@ -118,6 +118,7 @@ namespace cryptonote
MAP_JON_RPC_WE("get_version", on_get_version, COMMAND_RPC_GET_VERSION)
MAP_JON_RPC_WE("get_coinbase_tx_sum", on_get_coinbase_tx_sum, COMMAND_RPC_GET_COINBASE_TX_SUM)
MAP_JON_RPC_WE("get_fee_estimate", on_get_per_kb_fee_estimate, COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE)
+ MAP_JON_RPC_WE_IF("get_alternate_chains",on_get_alternate_chains, COMMAND_RPC_GET_ALTERNATE_CHAINS, !m_restricted)
END_JSON_RPC_MAP()
END_URI_MAP2()
@@ -166,6 +167,7 @@ namespace cryptonote
bool on_get_version(const COMMAND_RPC_GET_VERSION::request& req, COMMAND_RPC_GET_VERSION::response& res, epee::json_rpc::error& error_resp);
bool on_get_coinbase_tx_sum(const COMMAND_RPC_GET_COINBASE_TX_SUM::request& req, COMMAND_RPC_GET_COINBASE_TX_SUM::response& res, epee::json_rpc::error& error_resp);
bool on_get_per_kb_fee_estimate(const COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::request& req, COMMAND_RPC_GET_PER_KB_FEE_ESTIMATE::response& res, epee::json_rpc::error& error_resp);
+ bool on_get_alternate_chains(const COMMAND_RPC_GET_ALTERNATE_CHAINS::request& req, COMMAND_RPC_GET_ALTERNATE_CHAINS::response& res, epee::json_rpc::error& error_resp);
//-----------------------
private:
diff --git a/src/rpc/core_rpc_server_commands_defs.h b/src/rpc/core_rpc_server_commands_defs.h
index 23fcb0a92..b09cad235 100644
--- a/src/rpc/core_rpc_server_commands_defs.h
+++ b/src/rpc/core_rpc_server_commands_defs.h
@@ -1336,4 +1336,39 @@ namespace cryptonote
END_KV_SERIALIZE_MAP()
};
};
+
+ struct COMMAND_RPC_GET_ALTERNATE_CHAINS
+ {
+ struct request
+ {
+ BEGIN_KV_SERIALIZE_MAP()
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct chain_info
+ {
+ std::string block_hash;
+ uint64_t height;
+ uint64_t length;
+ uint64_t difficulty;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(block_hash)
+ KV_SERIALIZE(height)
+ KV_SERIALIZE(length)
+ KV_SERIALIZE(difficulty)
+ END_KV_SERIALIZE_MAP()
+ };
+
+ struct response
+ {
+ std::string status;
+ std::list<chain_info> chains;
+
+ BEGIN_KV_SERIALIZE_MAP()
+ KV_SERIALIZE(status)
+ KV_SERIALIZE(chains)
+ END_KV_SERIALIZE_MAP()
+ };
+ };
}
diff --git a/src/simplewallet/simplewallet.cpp b/src/simplewallet/simplewallet.cpp
index 793a93e22..1f6afe2db 100644
--- a/src/simplewallet/simplewallet.cpp
+++ b/src/simplewallet/simplewallet.cpp
@@ -572,7 +572,7 @@ simple_wallet::simple_wallet()
m_cmd_binder.set_handler("rescan_spent", boost::bind(&simple_wallet::rescan_spent, this, _1), tr("Rescan blockchain for spent outputs"));
m_cmd_binder.set_handler("get_tx_key", boost::bind(&simple_wallet::get_tx_key, this, _1), tr("Get transaction key (r) for a given <txid>"));
m_cmd_binder.set_handler("check_tx_key", boost::bind(&simple_wallet::check_tx_key, this, _1), tr("Check amount going to <address> in <txid>"));
- m_cmd_binder.set_handler("show_transfers", boost::bind(&simple_wallet::show_transfers, this, _1), tr("show_transfers [in|out] [<min_height> [<max_height>]] - Show incoming/outgoing transfers within an optional height range"));
+ m_cmd_binder.set_handler("show_transfers", boost::bind(&simple_wallet::show_transfers, this, _1), tr("show_transfers [in|out|pending|failed|pool] [<min_height> [<max_height>]] - Show incoming/outgoing transfers within an optional height range"));
m_cmd_binder.set_handler("rescan_bc", boost::bind(&simple_wallet::rescan_blockchain, this, _1), tr("Rescan blockchain from scratch"));
m_cmd_binder.set_handler("set_tx_note", boost::bind(&simple_wallet::set_tx_note, this, _1), tr("Set an arbitrary string note for a txid"));
m_cmd_binder.set_handler("get_tx_note", boost::bind(&simple_wallet::get_tx_note, this, _1), tr("Get a string note for a txid"));
@@ -2729,7 +2729,8 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
return true;
}
std::string mixin_str;
- std::string address_str = "donate.getmonero.org";
+ // Hardcode Monero's donation address (see #1447)
+ const std::string address_str = "44AFFq5kSiGBoZ4NMDwYtN18obc8AemS33DBLWs3H7otXft3XjrpDtQGv7SqSsaBYBb98uNbr2VBBEt7f2wfn3RVGQBEP3A";
std::string amount_str;
std::string payment_id_str;
// check payment id
@@ -2757,6 +2758,7 @@ bool simple_wallet::donate(const std::vector<std::string> &args_)
if (!payment_id_str.empty())
local_args.push_back(payment_id_str);
transfer_new(local_args);
+ return true;
}
//----------------------------------------------------------------------------------------------------
bool simple_wallet::accept_loaded_tx(const std::function<size_t()> get_num_txes, const std::function<const tools::wallet2::tx_construction_data&(size_t)> &get_tx, const std::string &extra_message)
@@ -3775,7 +3777,7 @@ bool simple_wallet::export_outputs(const std::vector<std::string> &args)
std::vector<tools::wallet2::transfer_details> outs = m_wallet->export_outputs();
std::stringstream oss;
- boost::archive::binary_oarchive ar(oss);
+ boost::archive::portable_binary_oarchive ar(oss);
ar << outs;
std::string magic(OUTPUT_EXPORT_FILE_MAGIC, strlen(OUTPUT_EXPORT_FILE_MAGIC));
@@ -3855,10 +3857,19 @@ bool simple_wallet::import_outputs(const std::vector<std::string> &args)
std::string body(data, headerlen);
std::stringstream iss;
iss << body;
- boost::archive::binary_iarchive ar(iss);
std::vector<tools::wallet2::transfer_details> outputs;
- ar >> outputs;
-
+ try
+ {
+ boost::archive::portable_binary_iarchive ar(iss);
+ ar >> outputs;
+ }
+ catch (...)
+ {
+ iss.str("");
+ iss << body;
+ boost::archive::binary_iarchive ar(iss);
+ ar >> outputs;
+ }
size_t n_outputs = m_wallet->import_outputs(outputs);
success_msg_writer() << boost::lexical_cast<std::string>(n_outputs) << " outputs imported";
}
diff --git a/src/wallet/api/wallet_manager.cpp b/src/wallet/api/wallet_manager.cpp
index 5a6f02b01..4ee5ab8df 100644
--- a/src/wallet/api/wallet_manager.cpp
+++ b/src/wallet/api/wallet_manager.cpp
@@ -352,6 +352,14 @@ double WalletManagerImpl::miningHashRate() const
return mres.speed;
}
+std::string WalletManagerImpl::resolveOpenAlias(const std::string &address, bool &dnssec_valid) const
+{
+ std::vector<std::string> addresses = tools::wallet2::addresses_from_url(address, dnssec_valid);
+ if (addresses.empty())
+ return "";
+ return addresses.front();
+}
+
///////////////////// WalletManagerFactory implementation //////////////////////
WalletManager *WalletManagerFactory::getWalletManager()
diff --git a/src/wallet/api/wallet_manager.h b/src/wallet/api/wallet_manager.h
index fe9662534..214afc3fa 100644
--- a/src/wallet/api/wallet_manager.h
+++ b/src/wallet/api/wallet_manager.h
@@ -52,6 +52,7 @@ public:
uint64_t blockchainTargetHeight() const;
uint64_t networkDifficulty() const;
double miningHashRate() const;
+ std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const;
private:
WalletManagerImpl() {}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 712f08adc..ed488b50c 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -30,8 +30,6 @@
#include <random>
#include <tuple>
-#include <boost/archive/binary_oarchive.hpp>
-#include <boost/archive/binary_iarchive.hpp>
#include <boost/format.hpp>
#include <boost/optional/optional.hpp>
#include <boost/utility/value_init.hpp>
@@ -2314,16 +2312,38 @@ void wallet2::load(const std::string& wallet_, const std::string& password)
std::stringstream iss;
iss << cache_data;
- boost::archive::binary_iarchive ar(iss);
- ar >> *this;
+ try {
+ boost::archive::portable_binary_iarchive ar(iss);
+ ar >> *this;
+ }
+ catch (...)
+ {
+ LOG_PRINT_L0("Failed to open portable binary, trying unportable");
+ boost::filesystem::copy_file(m_wallet_file, m_wallet_file + ".unportable", boost::filesystem::copy_option::overwrite_if_exists);
+ iss.str("");
+ iss << cache_data;
+ boost::archive::binary_iarchive ar(iss);
+ ar >> *this;
+ }
}
catch (...)
{
LOG_PRINT_L1("Failed to load encrypted cache, trying unencrypted");
std::stringstream iss;
iss << buf;
- boost::archive::binary_iarchive ar(iss);
- ar >> *this;
+ try {
+ boost::archive::portable_binary_iarchive ar(iss);
+ ar >> *this;
+ }
+ catch (...)
+ {
+ LOG_PRINT_L0("Failed to open portable binary, trying unportable");
+ boost::filesystem::copy_file(m_wallet_file, m_wallet_file + ".unportable", boost::filesystem::copy_option::overwrite_if_exists);
+ iss.str("");
+ iss << buf;
+ boost::archive::binary_iarchive ar(iss);
+ ar >> *this;
+ }
}
THROW_WALLET_EXCEPTION_IF(
m_account_public_address.m_spend_public_key != m_account.get_keys().m_account_address.m_spend_public_key ||
@@ -2397,7 +2417,7 @@ void wallet2::store_to(const std::string &path, const std::string &password)
}
// preparing wallet data
std::stringstream oss;
- boost::archive::binary_oarchive ar(oss);
+ boost::archive::portable_binary_oarchive ar(oss);
ar << *this;
wallet2::cache_file_data cache_file_data = boost::value_initialized<wallet2::cache_file_data>();
diff --git a/src/wallet/wallet2.h b/src/wallet/wallet2.h
index 40c339e67..54e26008b 100644
--- a/src/wallet/wallet2.h
+++ b/src/wallet/wallet2.h
@@ -31,7 +31,6 @@
#pragma once
#include <memory>
-#include <boost/archive/binary_iarchive.hpp>
#include <boost/program_options/options_description.hpp>
#include <boost/program_options/variables_map.hpp>
@@ -679,11 +678,11 @@ namespace boost
namespace serialization
{
template <class Archive>
- inline void initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
+ inline typename std::enable_if<!Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
{
}
- template<>
- inline void initialize_transfer_details(boost::archive::binary_iarchive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
+ template <class Archive>
+ inline typename std::enable_if<Archive::is_loading::value, void>::type initialize_transfer_details(Archive &a, tools::wallet2::transfer_details &x, const boost::serialization::version_type ver)
{
if (ver < 1)
{
diff --git a/src/wallet/wallet2_api.h b/src/wallet/wallet2_api.h
index 6651b876d..2e1d95b58 100644
--- a/src/wallet/wallet2_api.h
+++ b/src/wallet/wallet2_api.h
@@ -561,6 +561,9 @@ struct WalletManager
//! returns current mining hash rate (0 if not mining)
virtual double miningHashRate() const = 0;
+
+ //! resolves an OpenAlias address to a monero address
+ virtual std::string resolveOpenAlias(const std::string &address, bool &dnssec_valid) const = 0;
};