Eth.h 5.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140
  1. /*
  2. This file is part of cpp-ethereum.
  3. cpp-ethereum is free software: you can redistribute it and/or modify
  4. it under the terms of the GNU General Public License as published by
  5. the Free Software Foundation, either version 3 of the License, or
  6. (at your option) any later version.
  7. cpp-ethereum is distributed in the hope that it will be useful,
  8. but WITHOUT ANY WARRANTY; without even the implied warranty of
  9. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  10. GNU General Public License for more details.
  11. You should have received a copy of the GNU General Public License
  12. along with cpp-ethereum. If not, see <http://www.gnu.org/licenses/>.
  13. */
  14. /** @file Eth.h
  15. * @authors:
  16. * Gav Wood <i@gavwood.com>
  17. * Marek Kotewicz <marek@ethdev.com>
  18. * @date 2014
  19. */
  20. #pragma once
  21. #include <memory>
  22. #include <iostream>
  23. #include <jsonrpccpp/server.h>
  24. #include <jsonrpccpp/common/exception.h>
  25. #include <libdevcrypto/Common.h>
  26. #include "SessionManager.h"
  27. #include "EthFace.h"
  28. namespace dev
  29. {
  30. class NetworkFace;
  31. class KeyPair;
  32. namespace eth
  33. {
  34. class AccountHolder;
  35. struct TransactionSkeleton;
  36. class Interface;
  37. }
  38. namespace shh
  39. {
  40. class Interface;
  41. }
  42. extern const unsigned SensibleHttpThreads;
  43. extern const unsigned SensibleHttpPort;
  44. }
  45. namespace dev
  46. {
  47. namespace rpc
  48. {
  49. /**
  50. * @brief JSON-RPC api implementation
  51. */
  52. class Eth: public dev::rpc::EthFace
  53. {
  54. public:
  55. Eth(eth::Interface& _eth, eth::AccountHolder& _ethAccounts);
  56. virtual RPCModules implementedModules() const override
  57. {
  58. return RPCModules{RPCModule{"eth", "1.0"}};
  59. }
  60. eth::AccountHolder const& ethAccounts() const { return m_ethAccounts; }
  61. virtual std::string eth_protocolVersion() override;
  62. virtual std::string eth_hashrate() override;
  63. virtual std::string eth_coinbase() override;
  64. virtual bool eth_mining() override;
  65. virtual std::string eth_gasPrice() override;
  66. virtual Json::Value eth_accounts() override;
  67. virtual std::string eth_blockNumber()override;
  68. virtual std::string eth_getBalance(std::string const& _address, std::string const& _blockNumber) override;
  69. virtual std::string eth_getStorageAt(std::string const& _address, std::string const& _position, std::string const& _blockNumber) override;
  70. virtual std::string eth_getStorageRoot(std::string const& _address, std::string const& _blockNumber) override;
  71. virtual std::string eth_getTransactionCount(std::string const& _address, std::string const& _blockNumber) override;
  72. virtual std::string eth_pendingTransactions() override;
  73. virtual Json::Value eth_getBlockTransactionCountByHash(std::string const& _blockHash) override;
  74. virtual Json::Value eth_getBlockTransactionCountByNumber(std::string const& _blockNumber) override;
  75. virtual Json::Value eth_getUncleCountByBlockHash(std::string const& _blockHash) override;
  76. virtual Json::Value eth_getUncleCountByBlockNumber(std::string const& _blockNumber) override;
  77. virtual std::string eth_getCode(std::string const& _address, std::string const& _blockNumber) override;
  78. virtual std::string eth_sendTransaction(Json::Value const& _json) override;
  79. virtual std::string eth_call(Json::Value const& _json, std::string const& _blockNumber) override;
  80. virtual std::string eth_estimateGas(Json::Value const& _json) override;
  81. virtual bool eth_flush() override;
  82. virtual Json::Value eth_getBlockByHash(std::string const& _blockHash, bool _includeTransactions) override;
  83. virtual Json::Value eth_getBlockByNumber(std::string const& _blockNumber, bool _includeTransactions) override;
  84. virtual Json::Value eth_getTransactionByHash(std::string const& _transactionHash) override;
  85. virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const& _blockHash, std::string const& _transactionIndex) override;
  86. virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _transactionIndex) override;
  87. virtual Json::Value eth_getTransactionReceipt(std::string const& _transactionHash) override;
  88. virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const& _blockHash, std::string const& _uncleIndex) override;
  89. virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const& _blockNumber, std::string const& _uncleIndex) override;
  90. virtual std::string eth_newFilter(Json::Value const& _json) override;
  91. virtual std::string eth_newFilterEx(Json::Value const& _json) override;
  92. virtual std::string eth_newBlockFilter() override;
  93. virtual std::string eth_newPendingTransactionFilter() override;
  94. virtual bool eth_uninstallFilter(std::string const& _filterId) override;
  95. virtual Json::Value eth_getFilterChanges(std::string const& _filterId) override;
  96. virtual Json::Value eth_getFilterChangesEx(std::string const& _filterId) override;
  97. virtual Json::Value eth_getFilterLogs(std::string const& _filterId) override;
  98. virtual Json::Value eth_getFilterLogsEx(std::string const& _filterId) override;
  99. virtual Json::Value eth_getLogs(Json::Value const& _json) override;
  100. virtual Json::Value eth_getLogsEx(Json::Value const& _json) override;
  101. virtual Json::Value eth_getWork() override;
  102. virtual bool eth_submitWork(std::string const& _nonce, std::string const&, std::string const& _mixHash) override;
  103. virtual bool eth_submitHashrate(std::string const& _hashes, std::string const& _id) override;
  104. virtual std::string eth_register(std::string const& _address) override;
  105. virtual bool eth_unregister(std::string const& _accountId) override;
  106. virtual Json::Value eth_fetchQueuedTransactions(std::string const& _accountId) override;
  107. virtual std::string eth_signTransaction(Json::Value const& _transaction) override;
  108. virtual Json::Value eth_inspectTransaction(std::string const& _rlp) override;
  109. virtual std::string eth_sendRawTransaction(std::string const& _rlp) override;
  110. virtual bool eth_notePassword(std::string const&) override { return false; }
  111. virtual Json::Value eth_syncing() override;
  112. void setTransactionDefaults(eth::TransactionSkeleton& _t);
  113. protected:
  114. eth::Interface* client() { return &m_eth; }
  115. eth::Interface& m_eth;
  116. eth::AccountHolder& m_ethAccounts;
  117. };
  118. }
  119. } //namespace dev