From 7414e2bac11cbf9163ca16dc1b1510b4fd9a0d64 Mon Sep 17 00:00:00 2001 From: Lee Clagett Date: Tue, 13 Oct 2020 15:15:07 +0000 Subject: Change epee binary output from std::stringstream to byte_stream --- src/wallet/wallet2.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'src/wallet/wallet2.cpp') 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::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::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(account_data.data()), account_data.size()); json.AddMember("key_data", value, json.GetAllocator()); if (!seed_language.empty()) { @@ -3989,13 +3989,12 @@ boost::optional wallet2::get_keys_file_data(const epee: rapidjson::StringBuffer buffer; rapidjson::Writer 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::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; } -- cgit v1.2.3