Merge pull request #5297

a8b98a0b wallet: fix memory only wallets (moneromooo-monero)
This commit is contained in:
Riccardo Spagni 2019-04-01 17:23:37 +02:00
commit f13d38350a
No known key found for this signature in database
GPG Key ID: 55432DF31CCD4FCD
2 changed files with 9 additions and 18 deletions

View File

@ -3539,6 +3539,7 @@ void wallet2::change_password(const std::string &filename, const epee::wipeable_
decrypt_keys(original_password);
setup_keys(new_password);
rewrite(filename, new_password);
if (!filename.empty())
store();
}
//----------------------------------------------------------------------------------------------------
@ -5228,6 +5229,7 @@ std::string wallet2::path() const
//----------------------------------------------------------------------------------------------------
void wallet2::store()
{
if (!m_wallet_file.empty())
store_to("", epee::wipeable_string());
}
//----------------------------------------------------------------------------------------------------

View File

@ -2936,7 +2936,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);
{
std::vector<std::string> languages;
crypto::ElectrumWords::get_language_list(languages);
@ -3221,12 +3221,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.viewkey.empty())
{
er.code = WALLET_RPC_ERROR_CODE_UNKNOWN_ERROR;
@ -3255,7 +3249,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())
{
@ -3365,6 +3359,7 @@ namespace tools
{
try
{
if (!wallet_file.empty())
m_wallet->store();
}
catch (const std::exception &e)
@ -3389,12 +3384,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;
@ -3417,7 +3406,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())
{