/* This file is part of cpp-ethereum. cpp-ethereum is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. cpp-ethereum 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 General Public License for more details. You should have received a copy of the GNU General Public License along with cpp-ethereum. If not, see . */ /** @file AccountHolder.h * @authors: * Christian R * Lefteris Karapetsas * @date 2015 */ #pragma once #include #include #include #include #include namespace dev { namespace eth { class Interface; } /** * Manages real accounts (where we know the secret key) and proxy accounts (where transactions * to be sent from these accounts are forwarded to a proxy on the other side). */ class AccountHolder { public: explicit AccountHolder(std::function const& _client): m_client(_client) {} /// Sets or resets the list of real accounts. void setAccounts(std::vector const& _accounts); std::vector
const& getRealAccounts() const { return m_accounts; } bool isRealAccount(Address const& _account) const { return m_keyPairs.count(_account) > 0; } bool isProxyAccount(Address const& _account) const { return m_proxyAccounts.count(_account) > 0; } Secret const& secretKey(Address const& _account) const { return m_keyPairs.at(_account).secret(); } std::vector
getAllAccounts() const; Address const& getDefaultTransactAccount() const; int addProxyAccount(Address const& _account); bool removeProxyAccount(unsigned _id); void queueTransaction(eth::TransactionSkeleton const& _transaction); std::vector const& getQueuedTransactions(int _id) const; void clearQueue(int _id); private: using TransactionQueue = std::vector; std::map m_keyPairs; std::vector
m_accounts; std::map m_proxyAccounts; std::map> m_transactionQueues; std::function m_client; }; }