// Copyright (c) 2012-2015, 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 . #pragma once #include "cryptonote_core/account.h" // epee #include "serialization/keyvalue_serialization.h" namespace CryptoNote { template struct AccountPublicAddressSerializer; template struct AccountKeysSerializer; template struct AccountBaseSerializer; template<> struct AccountPublicAddressSerializer { const AccountPublicAddress& m_account_address; AccountPublicAddressSerializer(const AccountPublicAddress& account_address) : m_account_address(account_address) { } BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_account_address.m_spendPublicKey, "m_spend_public_key") KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_account_address.m_viewPublicKey, "m_view_public_key") END_KV_SERIALIZE_MAP() }; template<> struct AccountPublicAddressSerializer { AccountPublicAddress& m_account_address; AccountPublicAddressSerializer(AccountPublicAddress& account_address) : m_account_address(account_address) { } BEGIN_KV_SERIALIZE_MAP() KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_account_address.m_spendPublicKey, "m_spend_public_key") KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_account_address.m_viewPublicKey, "m_view_public_key") END_KV_SERIALIZE_MAP() }; template<> struct AccountKeysSerializer { const account_keys& m_keys; AccountKeysSerializer(const account_keys& keys) : m_keys(keys) { } BEGIN_KV_SERIALIZE_MAP() AccountPublicAddressSerializer addressSerializer(this_ref.m_keys.m_account_address); epee::serialization::selector::serialize(addressSerializer, stg, hparent_section, "m_account_address"); KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_keys.m_spend_secret_key, "m_spend_secret_key") KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_keys.m_view_secret_key, "m_view_secret_key") END_KV_SERIALIZE_MAP() }; template<> struct AccountKeysSerializer { account_keys& m_keys; AccountKeysSerializer(account_keys& keys) : m_keys(keys) { } BEGIN_KV_SERIALIZE_MAP() AccountPublicAddressSerializer addressSerializer(this_ref.m_keys.m_account_address); epee::serialization::selector::serialize(addressSerializer, stg, hparent_section, "m_account_address"); KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_keys.m_spend_secret_key, "m_spend_secret_key") KV_SERIALIZE_VAL_POD_AS_BLOB_FORCE_N(m_keys.m_view_secret_key, "m_view_secret_key") END_KV_SERIALIZE_MAP() }; template<> struct AccountBaseSerializer { const account_base& m_account; AccountBaseSerializer(const account_base& account) : m_account(account) { } BEGIN_KV_SERIALIZE_MAP() AccountKeysSerializer keysSerializer(this_ref.m_account.m_keys); epee::serialization::selector::serialize(keysSerializer, stg, hparent_section, "m_keys"); KV_SERIALIZE_N(m_account.m_creation_timestamp, "m_creation_timestamp") END_KV_SERIALIZE_MAP() }; template<> struct AccountBaseSerializer { account_base& m_account; AccountBaseSerializer(account_base& account) : m_account(account) { } BEGIN_KV_SERIALIZE_MAP() AccountKeysSerializer keysSerializer(this_ref.m_account.m_keys); epee::serialization::selector::serialize(keysSerializer, stg, hparent_section, "m_keys"); KV_SERIALIZE_N(m_account.m_creation_timestamp, "m_creation_timestamp") END_KV_SERIALIZE_MAP() }; }