forked from lthn/blockchain
added new portable storage
This commit is contained in:
parent
569d64b5f2
commit
c8c2414fd3
2 changed files with 19 additions and 4 deletions
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue