1
0
Fork 0
forked from lthn/blockchain

Added error on opening same wallet file

This commit is contained in:
cryptozoidberg 2020-05-12 21:11:54 +02:00
parent 6b2832fbcf
commit e6616cd225
No known key found for this signature in database
GPG key ID: 22DEB97A54C6FDEC
2 changed files with 13 additions and 1 deletions

View file

@ -705,7 +705,8 @@ namespace epee
#define EXCLUSIVE_CRITICAL_REGION_LOCAL(x) boost::unique_lock< boost::shared_mutex > critical_region_var(x)
#define SHARED_CRITICAL_REGION_BEGIN(x) { SHARED_CRITICAL_REGION_LOCAL(x)
#define SHARED_CRITICAL_REGION_END() }
#define EXCLUSIVE_CRITICAL_REGION_BEGIN(x) { EXCLUSIVE_CRITICAL_REGION_LOCAL(x)
#define EXCLUSIVE_CRITICAL_REGION_END() }
}

View file

@ -732,6 +732,16 @@ std::string wallets_manager::get_my_offers(const bc_services::core_offers_filter
std::string wallets_manager::open_wallet(const std::wstring& path, const std::string& password, uint64_t txs_to_return, view::open_wallet_response& owr)
{
// check if that file already opened
SHARED_CRITICAL_REGION_BEGIN(m_wallets_lock);
for (auto& wallet_entry : m_wallets)
{
if (wallet_entry.second.w.unlocked_get()->get_wallet_path() == path)
return API_RETURN_CODE_ALREADY_EXISTS;
}
SHARED_CRITICAL_REGION_END();
std::shared_ptr<tools::wallet2> w(new tools::wallet2());
owr.wallet_id = m_wallet_id_counter++;
@ -784,6 +794,7 @@ std::string wallets_manager::open_wallet(const std::wstring& path, const std::st
}
}
EXCLUSIVE_CRITICAL_REGION_LOCAL(m_wallets_lock);
wallet_vs_options& wo = m_wallets[owr.wallet_id];
**wo.w = w;
get_wallet_info(wo, owr.wi);