Skip to content

Commit

Permalink
wallet: fix memory only wallets
Browse files Browse the repository at this point in the history
at least when using restore_deterministic_wallet
  • Loading branch information
moneromooo-monero committed Mar 17, 2019
1 parent ea07a9b commit ad18427
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 11 deletions.
6 changes: 4 additions & 2 deletions src/wallet/wallet2.cpp
Expand Up @@ -3460,7 +3460,8 @@ void wallet2::change_password(const std::string &filename, const epee::wipeable_
decrypt_keys(original_password);
setup_keys(new_password);
rewrite(filename, new_password);
store();
if (!filename.empty())
store();
}
//----------------------------------------------------------------------------------------------------
/*!
Expand Down Expand Up @@ -5142,7 +5143,8 @@ std::string wallet2::path() const
//----------------------------------------------------------------------------------------------------
void wallet2::store()
{
store_to("", epee::wipeable_string());
if (!m_wallet_file.empty())
store_to("", epee::wipeable_string());
}
//----------------------------------------------------------------------------------------------------
void wallet2::store_to(const std::string &path, const epee::wipeable_string &password)
Expand Down
13 changes: 4 additions & 9 deletions src/wallet/wallet_rpc_server.cpp
Expand Up @@ -3221,7 +3221,7 @@ namespace tools
er.message = "Invalid filename";
return false;
}
std::string wallet_file = m_wallet_dir + "/" + req.filename;
std::string wallet_file = req.filename.empty() ? "" : (m_wallet_dir + "/" + req.filename);
// check if wallet file already exists
if (!wallet_file.empty())
{
Expand Down Expand Up @@ -3331,7 +3331,8 @@ namespace tools
{
try
{
m_wallet->store();
if (!wallet_file.empty())
m_wallet->store();
}
catch (const std::exception &e)
{
Expand All @@ -3355,12 +3356,6 @@ namespace tools
}

// early check for mandatory fields
if (req.filename.empty())
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
er.message = "field 'filename' is mandatory. Please provide a filename to save the restored wallet to.";
return false;
}
if (req.seed.empty())
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
Expand All @@ -3383,7 +3378,7 @@ namespace tools
er.message = "Invalid filename";
return false;
}
std::string wallet_file = m_wallet_dir + "/" + req.filename;
std::string wallet_file = req.filename.empty() ? "" : (m_wallet_dir + "/" + req.filename);
// check if wallet file already exists
if (!wallet_file.empty())
{
Expand Down

0 comments on commit ad18427

Please sign in to comment.