aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorkenshi84 <kenshi84@protonmail.ch>2016-12-16 18:10:03 +0900
committerkenshi84 <kenshi84@protonmail.ch>2016-12-16 23:46:24 +0900
commit66e6af89ce413ed7bb9f427d64250c6cc4bc3120 (patch)
treedd9b808d9ac6cb0e6c46bcf1fbe4bbdfa082bbc2 /src/wallet
parentMerge pull request #1459 (diff)
downloadmonero-66e6af89ce413ed7bb9f427d64250c6cc4bc3120.tar.xz
added experimental boost::archive::portable_binary_{i|o}archive
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/CMakeLists.txt1
-rw-r--r--src/wallet/wallet2.cpp34
-rw-r--r--src/wallet/wallet2.h7
3 files changed, 31 insertions, 11 deletions
diff --git a/src/wallet/CMakeLists.txt b/src/wallet/CMakeLists.txt
index 056a1ca10..e34b7b579 100644
--- a/src/wallet/CMakeLists.txt
+++ b/src/wallet/CMakeLists.txt
@@ -73,6 +73,7 @@ target_link_libraries(wallet
cryptonote_core
mnemonics
p2p
+ boost_extra
${Boost_CHRONO_LIBRARY}
${Boost_SERIALIZATION_LIBRARY}
${Boost_FILESYSTEM_LIBRARY}
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index db4fae557..f22410563 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>
@@ -2313,16 +2311,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 + ".old", 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 + ".old", 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 ||
@@ -2396,7 +2416,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 c3381730b..9f4180c0d 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>
@@ -676,11 +675,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)
{