56 lines
1.8 KiB
C
56 lines
1.8 KiB
C
|
// Copyright (c) 2012-2014, The CryptoNote developers, The Bytecoin developers
|
||
|
//
|
||
|
// This file is part of Bytecoin.
|
||
|
//
|
||
|
// Bytecoin is free software: you can redistribute it and/or modify
|
||
|
// it under the terms of the GNU Lesser General Public License as published by
|
||
|
// the Free Software Foundation, either version 3 of the License, or
|
||
|
// (at your option) any later version.
|
||
|
//
|
||
|
// Bytecoin is distributed in the hope that it will be useful,
|
||
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||
|
// GNU Lesser General Public License for more details.
|
||
|
//
|
||
|
// You should have received a copy of the GNU Lesser General Public License
|
||
|
// along with Bytecoin. If not, see <http://www.gnu.org/licenses/>.
|
||
|
|
||
|
#pragma once
|
||
|
|
||
|
#include <vector>
|
||
|
#include <ostream>
|
||
|
#include <istream>
|
||
|
|
||
|
#include "crypto/hash.h"
|
||
|
#include "crypto/chacha8.h"
|
||
|
|
||
|
namespace cryptonote {
|
||
|
class account_base;
|
||
|
class ISerializer;
|
||
|
}
|
||
|
|
||
|
namespace CryptoNote {
|
||
|
|
||
|
class WalletUserTransactionsCache;
|
||
|
|
||
|
class WalletSerializer {
|
||
|
public:
|
||
|
WalletSerializer(cryptonote::account_base& account, WalletUserTransactionsCache& transactionsCache);
|
||
|
|
||
|
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:
|
||
|
void saveKeys(cryptonote::ISerializer& serializer);
|
||
|
void loadKeys(cryptonote::ISerializer& serializer);
|
||
|
|
||
|
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);
|
||
|
|
||
|
cryptonote::account_base& account;
|
||
|
WalletUserTransactionsCache& transactionsCache;
|
||
|
const uint32_t walletSerializationVersion;
|
||
|
};
|
||
|
|
||
|
} //namespace CryptoNote
|