Fabcoin Core  0.16.2
P2P Digital Currency
Eth.cpp
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 #include <csignal>
25 #include <jsonrpccpp/common/exception.h>
26 #include <libdevcore/CommonData.h>
27 #include <libevmcore/Instruction.h>
28 #include <libethereum/Client.h>
30 #include <libwebthree/WebThree.h>
31 #include <libethcore/CommonJS.h>
33 #include "Eth.h"
34 #include "AccountHolder.h"
35 #include "JsonHelper.h"
36 
37 using namespace std;
38 using namespace jsonrpc;
39 using namespace dev;
40 using namespace eth;
41 using namespace shh;
42 using namespace dev::rpc;
43 
44 #if ETH_DEBUG
45 const unsigned dev::SensibleHttpThreads = 1;
46 #else
47 const unsigned dev::SensibleHttpThreads = 4;
48 #endif
49 const unsigned dev::SensibleHttpPort = 8545;
50 
51 Eth::Eth(eth::Interface& _eth, eth::AccountHolder& _ethAccounts):
52  m_eth(_eth),
53  m_ethAccounts(_ethAccounts)
54 {
55 }
56 
58 {
60 }
61 
63 {
64  return toJS(client()->author());
65 }
66 
68 {
69  try
70  {
71  return toJS(asEthashClient(client())->hashrate());
72  }
73  catch (InvalidSealEngine&)
74  {
75  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
76  }
77 }
78 
80 {
81  try
82  {
83  return asEthashClient(client())->isMining();
84  }
85  catch (InvalidSealEngine&)
86  {
87  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
88  }
89 }
90 
92 {
93  return toJS(client()->gasBidPrice());
94 }
95 
97 {
99 }
100 
102 {
103  return toJS(client()->number());
104 }
105 
106 
107 string Eth::eth_getBalance(string const& _address, string const& _blockNumber)
108 {
109  try
110  {
111  return toJS(client()->balanceAt(jsToAddress(_address), jsToBlockNumber(_blockNumber)));
112  }
113  catch (...)
114  {
115  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
116  }
117 }
118 
119 string Eth::eth_getStorageAt(string const& _address, string const& _position, string const& _blockNumber)
120 {
121  try
122  {
123  return toJS(toCompactBigEndian(client()->stateAt(jsToAddress(_address), jsToU256(_position), jsToBlockNumber(_blockNumber)), 32));
124  }
125  catch (...)
126  {
127  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
128  }
129 }
130 
131 string Eth::eth_getStorageRoot(string const& _address, string const& _blockNumber)
132 {
133  try
134  {
135  return toString(client()->stateRootAt(jsToAddress(_address), jsToBlockNumber(_blockNumber)));
136  }
137  catch (...)
138  {
139  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
140  }
141 }
142 
144 {
145  //Return list of transaction that being sent by local accounts
146  Transactions ours;
147  for (Transaction const& pending:client()->pending())
148  {
149  for (Address const& account:m_ethAccounts.allAccounts())
150  {
151  if (pending.sender() == account)
152  {
153  ours.push_back(pending);
154  break;
155  }
156  }
157  }
158 
159  return toJS(ours);
160 }
161 
162 string Eth::eth_getTransactionCount(string const& _address, string const& _blockNumber)
163 {
164  try
165  {
166  return toJS(client()->countAt(jsToAddress(_address), jsToBlockNumber(_blockNumber)));
167  }
168  catch (...)
169  {
170  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
171  }
172 }
173 
175 {
176  try
177  {
178  h256 blockHash = jsToFixed<32>(_blockHash);
179  if (!client()->isKnown(blockHash))
180  return Json::Value(Json::nullValue);
181 
182  return toJS(client()->transactionCount(blockHash));
183  }
184  catch (...)
185  {
186  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
187  }
188 }
189 
191 {
192  try
193  {
194  BlockNumber blockNumber = jsToBlockNumber(_blockNumber);
195  if (!client()->isKnown(blockNumber))
196  return Json::Value(Json::nullValue);
197 
198  return toJS(client()->transactionCount(jsToBlockNumber(_blockNumber)));
199  }
200  catch (...)
201  {
202  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
203  }
204 }
205 
207 {
208  try
209  {
210  h256 blockHash = jsToFixed<32>(_blockHash);
211  if (!client()->isKnown(blockHash))
212  return Json::Value(Json::nullValue);
213 
214  return toJS(client()->uncleCount(blockHash));
215  }
216  catch (...)
217  {
218  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
219  }
220 }
221 
223 {
224  try
225  {
226  BlockNumber blockNumber = jsToBlockNumber(_blockNumber);
227  if (!client()->isKnown(blockNumber))
228  return Json::Value(Json::nullValue);
229 
230  return toJS(client()->uncleCount(blockNumber));
231  }
232  catch (...)
233  {
234  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
235  }
236 }
237 
238 string Eth::eth_getCode(string const& _address, string const& _blockNumber)
239 {
240  try
241  {
242  return toJS(client()->codeAt(jsToAddress(_address), jsToBlockNumber(_blockNumber)));
243  }
244  catch (...)
245  {
246  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
247  }
248 }
249 
251 {
252  if (!_t.from)
254 }
255 
257 {
258  try
259  {
263  switch (n.r)
264  {
265  case TransactionRepercussion::Success:
266  return toJS(n.hash);
267  case TransactionRepercussion::ProxySuccess:
268  return toJS(n.hash);// TODO: give back something more useful than an empty hash.
269  case TransactionRepercussion::UnknownAccount:
270  BOOST_THROW_EXCEPTION(JsonRpcException("Account unknown."));
271  case TransactionRepercussion::Locked:
272  BOOST_THROW_EXCEPTION(JsonRpcException("Account is locked."));
273  case TransactionRepercussion::Refused:
274  BOOST_THROW_EXCEPTION(JsonRpcException("Transaction rejected by user."));
275  case TransactionRepercussion::Unknown:
276  BOOST_THROW_EXCEPTION(JsonRpcException("Unknown reason."));
277  }
278  }
279  catch (JsonRpcException&)
280  {
281  throw;
282  }
283  catch (...)
284  {
285  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
286  }
287  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
288  return string();
289 }
290 
292 {
293  try
294  {
298  switch (n.r)
299  {
300  case TransactionRepercussion::Success:
301  return toJS(n.hash);
302  case TransactionRepercussion::ProxySuccess:
303  return toJS(n.hash);// TODO: give back something more useful than an empty hash.
304  default:
305  // TODO: provide more useful information in the exception.
306  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
307  }
308  }
309  catch (...)
310  {
311  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
312  }
313 }
314 
315 Json::Value Eth::eth_inspectTransaction(std::string const& _rlp)
316 {
317  try
318  {
319  return toJson(Transaction(jsToBytes(_rlp, OnFailed::Throw), CheckTransaction::Everything));
320  }
321  catch (...)
322  {
323  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
324  }
325 }
326 
327 string Eth::eth_sendRawTransaction(std::string const& _rlp)
328 {
329  try
330  {
331  if (client()->injectTransaction(jsToBytes(_rlp, OnFailed::Throw)) == ImportResult::Success)
332  {
334  return toJS(tx.sha3());
335  }
336  else
337  return toJS(h256());
338  }
339  catch (...)
340  {
341  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
342  }
343 }
344 
345 string Eth::eth_call(Json::Value const& _json, string const& _blockNumber)
346 {
347  try
348  {
351  ExecutionResult er = client()->call(t.from, t.value, t.to, t.data, t.gas, t.gasPrice, jsToBlockNumber(_blockNumber), FudgeFactor::Lenient);
352  return toJS(er.output);
353  }
354  catch (...)
355  {
356  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
357  }
358 }
359 
360 string Eth::eth_estimateGas(Json::Value const& _json)
361 {
362  try
363  {
366  int64_t gas = static_cast<int64_t>(t.gas);
367  return toJS(client()->estimateGas(t.from, t.value, t.to, t.data, gas, t.gasPrice, PendingBlock).first);
368  }
369  catch (...)
370  {
371  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
372  }
373 }
374 
376 {
378  return true;
379 }
380 
381 Json::Value Eth::eth_getBlockByHash(string const& _blockHash, bool _includeTransactions)
382 {
383  try
384  {
385  h256 h = jsToFixed<32>(_blockHash);
386  if (!client()->isKnown(h))
387  return Json::Value(Json::nullValue);
388 
389  if (_includeTransactions)
390  return toJson(client()->blockInfo(h), client()->blockDetails(h), client()->uncleHashes(h), client()->transactions(h), client()->sealEngine());
391  else
392  return toJson(client()->blockInfo(h), client()->blockDetails(h), client()->uncleHashes(h), client()->transactionHashes(h), client()->sealEngine());
393  }
394  catch (...)
395  {
396  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
397  }
398 }
399 
400 Json::Value Eth::eth_getBlockByNumber(string const& _blockNumber, bool _includeTransactions)
401 {
402  try
403  {
404  BlockNumber h = jsToBlockNumber(_blockNumber);
405  if (!client()->isKnown(h))
406  return Json::Value(Json::nullValue);
407 
408  if (_includeTransactions)
409  return toJson(client()->blockInfo(h), client()->blockDetails(h), client()->uncleHashes(h), client()->transactions(h), client()->sealEngine());
410  else
411  return toJson(client()->blockInfo(h), client()->blockDetails(h), client()->uncleHashes(h), client()->transactionHashes(h), client()->sealEngine());
412  }
413  catch (...)
414  {
415  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
416  }
417 }
418 
419 Json::Value Eth::eth_getTransactionByHash(string const& _transactionHash)
420 {
421  try
422  {
423  h256 h = jsToFixed<32>(_transactionHash);
424  if (!client()->isKnownTransaction(h))
425  return Json::Value(Json::nullValue);
426 
427  return toJson(client()->localisedTransaction(h));
428  }
429  catch (...)
430  {
431  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
432  }
433 }
434 
435 Json::Value Eth::eth_getTransactionByBlockHashAndIndex(string const& _blockHash, string const& _transactionIndex)
436 {
437  try
438  {
439  h256 bh = jsToFixed<32>(_blockHash);
440  unsigned ti = jsToInt(_transactionIndex);
441  if (!client()->isKnownTransaction(bh, ti))
442  return Json::Value(Json::nullValue);
443 
444  return toJson(client()->localisedTransaction(bh, ti));
445  }
446  catch (...)
447  {
448  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
449  }
450 }
451 
452 Json::Value Eth::eth_getTransactionByBlockNumberAndIndex(string const& _blockNumber, string const& _transactionIndex)
453 {
454  try
455  {
456  BlockNumber bn = jsToBlockNumber(_blockNumber);
457  h256 bh = client()->hashFromNumber(bn);
458  unsigned ti = jsToInt(_transactionIndex);
459  if (!client()->isKnownTransaction(bh, ti))
460  return Json::Value(Json::nullValue);
461 
462  return toJson(client()->localisedTransaction(bh, ti));
463  }
464  catch (...)
465  {
466  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
467  }
468 }
469 
470 Json::Value Eth::eth_getTransactionReceipt(string const& _transactionHash)
471 {
472  try
473  {
474  h256 h = jsToFixed<32>(_transactionHash);
475  if (!client()->isKnownTransaction(h))
476  return Json::Value(Json::nullValue);
477 
478  return toJson(client()->localisedTransactionReceipt(h));
479  }
480  catch (...)
481  {
482  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
483  }
484 }
485 
486 Json::Value Eth::eth_getUncleByBlockHashAndIndex(string const& _blockHash, string const& _uncleIndex)
487 {
488  try
489  {
490  return toJson(client()->uncle(jsToFixed<32>(_blockHash), jsToInt(_uncleIndex)), client()->sealEngine());
491  }
492  catch (...)
493  {
494  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
495  }
496 }
497 
498 Json::Value Eth::eth_getUncleByBlockNumberAndIndex(string const& _blockNumber, string const& _uncleIndex)
499 {
500  try
501  {
502  return toJson(client()->uncle(jsToBlockNumber(_blockNumber), jsToInt(_uncleIndex)), client()->sealEngine());
503  }
504  catch (...)
505  {
506  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
507  }
508 }
509 
510 string Eth::eth_newFilter(Json::Value const& _json)
511 {
512  try
513  {
514  return toJS(client()->installWatch(toLogFilter(_json, *client())));
515  }
516  catch (...)
517  {
518  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
519  }
520 }
521 
522 string Eth::eth_newFilterEx(Json::Value const& _json)
523 {
524  try
525  {
526  return toJS(client()->installWatch(toLogFilter(_json)));
527  }
528  catch (...)
529  {
530  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
531  }
532 }
533 
535 {
536  h256 filter = dev::eth::ChainChangedFilter;
537  return toJS(client()->installWatch(filter));
538 }
539 
541 {
542  h256 filter = dev::eth::PendingChangedFilter;
543  return toJS(client()->installWatch(filter));
544 }
545 
546 bool Eth::eth_uninstallFilter(string const& _filterId)
547 {
548  try
549  {
550  return client()->uninstallWatch(jsToInt(_filterId));
551  }
552  catch (...)
553  {
554  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
555  }
556 }
557 
558 Json::Value Eth::eth_getFilterChanges(string const& _filterId)
559 {
560  try
561  {
562  int id = jsToInt(_filterId);
563  auto entries = client()->checkWatch(id);
564 // if (entries.size())
565 // cnote << "FIRING WATCH" << id << entries.size();
566  return toJson(entries);
567  }
568  catch (...)
569  {
570  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
571  }
572 }
573 
574 Json::Value Eth::eth_getFilterChangesEx(string const& _filterId)
575 {
576  try
577  {
578  int id = jsToInt(_filterId);
579  auto entries = client()->checkWatch(id);
580 // if (entries.size())
581 // cnote << "FIRING WATCH" << id << entries.size();
582  return toJsonByBlock(entries);
583  }
584  catch (...)
585  {
586  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
587  }
588 }
589 
590 Json::Value Eth::eth_getFilterLogs(string const& _filterId)
591 {
592  try
593  {
594  return toJson(client()->logs(jsToInt(_filterId)));
595  }
596  catch (...)
597  {
598  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
599  }
600 }
601 
602 Json::Value Eth::eth_getFilterLogsEx(string const& _filterId)
603 {
604  try
605  {
606  return toJsonByBlock(client()->logs(jsToInt(_filterId)));
607  }
608  catch (...)
609  {
610  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
611  }
612 }
613 
615 {
616  try
617  {
618  return toJson(client()->logs(toLogFilter(_json, *client())));
619  }
620  catch (...)
621  {
622  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
623  }
624 }
625 
627 {
628  try
629  {
630  return toJsonByBlock(client()->logs(toLogFilter(_json)));
631  }
632  catch (...)
633  {
634  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
635  }
636 }
637 
639 {
640  try
641  {
642  Json::Value ret(Json::arrayValue);
643  auto r = asEthashClient(client())->getEthashWork();
644  ret.append(toJS(get<0>(r)));
645  ret.append(toJS(get<1>(r)));
646  ret.append(toJS(get<2>(r)));
647  return ret;
648  }
649  catch (...)
650  {
651  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
652  }
653 }
654 
656 {
658  if (sync.state == SyncState::Idle || !sync.majorSyncing)
659  return Json::Value(false);
660 
661  Json::Value info(Json::objectValue);
662  info["startingBlock"] = sync.startBlockNumber;
663  info["highestBlock"] = sync.highestBlockNumber;
664  info["currentBlock"] = sync.currentBlockNumber;
665  return info;
666 }
667 
668 bool Eth::eth_submitWork(string const& _nonce, string const&, string const& _mixHash)
669 {
670  try
671  {
672  return asEthashClient(client())->submitEthashWork(jsToFixed<32>(_mixHash), jsToFixed<Nonce::size>(_nonce));
673  }
674  catch (...)
675  {
676  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
677  }
678 }
679 
680 bool Eth::eth_submitHashrate(string const& _hashes, string const& _id)
681 {
682  try
683  {
684  asEthashClient(client())->submitExternalHashrate(jsToInt<32>(_hashes), jsToFixed<32>(_id));
685  return true;
686  }
687  catch (...)
688  {
689  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
690  }
691 }
692 
693 string Eth::eth_register(string const& _address)
694 {
695  try
696  {
697  return toJS(m_ethAccounts.addProxyAccount(jsToAddress(_address)));
698  }
699  catch (...)
700  {
701  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
702  }
703 }
704 
705 bool Eth::eth_unregister(string const& _accountId)
706 {
707  try
708  {
709  return m_ethAccounts.removeProxyAccount(jsToInt(_accountId));
710  }
711  catch (...)
712  {
713  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
714  }
715 }
716 
718 {
719  try
720  {
721  auto id = jsToInt(_accountId);
722  Json::Value ret(Json::arrayValue);
723  // TODO: throw an error on no account with given id
725  ret.append(toJson(t));
727  return ret;
728  }
729  catch (...)
730  {
731  BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
732  }
733 }
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
virtual std::string eth_getStorageAt(std::string const &_address, std::string const &_position, std::string const &_blockNumber) override
Definition: Eth.cpp:119
unsigned startBlockNumber
Definition: CommonNet.h:105
virtual Json::Value eth_getBlockTransactionCountByNumber(std::string const &_blockNumber) override
Definition: Eth.cpp:190
virtual std::string eth_blockNumber() override
Definition: Eth.cpp:101
const unsigned c_protocolVersion
Current protocol version.
Definition: Common.cpp:43
virtual Json::Value eth_getTransactionByHash(std::string const &_transactionHash) override
Definition: Eth.cpp:419
virtual std::string eth_signTransaction(Json::Value const &_transaction) override
Definition: Eth.cpp:291
Manages real accounts (where we know the secret key) and proxy accounts (where transactions to be sen...
Definition: AccountHolder.h:64
virtual std::string eth_getTransactionCount(std::string const &_address, std::string const &_blockNumber) override
Definition: Eth.cpp:162
virtual Json::Value eth_getTransactionReceipt(std::string const &_transactionHash) override
Definition: Eth.cpp:470
EthashClient & asEthashClient(Interface &_c)
virtual std::string eth_newFilter(Json::Value const &_json) override
Definition: Eth.cpp:510
eth::AccountHolder & m_ethAccounts
Definition: Eth.h:134
virtual Json::Value eth_getLogs(Json::Value const &_json) override
Definition: Eth.cpp:614
virtual bool isKnown(BlockNumber _block) const =0
#define h(i)
Definition: sha.cpp:736
virtual Json::Value eth_inspectTransaction(std::string const &_rlp) override
Definition: Eth.cpp:315
virtual std::string eth_register(std::string const &_address) override
Definition: Eth.cpp:693
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
Definition: Transaction.h:121
virtual std::string eth_hashrate() override
Definition: Eth.cpp:67
std::tuple< h256, h256, h256 > getEthashWork()
Update to the latest transactions and get hash of the current block to be mined minus the nonce (the ...
virtual Json::Value eth_getBlockByNumber(std::string const &_blockNumber, bool _includeTransactions) override
Definition: Eth.cpp:400
virtual h256 hashFromNumber(BlockNumber _number) const =0
bool submitEthashWork(h256 const &_mixHash, h64 const &_nonce)
Submit the proof for the proof-of-work.
virtual TransactionNotification authenticate(dev::eth::TransactionSkeleton const &_t)=0
std::hash for asio::adress
Definition: Common.h:323
void submitExternalHashrate(u256 const &_rate, h256 const &_id)
virtual bool eth_submitHashrate(std::string const &_hashes, std::string const &_id) override
Definition: Eth.cpp:680
virtual std::string eth_estimateGas(Json::Value const &_json) override
Definition: Eth.cpp:360
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Definition: CommonData.cpp:141
virtual Json::Value eth_getFilterChanges(std::string const &_filterId) override
Definition: Eth.cpp:558
Description of the result of executing a transaction.
Definition: Transaction.h:69
virtual std::string eth_getStorageRoot(std::string const &_address, std::string const &_blockNumber) override
Definition: Eth.cpp:131
virtual Json::Value eth_getLogsEx(Json::Value const &_json) override
Definition: Eth.cpp:626
TransactionSkeleton toTransactionSkeleton(Json::Value const &_json)
Definition: JsonHelper.cpp:354
unsigned BlockNumber
Definition: Common.h:72
virtual std::string eth_newFilterEx(Json::Value const &_json) override
Definition: Eth.cpp:522
int addProxyAccount(Address const &_account)
BlockNumber jsToBlockNumber(std::string const &_js)
Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "lat...
Definition: CommonJS.cpp:62
virtual std::string eth_gasPrice() override
Definition: Eth.cpp:91
virtual bool eth_unregister(std::string const &_accountId) override
Definition: Eth.cpp:705
virtual Json::Value eth_getUncleCountByBlockHash(std::string const &_blockHash) override
Definition: Eth.cpp:206
virtual bool isKnownTransaction(h256 const &_transactionHash) const =0
Config::Value_type Value
virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const &_blockNumber, std::string const &_uncleIndex) override
Definition: Eth.cpp:498
eth::Interface * client()
Definition: Eth.h:131
virtual Json::Value eth_syncing() override
Definition: Eth.cpp:655
virtual bool eth_uninstallFilter(std::string const &_filterId) override
Definition: Eth.cpp:546
virtual Json::Value eth_accounts() override
Definition: Eth.cpp:96
virtual Json::Value eth_fetchQueuedTransactions(std::string const &_accountId) override
Definition: Eth.cpp:717
virtual ExecutionResult call(Address const &_from, u256 _value, Address _dest, bytes const &_data, u256 _gas, u256 _gasPrice, BlockNumber _blockNumber, FudgeFactor _ff=FudgeFactor::Strict)=0
Makes the given call. Nothing is recorded into the state.
std::string toJS(FixedHash< S > const &_h)
Definition: CommonJS.h:34
Address jsToAddress(std::string const &_s)
Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length...
Definition: CommonJS.h:43
virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const &_blockHash, std::string const &_transactionIndex) override
Definition: Eth.cpp:435
bool isMining() const
Are we mining now?
virtual std::string eth_sendTransaction(Json::Value const &_json) override
Definition: Eth.cpp:256
bytes toCompactBigEndian(T _val, unsigned _min=0)
Convenience function for toBigEndian.
Definition: CommonData.h:141
dev::eth::LogFilter toLogFilter(Json::Value const &_json)
Definition: JsonHelper.cpp:387
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
Definition: FixedHash.h:47
h256 sha3(IncludeSignature _sig=WithSignature) const
FixedHash< 32 > h256
Definition: FixedHash.h:340
virtual std::string eth_call(Json::Value const &_json, std::string const &_blockNumber) override
Definition: Eth.cpp:345
std::vector< eth::TransactionSkeleton > const & queuedTransactions(int _id) const
virtual Json::Value eth_getWork() override
Definition: Eth.cpp:638
virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const &_blockNumber, std::string const &_transactionIndex) override
Definition: Eth.cpp:452
void setTransactionDefaults(eth::TransactionSkeleton &_t)
Definition: Eth.cpp:250
virtual LocalisedLogEntries checkWatch(unsigned _watchId)=0
TransactionRepercussion r
Definition: AccountHolder.h:55
const unsigned SensibleHttpPort
Definition: Eth.cpp:49
virtual bool eth_flush() override
Definition: Eth.cpp:375
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Definition: Transaction.h:84
bytes jsToBytes(string const &_s, OnFailed _f)
Definition: CommonJS.cpp:31
Main API hub for interfacing with Ethereum.
Definition: Interface.h:67
Json::Value toJsonByBlock(LocalisedLogEntries const &_entries)
Definition: JsonHelper.cpp:332
virtual std::string eth_getCode(std::string const &_address, std::string const &_blockNumber) override
Definition: Eth.cpp:238
virtual SyncStatus syncStatus() const =0
Get some information on the block queue.
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
Definition: JsonHelper.cpp:41
virtual Json::Value eth_getBlockByHash(std::string const &_blockHash, bool _includeTransactions) override
Definition: Eth.cpp:381
unsigned currentBlockNumber
Definition: CommonNet.h:106
virtual std::string eth_pendingTransactions() override
Definition: Eth.cpp:143
virtual std::string eth_sendRawTransaction(std::string const &_rlp) override
Definition: Eth.cpp:327
virtual std::string eth_coinbase() override
Definition: Eth.cpp:62
virtual std::string eth_newPendingTransactionFilter() override
Definition: Eth.cpp:540
virtual bool eth_mining() override
Definition: Eth.cpp:79
const unsigned SensibleHttpThreads
Definition: Eth.cpp:47
virtual std::string eth_protocolVersion() override
Definition: Eth.cpp:57
virtual Json::Value eth_getFilterLogs(std::string const &_filterId) override
Definition: Eth.cpp:590
virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const &_blockHash, std::string const &_uncleIndex) override
Definition: Eth.cpp:486
virtual std::string eth_getBalance(std::string const &_address, std::string const &_blockNumber) override
Definition: Eth.cpp:107
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< N *8, N *8, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void > > jsToInt(std::string const &_s)
Convert a string representation of a number to an int String can be a normal decimal number...
Definition: CommonJS.h:97
bool removeProxyAccount(unsigned _id)
virtual std::string eth_newBlockFilter() override
Definition: Eth.cpp:534
unsigned highestBlockNumber
Definition: CommonNet.h:107
virtual Json::Value eth_getUncleCountByBlockNumber(std::string const &_blockNumber) override
Definition: Eth.cpp:222
virtual Json::Value eth_getFilterLogsEx(std::string const &_filterId) override
Definition: Eth.cpp:602
u256 jsToU256(std::string const &_s)
Definition: CommonJS.h:110
virtual bool eth_submitWork(std::string const &_nonce, std::string const &, std::string const &_mixHash) override
Definition: Eth.cpp:668
virtual Json::Value eth_getFilterChangesEx(std::string const &_filterId) override
Definition: Eth.cpp:574
Address const & defaultTransactAccount() const
Addresses allAccounts() const
virtual bool uninstallWatch(unsigned _watchId)=0
virtual Json::Value eth_getBlockTransactionCountByHash(std::string const &_blockHash) override
Definition: Eth.cpp:174
virtual void flushTransactions()=0
Blocks until all pending transactions have been processed.