wallet2: fix keys file deserialization exception handling

This commit is contained in:
xiphon 2020-05-05 02:30:54 +00:00 committed by wowario
parent b59ef9a359
commit 1e981f5be6
No known key found for this signature in database
GPG key ID: 24DCBE762DE9C111

View file

@ -3992,13 +3992,7 @@ bool wallet2::load_keys(const std::string& keys_file_name, const epee::wipeable_
// Load keys from buffer
boost::optional<crypto::chacha_key> keys_to_encrypt;
try {
r = wallet2::load_keys_buf(keys_file_buf, password, keys_to_encrypt);
} catch (const std::exception& e) {
std::size_t found = string(e.what()).find("failed to deserialize keys buffer");
THROW_WALLET_EXCEPTION_IF(found != std::string::npos, error::wallet_internal_error, "internal error: failed to deserialize \"" + keys_file_name + '\"');
throw e;
}
r = wallet2::load_keys_buf(keys_file_buf, password, keys_to_encrypt);
// Rewrite with encrypted keys if unencrypted, ignore errors
if (r && keys_to_encrypt != boost::none)