diff --git a/src/currency_core/currency_config.h b/src/currency_core/currency_config.h index 1b658a69..164170be 100644 --- a/src/currency_core/currency_config.h +++ b/src/currency_core/currency_config.h @@ -148,7 +148,9 @@ #define WALLET_FILE_SIGNATURE_OLD 0x1111012101101011LL // Bender's nightmare #define WALLET_FILE_SIGNATURE_V2 0x1111011201101011LL // another Bender's nightmare -#define WALLET_FILE_BINARY_HEADER_VERSION 1001 +#define WALLET_FILE_BINARY_HEADER_VERSION_INITAL 1000 +#define WALLET_FILE_BINARY_HEADER_VERSION_2 1001 +#define WALLET_FILE_BINARY_HEADER_VERSION_3 1002 #define WALLET_FILE_MAX_KEYS_SIZE 10000 // #define WALLET_BRAIN_DATE_OFFSET 1543622400 diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp index 81a68705..faa7f267 100644 --- a/src/wallet/wallet2.cpp +++ b/src/wallet/wallet2.cpp @@ -2664,11 +2664,19 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) load_keys(keys_buff, password, wbh.m_signature, kf_data); bool need_to_resync = false; - if (wbh.m_ver == 1000) + if (wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_INITAL) { need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, data_file); } - else + else if (wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_2) + { + tools::encrypt_chacha_in_filter decrypt_filter(password, kf_data.iv); + boost::iostreams::filtering_istream in; + in.push(decrypt_filter); + in.push(data_file); + need_to_resync = !tools::portable_unserialize_obj_from_stream(*this, in); + } + else if(wbh.m_ver == WALLET_FILE_BINARY_HEADER_VERSION_3) { tools::encrypt_chacha_in_filter decrypt_filter(password, kf_data.iv); boost::iostreams::filtering_istream in; @@ -2676,6 +2684,11 @@ void wallet2::load(const std::wstring& wallet_, const std::string& password) in.push(data_file); need_to_resync = !tools::portable_unserialize_obj_from_stream2(*this, in); } + else + { + WLT_LOG_L0("Unknown wallet body version(" << wbh.m_ver << "), resync initiated."); + need_to_resync = true; + } @@ -2729,7 +2742,7 @@ void wallet2::store(const std::wstring& path_to_save, const std::string& passwor wbh.m_signature = WALLET_FILE_SIGNATURE_V2; wbh.m_cb_keys = keys_buff.size(); //@#@ change it to proper - wbh.m_ver = WALLET_FILE_BINARY_HEADER_VERSION; + wbh.m_ver = WALLET_FILE_BINARY_HEADER_VERSION_3; std::string header_buff((const char*)&wbh, sizeof(wbh)); uint64_t ts = m_core_runtime_config.get_core_time();