forked from lthn/blockchain
added more return codes to wallet
This commit is contained in:
parent
05e5174937
commit
4fcbe8fbdd
4 changed files with 20 additions and 3 deletions
|
|
@ -793,6 +793,7 @@ public:
|
|||
#define API_RETURN_CODE_OVERFLOW "OVERFLOW"
|
||||
#define API_RETURN_CODE_BUSY "BUSY"
|
||||
#define API_RETURN_CODE_INVALID_FILE "INVALID_FILE"
|
||||
#define API_RETURN_CODE_WRONG_SEED "WRONG_SEED"
|
||||
|
||||
#define API_MAX_ALIASES_COUNT 10000
|
||||
|
||||
|
|
|
|||
|
|
@ -2020,7 +2020,7 @@ void wallet2::restore(const std::wstring& path, const std::string& pass, const s
|
|||
m_password = pass;
|
||||
bool r = m_account.restore_keys_from_braindata(restore_key);
|
||||
init_log_prefix();
|
||||
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_internal_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
THROW_IF_TRUE_WALLET_EX(!r, error::wallet_wrong_seed_error, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
boost::system::error_code ignored_ec;
|
||||
THROW_IF_TRUE_WALLET_EX(boost::filesystem::exists(m_wallet_file, ignored_ec), error::file_exists, epee::string_encoding::convert_to_ansii(m_wallet_file));
|
||||
store();
|
||||
|
|
|
|||
|
|
@ -124,6 +124,14 @@ namespace tools
|
|||
}
|
||||
};
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
struct wallet_wrong_seed_error : public wallet_runtime_error
|
||||
{
|
||||
explicit wallet_wrong_seed_error(std::string&& loc, const std::string& message)
|
||||
: wallet_runtime_error(std::move(loc), message)
|
||||
{
|
||||
}
|
||||
};
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
struct wallet_common_error : public wallet_runtime_error
|
||||
{
|
||||
explicit wallet_common_error(std::string&& loc, const std::string& message)
|
||||
|
|
|
|||
|
|
@ -773,9 +773,13 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
|
|||
return_code = API_RETURN_CODE_FILE_RESTORED;
|
||||
break;
|
||||
}
|
||||
catch (const tools::error::invalid_password& )
|
||||
{
|
||||
return std::string(API_RETURN_CODE_WRONG_PASSWORD);
|
||||
}
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
return std::string(API_RETURN_CODE_WRONG_PASSWORD) + ":" + e.what();
|
||||
return std::string(API_RETURN_CODE_INTERNAL_ERROR) + ", DESCRIPTION: " + e.what();
|
||||
}
|
||||
}
|
||||
EXCLUSIVE_CRITICAL_REGION_LOCAL(m_wallets_lock);
|
||||
|
|
@ -929,7 +933,11 @@ std::string wallets_manager::restore_wallet(const std::wstring& path, const std:
|
|||
{
|
||||
return API_RETURN_CODE_ALREADY_EXISTS;
|
||||
}
|
||||
|
||||
catch (const tools::error::wallet_wrong_seed_error&)
|
||||
{
|
||||
return API_RETURN_CODE_WRONG_SEED;
|
||||
}
|
||||
|
||||
catch (const std::exception& e)
|
||||
{
|
||||
return std::string(API_RETURN_CODE_FAIL) + ":" + e.what();
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue