Fabcoin Core  0.16.2
P2P Digital Currency
JsonHelper.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 */
23 #include "JsonHelper.h"
24 
25 #include <libevmcore/Instruction.h>
26 #include <libethcore/SealEngine.h>
27 #include <libethereum/Client.h>
28 #include <libwebthree/WebThree.h>
29 #include <libethcore/CommonJS.h>
30 #include <libethcore/ICAP.h>
31 #include <libwhisper/Message.h>
32 #include <libwhisper/WhisperHost.h>
33 #include <jsonrpccpp/common/exception.h>
34 using namespace std;
35 using namespace dev;
36 using namespace eth;
37 
38 namespace dev
39 {
40 
41 Json::Value toJson(unordered_map<u256, u256> const& _storage)
42 {
43  Json::Value res(Json::objectValue);
44  for (auto i: _storage)
45  res[toJS(i.first)] = toJS(i.second);
46  return res;
47 }
48 
49 Json::Value toJson(map<h256, pair<u256, u256>> const& _storage)
50 {
51  Json::Value res(Json::objectValue);
52  for (auto i: _storage)
53  res[toJS(u256(i.second.first))] = toJS(i.second.second);
54  return res;
55 }
56 
57 Json::Value toJson(Address const& _address)
58 {
59  return toJS(_address);
60 }
61 
62 // ////////////////////////////////////////////////////////////////////////////////
63 // p2p
64 // ////////////////////////////////////////////////////////////////////////////////
65 namespace p2p
66 {
67 
69 {
70  //@todo localAddress
71  //@todo protocols
72  Json::Value ret;
73  ret["id"] = _p.id.hex();
74  ret["name"] = _p.clientVersion;
75  ret["network"]["remoteAddress"] = _p.host + ":" + toString(_p.port);
76  ret["lastPing"] = (int)chrono::duration_cast<chrono::milliseconds>(_p.lastPing).count();
77  for (auto const& i: _p.notes)
78  ret["notes"][i.first] = i.second;
79  for (auto const& i: _p.caps)
80  ret["caps"].append(i.first + "/" + toString((unsigned)i.second));
81  return ret;
82 }
83 
84 }
85 
86 // ////////////////////////////////////////////////////////////////////////////////
87 // eth
88 // ////////////////////////////////////////////////////////////////////////////////
89 
90 namespace eth
91 {
92 
94 {
95  Json::Value res;
96  if (_bi)
97  {
98  DEV_IGNORE_EXCEPTIONS(res["hash"] = toJS(_bi.hash()));
99  res["parentHash"] = toJS(_bi.parentHash());
100  res["sha3Uncles"] = toJS(_bi.sha3Uncles());
101  res["author"] = toJS(_bi.author());
102  res["stateRoot"] = toJS(_bi.stateRoot());
103  res["transactionsRoot"] = toJS(_bi.transactionsRoot());
104  res["receiptsRoot"] = toJS(_bi.receiptsRoot());
105  res["number"] = toJS(_bi.number());
106  res["gasUsed"] = toJS(_bi.gasUsed());
107  res["gasLimit"] = toJS(_bi.gasLimit());
108  res["extraData"] = toJS(_bi.extraData());
109  res["logsBloom"] = toJS(_bi.logBloom());
110  res["timestamp"] = toJS(_bi.timestamp());
111  // TODO: remove once JSONRPC spec is updated to use "author" over "miner".
112  res["miner"] = toJS(_bi.author());
113  if (_sealer)
114  for (auto const& i: _sealer->jsInfo(_bi))
115  res[i.first] = i.second;
116 
117  }
118  return res;
119 }
120 
121 Json::Value toJson(dev::eth::Transaction const& _t, std::pair<h256, unsigned> _location, BlockNumber _blockNumber)
122 {
123  Json::Value res;
124  if (_t)
125  {
126  res["hash"] = toJS(_t.sha3());
127  res["input"] = toJS(_t.data());
128  res["to"] = _t.isCreation() ? Json::Value() : toJS(_t.receiveAddress());
129  res["from"] = toJS(_t.safeSender());
130  res["gas"] = toJS(_t.gas());
131  res["gasPrice"] = toJS(_t.gasPrice());
132  res["nonce"] = toJS(_t.nonce());
133  res["value"] = toJS(_t.value());
134  res["blockHash"] = toJS(_location.first);
135  res["transactionIndex"] = toJS(_location.second);
136  res["blockNumber"] = toJS(_blockNumber);
137  }
138  return res;
139 }
140 
141 Json::Value toJson(dev::eth::BlockHeader const& _bi, BlockDetails const& _bd, UncleHashes const& _us, Transactions const& _ts, SealEngineFace* _face)
142 {
143  Json::Value res = toJson(_bi, _face);
144  if (_bi)
145  {
146  res["totalDifficulty"] = toJS(_bd.totalDifficulty);
147  res["uncles"] = Json::Value(Json::arrayValue);
148  for (h256 h: _us)
149  res["uncles"].append(toJS(h));
150  res["transactions"] = Json::Value(Json::arrayValue);
151  for (unsigned i = 0; i < _ts.size(); i++)
152  res["transactions"].append(toJson(_ts[i], std::make_pair(_bi.hash(), i), (BlockNumber)_bi.number()));
153  }
154  return res;
155 }
156 
157 Json::Value toJson(dev::eth::BlockHeader const& _bi, BlockDetails const& _bd, UncleHashes const& _us, TransactionHashes const& _ts, SealEngineFace* _face)
158 {
159  Json::Value res = toJson(_bi, _face);
160  if (_bi)
161  {
162  res["totalDifficulty"] = toJS(_bd.totalDifficulty);
163  res["uncles"] = Json::Value(Json::arrayValue);
164  for (h256 h: _us)
165  res["uncles"].append(toJS(h));
166  res["transactions"] = Json::Value(Json::arrayValue);
167  for (h256 const& t: _ts)
168  res["transactions"].append(toJS(t));
169  }
170  return res;
171 }
172 
174 {
175  Json::Value res;
176  res["to"] = _t.creation ? Json::Value() : toJS(_t.to);
177  res["from"] = toJS(_t.from);
178  res["gas"] = toJS(_t.gas);
179  res["gasPrice"] = toJS(_t.gasPrice);
180  res["value"] = toJS(_t.value);
181  res["data"] = toJS(_t.data, 32);
182  return res;
183 }
184 
186 {
187  Json::Value res;
188  res["stateRoot"] = toJS(_t.stateRoot());
189  res["gasUsed"] = toJS(_t.gasUsed());
190  res["bloom"] = toJS(_t.bloom());
191  res["log"] = dev::toJson(_t.log());
192  return res;
193 }
194 
196 {
197  Json::Value res;
198  res["transactionHash"] = toJS(_t.hash());
199  res["transactionIndex"] = _t.transactionIndex();
200  res["blockHash"] = toJS(_t.blockHash());
201  res["blockNumber"] = _t.blockNumber();
202  res["cumulativeGasUsed"] = toJS(_t.gasUsed()); // TODO: check if this is fine
203  res["gasUsed"] = toJS(_t.gasUsed());
204  res["contractAddress"] = toJS(_t.contractAddress());
205  res["logs"] = dev::toJson(_t.localisedLogs());
206  return res;
207 }
208 
210 {
211  Json::Value res;
212  res["to"] = _t.isCreation() ? Json::Value() : toJS(_t.to());
213  res["from"] = toJS(_t.from());
214  res["gas"] = toJS(_t.gas());
215  res["gasPrice"] = toJS(_t.gasPrice());
216  res["value"] = toJS(_t.value());
217  res["data"] = toJS(_t.data(), 32);
218  res["nonce"] = toJS(_t.nonce());
219  res["hash"] = toJS(_t.sha3(WithSignature));
220  res["sighash"] = toJS(_t.sha3(WithoutSignature));
221  res["r"] = toJS(_t.signature().r);
222  res["s"] = toJS(_t.signature().s);
223  res["v"] = toJS(_t.signature().v);
224  return res;
225 }
226 
228 {
229  Json::Value res;
230  if (_t)
231  {
232  res["hash"] = toJS(_t.sha3());
233  res["input"] = toJS(_t.data());
234  res["to"] = _t.isCreation() ? Json::Value() : toJS(_t.receiveAddress());
235  res["from"] = toJS(_t.safeSender());
236  res["gas"] = toJS(_t.gas());
237  res["gasPrice"] = toJS(_t.gasPrice());
238  res["nonce"] = toJS(_t.nonce());
239  res["value"] = toJS(_t.value());
240  res["blockHash"] = toJS(_t.blockHash());
241  res["transactionIndex"] = toJS(_t.transactionIndex());
242  res["blockNumber"] = toJS(_t.blockNumber());
243  }
244  return res;
245 }
246 
248 {
249  Json::Value res;
250 
251  if (_e.isSpecial)
252  res = toJS(_e.special);
253  else
254  {
255  res = toJson(static_cast<dev::eth::LogEntry const&>(_e));
256  res["polarity"] = _e.polarity == BlockPolarity::Live ? true : false;
257  if (_e.mined)
258  {
259  res["type"] = "mined";
260  res["blockNumber"] = _e.blockNumber;
261  res["blockHash"] = toJS(_e.blockHash);
262  res["logIndex"] = _e.logIndex;
263  res["transactionHash"] = toJS(_e.transactionHash);
264  res["transactionIndex"] = _e.transactionIndex;
265  }
266  else
267  {
268  res["type"] = "pending";
269  res["blockNumber"] = Json::Value(Json::nullValue);
270  res["blockHash"] = Json::Value(Json::nullValue);
271  res["logIndex"] = Json::Value(Json::nullValue);
272  res["transactionHash"] = Json::Value(Json::nullValue);
273  res["transactionIndex"] = Json::Value(Json::nullValue);
274  }
275  }
276  return res;
277 }
278 
280 {
281  Json::Value res;
282  res["data"] = toJS(_e.data);
283  res["address"] = toJS(_e.address);
284  res["topics"] = Json::Value(Json::arrayValue);
285  for (auto const& t: _e.topics)
286  res["topics"].append(toJS(t));
287  return res;
288 }
289 
290 Json::Value toJson(std::unordered_map<h256, dev::eth::LocalisedLogEntries> const& _entriesByBlock, vector<h256> const& _order)
291 {
292  Json::Value res(Json::arrayValue);
293  for (auto const& i: _order)
294  {
295  auto entries = _entriesByBlock.at(i);
296  Json::Value currentBlock(Json::objectValue);
297  LocalisedLogEntry entry = entries[0];
298  if (entry.mined)
299  {
300 
301  currentBlock["blockNumber"] = entry.blockNumber;
302  currentBlock["blockHash"] = toJS(entry.blockHash);
303  currentBlock["type"] = "mined";
304  }
305  else
306  currentBlock["type"] = "pending";
307 
308  currentBlock["polarity"] = entry.polarity == BlockPolarity::Live ? true : false;
309  currentBlock["logs"] = Json::Value(Json::arrayValue);
310 
311  for (LocalisedLogEntry const& e: entries)
312  {
313  Json::Value log(Json::objectValue);
314  log["logIndex"] = e.logIndex;
315  log["transactionIndex"] = e.transactionIndex;
316  log["transactionHash"] = toJS(e.transactionHash);
317  log["address"] = toJS(e.address);
318  log["data"] = toJS(e.data);
319  log["topics"] = Json::Value(Json::arrayValue);
320  for (auto const& t: e.topics)
321  log["topics"].append(toJS(t));
322 
323  currentBlock["logs"].append(log);
324  }
325 
326  res.append(currentBlock);
327  }
328 
329  return res;
330 }
331 
333 {
334  vector<h256> order;
335  unordered_map <h256, LocalisedLogEntries> entriesByBlock;
336 
337  for (dev::eth::LocalisedLogEntry const& e: _entries)
338  {
339  if (e.isSpecial) // skip special log
340  continue;
341 
342  if (entriesByBlock.count(e.blockHash) == 0)
343  {
344  entriesByBlock[e.blockHash] = LocalisedLogEntries();
345  order.push_back(e.blockHash);
346  }
347 
348  entriesByBlock[e.blockHash].push_back(e);
349  }
350 
351  return toJson(entriesByBlock, order);
352 }
353 
355 {
357  if (!_json.isObject() || _json.empty())
358  return ret;
359 
360  if (!_json["from"].empty())
361  ret.from = jsToAddress(_json["from"].asString());
362  if (!_json["to"].empty() && _json["to"].asString() != "0x")
363  ret.to = jsToAddress(_json["to"].asString());
364  else
365  ret.creation = true;
366 
367  if (!_json["value"].empty())
368  ret.value = jsToU256(_json["value"].asString());
369 
370  if (!_json["gas"].empty())
371  ret.gas = jsToU256(_json["gas"].asString());
372 
373  if (!_json["gasPrice"].empty())
374  ret.gasPrice = jsToU256(_json["gasPrice"].asString());
375 
376  if (!_json["data"].empty()) // ethereum.js has preconstructed the data array
377  ret.data = jsToBytes(_json["data"].asString(), OnFailed::Throw);
378 
379  if (!_json["code"].empty())
380  ret.data = jsToBytes(_json["code"].asString(), OnFailed::Throw);
381 
382  if (!_json["nonce"].empty())
383  ret.nonce = jsToU256(_json["nonce"].asString());
384  return ret;
385 }
386 
388 {
389  dev::eth::LogFilter filter;
390  if (!_json.isObject() || _json.empty())
391  return filter;
392 
393  // check only !empty. it should throw exceptions if input params are incorrect
394  if (!_json["fromBlock"].empty())
395  filter.withEarliest(jsToFixed<32>(_json["fromBlock"].asString()));
396  if (!_json["toBlock"].empty())
397  filter.withLatest(jsToFixed<32>(_json["toBlock"].asString()));
398  if (!_json["address"].empty())
399  {
400  if (_json["address"].isArray())
401  for (auto i : _json["address"])
402  filter.address(jsToAddress(i.asString()));
403  else
404  filter.address(jsToAddress(_json["address"].asString()));
405  }
406  if (!_json["topics"].empty())
407  for (unsigned i = 0; i < _json["topics"].size(); i++)
408  {
409  if (_json["topics"][i].isArray())
410  {
411  for (auto t: _json["topics"][i])
412  if (!t.isNull())
413  filter.topic(i, jsToFixed<32>(t.asString()));
414  }
415  else if (!_json["topics"][i].isNull()) // if it is anything else then string, it should and will fail
416  filter.topic(i, jsToFixed<32>(_json["topics"][i].asString()));
417  }
418  return filter;
419 }
420 
421 // TODO: this should be removed once we decide to remove backward compatibility with old log filters
422 dev::eth::LogFilter toLogFilter(Json::Value const& _json, Interface const& _client) // commented to avoid warning. Uncomment once in use @ PoC-7.
423 {
424  dev::eth::LogFilter filter;
425  if (!_json.isObject() || _json.empty())
426  return filter;
427 
428  // check only !empty. it should throw exceptions if input params are incorrect
429  if (!_json["fromBlock"].empty())
430  filter.withEarliest(_client.hashFromNumber(jsToBlockNumber(_json["fromBlock"].asString())));
431  if (!_json["toBlock"].empty())
432  filter.withLatest(_client.hashFromNumber(jsToBlockNumber(_json["toBlock"].asString())));
433  if (!_json["address"].empty())
434  {
435  if (_json["address"].isArray())
436  for (auto i : _json["address"])
437  filter.address(jsToAddress(i.asString()));
438  else
439  filter.address(jsToAddress(_json["address"].asString()));
440  }
441  if (!_json["topics"].empty())
442  for (unsigned i = 0; i < _json["topics"].size(); i++)
443  {
444  if (_json["topics"][i].isArray())
445  {
446  for (auto t: _json["topics"][i])
447  if (!t.isNull())
448  filter.topic(i, jsToFixed<32>(t.asString()));
449  }
450  else if (!_json["topics"][i].isNull()) // if it is anything else then string, it should and will fail
451  filter.topic(i, jsToFixed<32>(_json["topics"][i].asString()));
452  }
453  return filter;
454 }
455 
456 }
457 
458 // ////////////////////////////////////////////////////////////////////////////////////
459 // shh
460 // ////////////////////////////////////////////////////////////////////////////////////
461 
462 namespace shh
463 {
464 
465 Json::Value toJson(h256 const& _h, shh::Envelope const& _e, shh::Message const& _m)
466 {
467  Json::Value res;
468  res["hash"] = toJS(_h);
469  res["expiry"] = toJS(_e.expiry());
470  res["sent"] = toJS(_e.sent());
471  res["ttl"] = toJS(_e.ttl());
472  res["workProved"] = toJS(_e.workProved());
473  res["topics"] = Json::Value(Json::arrayValue);
474  for (auto const& t: _e.topic())
475  res["topics"].append(toJS(t));
476  res["payload"] = toJS(_m.payload());
477  res["from"] = toJS(_m.from());
478  res["to"] = toJS(_m.to());
479  return res;
480 }
481 
483 {
484  shh::Message ret;
485  if (!_json["from"].empty())
486  ret.setFrom(jsToPublic(_json["from"].asString()));
487  if (!_json["to"].empty())
488  ret.setTo(jsToPublic(_json["to"].asString()));
489  if (!_json["payload"].empty())
490  ret.setPayload(jsToBytes(_json["payload"].asString()));
491  return ret;
492 }
493 
494 shh::Envelope toSealed(Json::Value const& _json, shh::Message const& _m, Secret const& _from)
495 {
496  unsigned ttl = 50;
497  unsigned workToProve = 50;
498  shh::BuildTopic bt;
499 
500  if (!_json["ttl"].empty())
501  ttl = jsToInt(_json["ttl"].asString());
502 
503  if (!_json["workToProve"].empty())
504  workToProve = jsToInt(_json["workToProve"].asString());
505 
506  if (!_json["topics"].empty())
507  for (auto i: _json["topics"])
508  {
509  if (i.isArray())
510  {
511  for (auto j: i)
512  if (!j.isNull())
513  bt.shift(jsToBytes(j.asString()));
514  }
515  else if (!i.isNull()) // if it is anything else then string, it should and will fail
516  bt.shift(jsToBytes(i.asString()));
517  }
518 
519  return _m.seal(_from, bt, ttl, workToProve);
520 }
521 
522 pair<shh::Topics, Public> toWatch(Json::Value const& _json)
523 {
524  shh::BuildTopic bt;
525  Public to;
526 
527  if (!_json["to"].empty())
528  to = jsToPublic(_json["to"].asString());
529 
530  if (!_json["topics"].empty())
531  for (auto i: _json["topics"])
532  bt.shift(jsToBytes(i.asString()));
533 
534  return make_pair(bt, to);
535 }
536 
537 }
538 
539 // ////////////////////////////////////////////////////////////////////////////////////
540 // rpc
541 // ////////////////////////////////////////////////////////////////////////////////////
542 
543 namespace rpc
544 {
545 h256 h256fromHex(string const& _s)
546 {
547  try
548  {
549  return h256(_s);
550  }
551  catch (boost::exception const&)
552  {
553  throw jsonrpc::JsonRpcException("Invalid hex-encoded string: " + _s);
554  }
555 }
556 }
557 
558 }
h256 blockHash
Definition: ExtVMFace.h:145
unsigned transactionIndex() const
Definition: Transaction.h:139
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Definition: Arith256.cpp:15
Address from() const
Synonym for safeSender().
Definition: Transaction.h:128
dev::eth::LogFilter toLogFilter(Json::Value const &_json, Interface const &_client)
Definition: JsonHelper.cpp:422
LogBloom const & logBloom() const
Definition: BlockHeader.h:165
std::string const host
Definition: Common.h:155
u256 const & number() const
Definition: BlockHeader.h:162
BlockNumber blockNumber() const
Definition: Transaction.h:140
unsigned transactionIndex
Definition: ExtVMFace.h:148
h256s TransactionHashes
Definition: BlockChain.h:81
Do include a signature.
Definition: Transaction.h:39
h256 const & stateRoot() const
Definition: BlockHeader.h:158
h256 hash(IncludeSeal _i=WithSeal) const
Definition: BlockHeader.cpp:64
Encapsulation of a block header.
Definition: BlockHeader.h:95
unsigned logIndex
Definition: ExtVMFace.h:149
LogBloom const & bloom() const
#define h(i)
Definition: sha.cpp:736
pair< shh::Topics, Public > toWatch(Json::Value const &_json)
Definition: JsonHelper.cpp:522
h256 const & transactionsRoot() const
Definition: BlockHeader.h:159
BlockNumber blockNumber
Definition: ExtVMFace.h:146
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
Definition: Transaction.h:121
std::map< std::string, std::string > notes
Definition: Common.h:160
virtual StringHashMap jsInfo(BlockHeader const &) const
Definition: SealEngine.h:54
LogFilter withEarliest(h256 _e)
Definition: LogFilter.h:78
virtual h256 hashFromNumber(BlockNumber _number) const =0
h256 const & stateRoot() const
h256 special
Definition: ExtVMFace.h:153
std::hash for asio::adress
Definition: Common.h:323
h256 const & sha3Uncles() const
Definition: BlockHeader.h:155
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
Definition: CommonData.cpp:141
AbridgedTopics const & topic() const
Definition: Message.h:76
bool mined
Definition: ExtVMFace.h:151
LogFilter withLatest(h256 _e)
Definition: LogFilter.h:79
TransactionSkeleton toTransactionSkeleton(Json::Value const &_json)
Definition: JsonHelper.cpp:354
unsigned BlockNumber
Definition: Common.h:72
std::chrono::steady_clock::duration lastPing
Definition: Common.h:157
bytes const & payload() const
Definition: Message.h:111
u256 const & gasUsed() const
SignatureStruct const & signature() const
Definition: Transaction.h:143
std::vector< LocalisedLogEntry > LocalisedLogEntries
Definition: ExtVMFace.h:156
h256 const & parentHash() const
Definition: BlockHeader.h:154
h256s UncleHashes
Definition: BlockChain.h:82
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
unsigned short const port
Definition: Common.h:156
Do not include a signature.
Definition: Transaction.h:38
unsigned expiry() const
Definition: Message.h:74
bool isCreation() const
Definition: Transaction.h:101
bool isSpecial
Definition: ExtVMFace.h:152
Config::Value_type Value
h256 transactionHash
Definition: ExtVMFace.h:147
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
Address const & contractAddress() const
bytes const & extraData() const
Definition: BlockHeader.h:164
LogFilter address(Address _a)
Definition: LogFilter.h:76
Address to() const
Synonym for receiveAddress().
Definition: Transaction.h:125
LocalisedLogEntries const & localisedLogs() const
LogFilter topic(unsigned _index, h256 const &_t)
Definition: LogFilter.h:77
h256s topics
Definition: ExtVMFace.h:106
bytes const & data() const
Definition: Transaction.h:131
h256 sha3(IncludeSignature _sig=WithSignature) const
Public jsToPublic(std::string const &_s)
Leniently convert string to Public (h512). Accepts integers, "0x" prefixing, non-exact length...
Definition: CommonJS.h:37
FixedHash< 32 > h256
Definition: FixedHash.h:340
void setPayload(bytes const &_payload)
Definition: Message.h:115
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
Definition: Common.h:125
unsigned sent() const
Definition: Message.h:73
void setTo(Public _to)
Definition: Message.h:114
unsigned workProved() const
Definition: Message.cpp:155
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
Address address
Definition: ExtVMFace.h:105
u256 const & timestamp() const
Definition: BlockHeader.h:156
Json::Value toJsonByBlock(LocalisedLogEntries const &_entries)
Definition: JsonHelper.cpp:332
Address const & safeSender() const noexcept
Like sender() but will never throw.
Definition: Transaction.cpp:98
h256 const & receiptsRoot() const
Definition: BlockHeader.h:160
h256 const & blockHash() const
Definition: Transaction.h:138
Address const & author() const
Definition: BlockHeader.h:157
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
Definition: JsonHelper.cpp:41
std::set< CapDesc > const caps
Definition: Common.h:158
bytes data
Definition: ExtVMFace.h:107
std::string const clientVersion
Definition: Common.h:154
An (unencrypted) message, constructed from the combination of an Envelope, and, potentially, a Secret key to decrypt the Message.
Definition: Message.h:100
u256 const & gasLimit() const
Definition: BlockHeader.h:163
shh::Message toMessage(Json::Value const &_json)
Definition: JsonHelper.cpp:482
#define e(i)
Definition: sha.cpp:733
Definition: ExtVMFace.h:112
Json::Value toJson(h256 const &_h, shh::Envelope const &_e, shh::Message const &_m)
Definition: JsonHelper.cpp:465
Envelope seal(Secret const &_from, Topics const &_topics, unsigned _ttl=50, unsigned _workToProve=50) const
Turn this message into a ditributable Envelope.
Definition: Message.cpp:100
Public to() const
Definition: Message.h:110
unsigned ttl() const
Definition: Message.h:75
Public from() const
Definition: Message.h:109
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
BlockPolarity polarity
Definition: ExtVMFace.h:150
h256 h256fromHex(string const &_s)
Definition: JsonHelper.cpp:545
shh::Envelope toSealed(Json::Value const &_json, shh::Message const &_m, Secret const &_from)
Definition: JsonHelper.cpp:494
u256 const & gasUsed() const
Definition: BlockHeader.h:161
BuildTopic & shift(T const &_r)
Definition: Common.h:82
u256 jsToU256(std::string const &_s)
Definition: CommonJS.h:110
#define DEV_IGNORE_EXCEPTIONS(X)
Definition: Common.h:63
std::string asString(bytes const &_b)
Converts byte array to a string containing the same (binary) data.
Definition: CommonData.h:79
Address receiveAddress() const
Definition: Transaction.h:122
std::string hex() const
Definition: FixedHash.h:130
LogEntries const & log() const
Definition: ExtVMFace.h:88
void setFrom(Public _from)
Definition: Message.h:113