forked from lthn/blockchain
Fixed tracking seed restoring bug
This commit is contained in:
parent
20dd1cafc3
commit
2768732e23
4 changed files with 50 additions and 26 deletions
|
|
@ -226,6 +226,11 @@ namespace currency
|
|||
return true;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
bool account_base::is_seed_tracking(const std::string& seed_phrase)
|
||||
{
|
||||
return seed_phrase.find(':') != std::string::npos;
|
||||
}
|
||||
//-----------------------------------------------------------------
|
||||
bool account_base::is_seed_password_protected(const std::string& seed_phrase, bool& is_password_protected)
|
||||
{
|
||||
//cut the last timestamp word from restore_dats
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ namespace currency
|
|||
static std::string vector_of_chars_to_string(const std::vector<unsigned char>& v) { return std::string(v.begin(), v.end()); }
|
||||
static std::vector<unsigned char> string_to_vector_of_chars(const std::string& v) { return std::vector<unsigned char>(v.begin(), v.end()); }
|
||||
static bool is_seed_password_protected(const std::string& seed_phrase, bool& is_password_protected);
|
||||
static bool is_seed_tracking(const std::string& seed_phrase);
|
||||
|
||||
BEGIN_KV_SERIALIZE_MAP()
|
||||
KV_SERIALIZE(m_keys)
|
||||
|
|
|
|||
|
|
@ -27,27 +27,39 @@ namespace tools
|
|||
inline std::string get_seed_phrase_info(const std::string& seed_phrase, const std::string& seed_password, view::seed_phrase_info& result)
|
||||
{
|
||||
//cut the last timestamp word from restore_dats
|
||||
try{
|
||||
result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password);
|
||||
try
|
||||
{
|
||||
//restore_from_tracking_seed
|
||||
bool is_tracking = currency::account_base::is_seed_tracking(seed_phrase);
|
||||
if (is_tracking)
|
||||
{
|
||||
currency::account_base acc;
|
||||
result.require_password = false;
|
||||
result.hash_sum_matched = false;
|
||||
result.syntax_correct = acc.restore_from_tracking_seed(seed_phrase);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.syntax_correct = currency::account_base::is_seed_password_protected(seed_phrase, result.require_password);
|
||||
if (result.syntax_correct && result.require_password)
|
||||
{
|
||||
if (seed_password.size())
|
||||
{
|
||||
currency::account_base acc;
|
||||
result.hash_sum_matched = acc.restore_from_seed_phrase(seed_phrase, seed_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.hash_sum_matched = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
result.syntax_correct = false;
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
|
||||
if (result.syntax_correct && result.require_password)
|
||||
{
|
||||
if (seed_password.size())
|
||||
{
|
||||
currency::account_base acc;
|
||||
result.hash_sum_matched = acc.restore_from_seed_phrase(seed_phrase, seed_password);
|
||||
}
|
||||
else
|
||||
{
|
||||
result.hash_sum_matched = false;
|
||||
}
|
||||
}
|
||||
return API_RETURN_CODE_OK;
|
||||
}
|
||||
}
|
||||
|
|
@ -1060,16 +1060,22 @@ std::string wallets_manager::is_pos_allowed()
|
|||
}
|
||||
std::string wallets_manager::is_valid_brain_restore_data(const std::string& seed_phrase, const std::string& seed_password)
|
||||
{
|
||||
|
||||
currency::account_base acc;
|
||||
if (acc.restore_from_seed_phrase(seed_phrase, seed_password))
|
||||
return API_RETURN_CODE_TRUE;
|
||||
|
||||
currency::account_public_address addr;
|
||||
crypto::secret_key view_sec_key;
|
||||
uint64_t ts;
|
||||
if (currency::parse_tracking_seed(seed_phrase, addr, view_sec_key, ts))
|
||||
return API_RETURN_CODE_TRUE;
|
||||
if (!currency::account_base::is_seed_tracking(seed_phrase))
|
||||
{
|
||||
if (acc.restore_from_seed_phrase(seed_phrase, seed_password))
|
||||
return API_RETURN_CODE_TRUE;
|
||||
}
|
||||
else
|
||||
{
|
||||
currency::account_public_address addr = AUTO_VAL_INIT(addr);
|
||||
crypto::secret_key view_sec_key = AUTO_VAL_INIT(view_sec_key);
|
||||
uint64_t ts = 0;
|
||||
if (currency::parse_tracking_seed(seed_phrase, addr, view_sec_key, ts))
|
||||
return API_RETURN_CODE_TRUE;
|
||||
|
||||
}
|
||||
return API_RETURN_CODE_FALSE;
|
||||
}
|
||||
#ifndef MOBILE_WALLET_BUILD
|
||||
|
|
@ -1115,8 +1121,8 @@ std::string wallets_manager::restore_wallet(const std::wstring& path, const std:
|
|||
currency::account_base acc;
|
||||
try
|
||||
{
|
||||
bool auditable_watch_only = seed_phrase.find(':') != std::string::npos;
|
||||
w->restore(path, password, seed_phrase, auditable_watch_only, seed_password);
|
||||
bool is_tracking = currency::account_base::is_seed_tracking(seed_phrase);
|
||||
w->restore(path, password, seed_phrase, is_tracking, seed_password);
|
||||
//owr.seed = w->get_account().get_seed_phrase();
|
||||
}
|
||||
catch (const tools::error::file_exists&)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue