aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/wallet2.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wallet/wallet2.cpp')
-rw-r--r--src/wallet/wallet2.cpp9
1 files changed, 4 insertions, 5 deletions
diff --git a/src/wallet/wallet2.cpp b/src/wallet/wallet2.cpp
index 920e0413c..91b3c0535 100644
--- a/src/wallet/wallet2.cpp
+++ b/src/wallet/wallet2.cpp
@@ -3788,7 +3788,7 @@ bool wallet2::store_keys(const std::string& keys_file_name, const epee::wipeable
//----------------------------------------------------------------------------------------------------
boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee::wipeable_string& password, bool watch_only)
{
- std::string account_data;
+ epee::byte_slice account_data;
std::string multisig_signers;
std::string multisig_derivations;
cryptonote::account_base account = m_account;
@@ -3815,7 +3815,7 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
rapidjson::Document json;
json.SetObject();
rapidjson::Value value(rapidjson::kStringType);
- value.SetString(account_data.c_str(), account_data.length());
+ value.SetString(reinterpret_cast<const char*>(account_data.data()), account_data.size());
json.AddMember("key_data", value, json.GetAllocator());
if (!seed_language.empty())
{
@@ -3989,13 +3989,12 @@ boost::optional<wallet2::keys_file_data> wallet2::get_keys_file_data(const epee:
rapidjson::StringBuffer buffer;
rapidjson::Writer<rapidjson::StringBuffer> writer(buffer);
json.Accept(writer);
- account_data = buffer.GetString();
// Encrypt the entire JSON object.
std::string cipher;
- cipher.resize(account_data.size());
+ cipher.resize(buffer.GetSize());
keys_file_data.get().iv = crypto::rand<crypto::chacha_iv>();
- crypto::chacha20(account_data.data(), account_data.size(), key, keys_file_data.get().iv, &cipher[0]);
+ crypto::chacha20(buffer.GetString(), buffer.GetSize(), key, keys_file_data.get().iv, &cipher[0]);
keys_file_data.get().account_data = cipher;
return keys_file_data;
}