2015-04-23 16:07:22 +00:00
|
|
|
// Copyright (c) 2011-2015 The Cryptonote developers
|
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
2015-04-06 16:13:07 +00:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
#include <vector>
|
|
|
|
#include <ostream>
|
|
|
|
#include <istream>
|
|
|
|
|
|
|
|
#include "crypto/hash.h"
|
|
|
|
#include "crypto/chacha8.h"
|
|
|
|
|
2015-05-27 12:08:46 +00:00
|
|
|
namespace CryptoNote {
|
2015-07-30 15:22:07 +00:00
|
|
|
class AccountBase;
|
2015-04-06 16:13:07 +00:00
|
|
|
class ISerializer;
|
|
|
|
}
|
|
|
|
|
|
|
|
namespace CryptoNote {
|
|
|
|
|
|
|
|
class WalletUserTransactionsCache;
|
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
class WalletLegacySerializer {
|
2015-04-06 16:13:07 +00:00
|
|
|
public:
|
2015-07-30 15:22:07 +00:00
|
|
|
WalletLegacySerializer(CryptoNote::AccountBase& account, WalletUserTransactionsCache& transactionsCache);
|
2015-04-06 16:13:07 +00:00
|
|
|
|
|
|
|
void serialize(std::ostream& stream, const std::string& password, bool saveDetailed, const std::string& cache);
|
|
|
|
void deserialize(std::istream& stream, const std::string& password, std::string& cache);
|
|
|
|
|
|
|
|
private:
|
2015-05-27 12:08:46 +00:00
|
|
|
void saveKeys(CryptoNote::ISerializer& serializer);
|
|
|
|
void loadKeys(CryptoNote::ISerializer& serializer);
|
2015-04-06 16:13:07 +00:00
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
Crypto::chacha8_iv encrypt(const std::string& plain, const std::string& password, std::string& cipher);
|
|
|
|
void decrypt(const std::string& cipher, std::string& plain, Crypto::chacha8_iv iv, const std::string& password);
|
2015-04-06 16:13:07 +00:00
|
|
|
|
2015-07-30 15:22:07 +00:00
|
|
|
CryptoNote::AccountBase& account;
|
2015-04-06 16:13:07 +00:00
|
|
|
WalletUserTransactionsCache& transactionsCache;
|
|
|
|
const uint32_t walletSerializationVersion;
|
|
|
|
};
|
|
|
|
|
|
|
|
} //namespace CryptoNote
|