33 #include <jsonrpccpp/common/exception.h> 44 for (
auto i: _storage)
52 for (
auto i: _storage)
59 return toJS(_address);
73 ret[
"id"] = _p.
id.
hex();
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));
114 for (
auto const& i: _sealer->
jsInfo(_bi))
115 res[i.first] = i.second;
134 res[
"blockHash"] =
toJS(_location.first);
135 res[
"transactionIndex"] =
toJS(_location.second);
136 res[
"blockNumber"] =
toJS(_blockNumber);
149 res[
"uncles"].append(
toJS(
h));
150 res[
"transactions"] =
Json::Value(Json::arrayValue);
151 for (
unsigned i = 0; i < _ts.size(); i++)
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));
198 res[
"transactionHash"] =
toJS(_t.
hash());
255 res =
toJson(static_cast<dev::eth::LogEntry const&>(_e));
256 res[
"polarity"] = _e.
polarity == BlockPolarity::Live ?
true :
false;
259 res[
"type"] =
"mined";
268 res[
"type"] =
"pending";
272 res[
"transactionHash"] =
Json::Value(Json::nullValue);
273 res[
"transactionIndex"] =
Json::Value(Json::nullValue);
285 for (
auto const& t: _e.
topics)
286 res[
"topics"].append(
toJS(t));
290 Json::Value toJson(std::unordered_map<h256, dev::eth::LocalisedLogEntries>
const& _entriesByBlock, vector<h256>
const& _order)
293 for (
auto const& i: _order)
295 auto entries = _entriesByBlock.at(i);
303 currentBlock[
"type"] =
"mined";
306 currentBlock[
"type"] =
"pending";
308 currentBlock[
"polarity"] = entry.
polarity == BlockPolarity::Live ?
true :
false;
309 currentBlock[
"logs"] =
Json::Value(Json::arrayValue);
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);
320 for (
auto const& t:
e.topics)
321 log[
"topics"].append(
toJS(t));
323 currentBlock[
"logs"].append(log);
326 res.append(currentBlock);
335 unordered_map <h256, LocalisedLogEntries> entriesByBlock;
342 if (entriesByBlock.count(
e.blockHash) == 0)
345 order.push_back(
e.blockHash);
348 entriesByBlock[
e.blockHash].push_back(
e);
351 return toJson(entriesByBlock, order);
357 if (!_json.isObject() || _json.empty())
360 if (!_json[
"from"].empty())
362 if (!_json[
"to"].empty() && _json[
"to"].asString() !=
"0x")
367 if (!_json[
"value"].empty())
370 if (!_json[
"gas"].empty())
373 if (!_json[
"gasPrice"].empty())
376 if (!_json[
"data"].empty())
379 if (!_json[
"code"].empty())
382 if (!_json[
"nonce"].empty())
390 if (!_json.isObject() || _json.empty())
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())
400 if (_json[
"address"].isArray())
401 for (
auto i : _json[
"address"])
406 if (!_json[
"topics"].empty())
407 for (
unsigned i = 0; i < _json[
"topics"].size(); i++)
409 if (_json[
"topics"][i].isArray())
411 for (
auto t: _json[
"topics"][i])
413 filter.
topic(i, jsToFixed<32>(t.asString()));
415 else if (!_json[
"topics"][i].isNull())
416 filter.
topic(i, jsToFixed<32>(_json[
"topics"][i].asString()));
425 if (!_json.isObject() || _json.empty())
429 if (!_json[
"fromBlock"].empty())
431 if (!_json[
"toBlock"].empty())
433 if (!_json[
"address"].empty())
435 if (_json[
"address"].isArray())
436 for (
auto i : _json[
"address"])
441 if (!_json[
"topics"].empty())
442 for (
unsigned i = 0; i < _json[
"topics"].size(); i++)
444 if (_json[
"topics"][i].isArray())
446 for (
auto t: _json[
"topics"][i])
448 filter.
topic(i, jsToFixed<32>(t.asString()));
450 else if (!_json[
"topics"][i].isNull())
451 filter.
topic(i, jsToFixed<32>(_json[
"topics"][i].asString()));
468 res[
"hash"] =
toJS(_h);
474 for (
auto const& t: _e.
topic())
475 res[
"topics"].append(
toJS(t));
478 res[
"to"] =
toJS(_m.
to());
485 if (!_json[
"from"].empty())
487 if (!_json[
"to"].empty())
489 if (!_json[
"payload"].empty())
497 unsigned workToProve = 50;
500 if (!_json[
"ttl"].empty())
503 if (!_json[
"workToProve"].empty())
506 if (!_json[
"topics"].empty())
507 for (
auto i: _json[
"topics"])
515 else if (!i.isNull())
519 return _m.
seal(_from, bt, ttl, workToProve);
527 if (!_json[
"to"].empty())
530 if (!_json[
"topics"].empty())
531 for (
auto i: _json[
"topics"])
534 return make_pair(bt, to);
551 catch (boost::exception
const&)
553 throw jsonrpc::JsonRpcException(
"Invalid hex-encoded string: " + _s);
unsigned transactionIndex() const
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
Address from() const
Synonym for safeSender().
h256 const & blockHash() const
dev::eth::LogFilter toLogFilter(Json::Value const &_json, Interface const &_client)
h256 const & hash() const
BlockNumber blockNumber() const
unsigned transactionIndex
unsigned transactionIndex() const
LogBloom const & bloom() const
pair< shh::Topics, Public > toWatch(Json::Value const &_json)
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
std::map< std::string, std::string > notes
virtual StringHashMap jsInfo(BlockHeader const &) const
LogFilter withEarliest(h256 _e)
virtual h256 hashFromNumber(BlockNumber _number) const =0
h256 const & stateRoot() const
std::hash for asio::adress
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
AbridgedTopics const & topic() const
LogFilter withLatest(h256 _e)
TransactionSkeleton toTransactionSkeleton(Json::Value const &_json)
std::chrono::steady_clock::duration lastPing
bytes const & payload() const
u256 const & gasUsed() const
SignatureStruct const & signature() const
std::vector< LocalisedLogEntry > LocalisedLogEntries
BlockNumber jsToBlockNumber(std::string const &_js)
Convert to a block number, a bit like jsToInt, except that it correctly recognises "pending" and "lat...
unsigned short const port
Do not include a signature.
std::string toJS(FixedHash< S > const &_h)
Address jsToAddress(std::string const &_s)
Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length...
Address const & contractAddress() const
LogFilter address(Address _a)
Address to() const
Synonym for receiveAddress().
LocalisedLogEntries const & localisedLogs() const
LogFilter topic(unsigned _index, h256 const &_t)
bytes const & data() const
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...
void setPayload(bytes const &_payload)
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
unsigned workProved() const
Encodes a transaction, ready to be exported to or freshly imported from RLP.
bytes jsToBytes(string const &_s, OnFailed _f)
Main API hub for interfacing with Ethereum.
Json::Value toJsonByBlock(LocalisedLogEntries const &_entries)
Address const & safeSender() const noexcept
Like sender() but will never throw.
h256 const & blockHash() const
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
std::set< CapDesc > const caps
std::string const clientVersion
An (unencrypted) message, constructed from the combination of an Envelope, and, potentially, a Secret key to decrypt the Message.
shh::Message toMessage(Json::Value const &_json)
Json::Value toJson(h256 const &_h, shh::Envelope const &_e, shh::Message const &_m)
Envelope seal(Secret const &_from, Topics const &_topics, unsigned _ttl=50, unsigned _workToProve=50) const
Turn this message into a ditributable Envelope.
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...
h256 h256fromHex(string const &_s)
shh::Envelope toSealed(Json::Value const &_json, shh::Message const &_m, Secret const &_from)
BlockNumber blockNumber() const
BuildTopic & shift(T const &_r)
u256 jsToU256(std::string const &_s)
#define DEV_IGNORE_EXCEPTIONS(X)
std::string asString(bytes const &_b)
Converts byte array to a string containing the same (binary) data.
Address receiveAddress() const
LogEntries const & log() const
void setFrom(Public _from)