Fabcoin Core  0.16.2
P2P Digital Currency
Eth.h
Go to the documentation of this file.
1 /*
2  This file is part of cpp-ethereum.
3 
4  cpp-ethereum is free software: you can redistribute it and/or modify
5  it under the terms of the GNU General Public License as published by
6  the Free Software Foundation, either version 3 of the License, or
7  (at your option) any later version.
8 
9  cpp-ethereum is distributed in the hope that it will be useful,
10  but WITHOUT ANY WARRANTY; without even the implied warranty of
11  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12  GNU General Public License for more details.
13 
14  You should have received a copy of the GNU General Public License
15  along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
16 */
24 #pragma once
25 
26 #include <memory>
27 #include <iostream>
28 #include <jsonrpccpp/server.h>
29 #include <jsonrpccpp/common/exception.h>
30 #include <libdevcrypto/Common.h>
31 #include "SessionManager.h"
32 #include "EthFace.h"
33 
34 
35 namespace dev
36 {
37 class NetworkFace;
38 class KeyPair;
39 namespace eth
40 {
41 class AccountHolder;
42 struct TransactionSkeleton;
43 class Interface;
44 }
45 namespace shh
46 {
47 class Interface;
48 }
49 
50 extern const unsigned SensibleHttpThreads;
51 extern const unsigned SensibleHttpPort;
52 
53 }
54 
55 namespace dev
56 {
57 
58 namespace rpc
59 {
60 
64 class Eth: public dev::rpc::EthFace
65 {
66 public:
67  Eth(eth::Interface& _eth, eth::AccountHolder& _ethAccounts);
68 
69  virtual RPCModules implementedModules() const override
70  {
71  return RPCModules{RPCModule{"eth", "1.0"}};
72  }
73 
74  eth::AccountHolder const& ethAccounts() const { return m_ethAccounts; }
75 
76  virtual std::string eth_protocolVersion() override;
77  virtual std::string eth_hashrate() override;
78  virtual std::string eth_coinbase() override;
79  virtual bool eth_mining() override;
80  virtual std::string eth_gasPrice() override;
81  virtual Json::Value eth_accounts() override;
82  virtual std::string eth_blockNumber()override;
83  virtual std::string eth_getBalance(std::string const& _address, std::string const& _blockNumber) override;
84  virtual std::string eth_getStorageAt(std::string const& _address, std::string const& _position, std::string const& _blockNumber) override;
85  virtual std::string eth_getStorageRoot(std::string const& _address, std::string const& _blockNumber) override;
86  virtual std::string eth_getTransactionCount(std::string const& _address, std::string const& _blockNumber) override;
87  virtual std::string eth_pendingTransactions() override;
88  virtual Json::Value eth_getBlockTransactionCountByHash(std::string const& _blockHash) override;
89  virtual Json::Value eth_getBlockTransactionCountByNumber(std::string const& _blockNumber) override;
90  virtual Json::Value eth_getUncleCountByBlockHash(std::string const& _blockHash) override;
91  virtual Json::Value eth_getUncleCountByBlockNumber(std::string const& _blockNumber) override;
92  virtual std::string eth_getCode(std::string const& _address, std::string const& _blockNumber) override;
93  virtual std::string eth_sendTransaction(Json::Value const& _json) override;
94  virtual std::string eth_call(Json::Value const& _json, std::string const& _blockNumber) override;
95  virtual std::string eth_estimateGas(Json::Value const& _json) override;
96  virtual bool eth_flush() override;
97  virtual Json::Value eth_getBlockByHash(std::string const& _blockHash, bool _includeTransactions) override;
98  virtual Json::Value eth_getBlockByNumber(std::string const& _blockNumber, bool _includeTransactions) override;
99  virtual Json::Value eth_getTransactionByHash(std::string const& _transactionHash) override;
100  virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const& _blockHash, std::string const& _transactionIndex) override;
101  virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _transactionIndex) override;
102  virtual Json::Value eth_getTransactionReceipt(std::string const& _transactionHash) override;
103  virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const& _blockHash, std::string const& _uncleIndex) override;
104  virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _uncleIndex) override;
105  virtual std::string eth_newFilter(Json::Value const& _json) override;
106  virtual std::string eth_newFilterEx(Json::Value const& _json) override;
107  virtual std::string eth_newBlockFilter() override;
108  virtual std::string eth_newPendingTransactionFilter() override;
109  virtual bool eth_uninstallFilter(std::string const& _filterId) override;
110  virtual Json::Value eth_getFilterChanges(std::string const& _filterId) override;
111  virtual Json::Value eth_getFilterChangesEx(std::string const& _filterId) override;
112  virtual Json::Value eth_getFilterLogs(std::string const& _filterId) override;
113  virtual Json::Value eth_getFilterLogsEx(std::string const& _filterId) override;
114  virtual Json::Value eth_getLogs(Json::Value const& _json) override;
115  virtual Json::Value eth_getLogsEx(Json::Value const& _json) override;
116  virtual Json::Value eth_getWork() override;
117  virtual bool eth_submitWork(std::string const& _nonce, std::string const&, std::string const& _mixHash) override;
118  virtual bool eth_submitHashrate(std::string const& _hashes, std::string const& _id) override;
119  virtual std::string eth_register(std::string const& _address) override;
120  virtual bool eth_unregister(std::string const& _accountId) override;
121  virtual Json::Value eth_fetchQueuedTransactions(std::string const& _accountId) override;
122  virtual std::string eth_signTransaction(Json::Value const& _transaction) override;
123  virtual Json::Value eth_inspectTransaction(std::string const& _rlp) override;
124  virtual std::string eth_sendRawTransaction(std::string const& _rlp) override;
125  virtual bool eth_notePassword(std::string const&) override { return false; }
126  virtual Json::Value eth_syncing() override;
127 
128  void setTransactionDefaults(eth::TransactionSkeleton& _t);
129 protected:
130 
131  eth::Interface* client() { return &m_eth; }
132 
135 
136 };
137 
138 }
139 } //namespace dev
eth::AccountHolder const & ethAccounts() const
Definition: Eth.h:74
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
std::vector< RPCModule > RPCModules
Definition: ModularServer.h:50
virtual bool eth_notePassword(std::string const &) override
Definition: Eth.h:125
Manages real accounts (where we know the secret key) and proxy accounts (where transactions to be sen...
Definition: AccountHolder.h:64
eth::AccountHolder & m_ethAccounts
Definition: Eth.h:134
virtual RPCModules implementedModules() const override
Definition: Eth.h:69
Config::Value_type Value
eth::Interface * client()
Definition: Eth.h:131
const unsigned SensibleHttpPort
Definition: Eth.cpp:49
Main API hub for interfacing with Ethereum.
Definition: Interface.h:67
JSON-RPC api implementation.
Definition: Eth.h:64
const unsigned SensibleHttpThreads
Definition: Eth.cpp:47
eth::Interface & m_eth
Definition: Eth.h:133