1 #include <jsonrpccpp/common/exception.h> 19 m_keyManager(_keyManager),
42 ret[
"future"] = (int)bqs.
future;
43 ret[
"unknown"] = (
int)bqs.
unknown;
44 ret[
"bad"] = (int)bqs.
bad;
70 case QueueStatus::Ready:
72 case QueueStatus::Importing:
74 case QueueStatus::UnknownParent:
75 return "unknown parent";
76 case QueueStatus::Bad:
101 u256 pendingtotal = 0;
109 a[
"beneficiary"] =
true;
111 a[
"balance"] =
toJS(latest);
113 a[
"pending"] =
toJS(pending);
117 pendingtotal += pending;
119 ret[
"total"] =
toJS(total);
121 ret[
"pendingtotal"] =
toJS(pendingtotal);
129 if (!_info.isMember(
"name"))
130 throw jsonrpc::JsonRpcException(
"No member found: name");
131 string name = _info[
"name"].asString();
132 auto s = ICAP::createDirect();
134 if (_info.isMember(
"password"))
136 string password = _info[
"password"].asString();
137 string hint = _info[
"passwordHint"].asString();
144 ret[
"uuid"] =
toUUID(uuid);
157 if (!isHash<Address>(_address))
158 throw jsonrpc::JsonRpcException(
"Invalid address given.");
171 if (isHash<h256>(_blockNumberOrHash))
172 return h256(_blockNumberOrHash.substr(_blockNumberOrHash.size() - 64, 64));
179 throw jsonrpc::JsonRpcException(
"Invalid argument");
189 ret[
"enact"] = ps.
enact;
190 ret[
"verify"] = ps.
verify;
202 throw jsonrpc::JsonRpcException(
"Negative index");
204 if ((
unsigned)_txIndex < block.
pending().size())
207 State s(State::Null);
217 Json::Reader().parse(st.
json(), ret);
221 cwarn << diagnostic_information(_e);
232 throw jsonrpc::JsonRpcException(
"Negative index");
235 throw jsonrpc::JsonRpcException(
"Invalid/unknown block.");
237 if ((
unsigned)_txIndex >= rs.receipts.size())
238 throw jsonrpc::JsonRpcException(
"Index too large.");
239 return toJson(rs.receipts[_txIndex]);
260 else if (isHash<Address>(_uuidOrAddress))
263 throw jsonrpc::JsonRpcException(
"Invalid UUID or address");
293 throw jsonrpc::JsonRpcException(
"Hashrate not available - blockchain does not support mining.");
h128 fromUUID(std::string const &_uuid)
void stopSealing() override
Stop sealing.
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
virtual bool admin_eth_setMiningBenefactor(std::string const &_uuidOrAddress, std::string const &_session) override
virtual bool miner_setEtherbase(std::string const &_uuidOrAddress) override
u256 hashrate() const
The hashrate...
virtual Json::Value admin_eth_findBlock(std::string const &_blockHash, std::string const &_session) override
virtual bool admin_eth_setMining(bool _on, std::string const &_session) override
std::string const & accountName(Address const &_address) const
BlockHeader info(h256 const &_hash) const
Get the partial-header of a block (or the most recent mined if none given). Thread-safe.
eth::TrivialGasPricer & m_gp
dev::eth::Block block(h256 const &_blockHash, PopulationStatistics *o_stats) const
Get the block.
virtual bool miner_start(int _threads) override
virtual Json::Value admin_eth_vmTrace(std::string const &_blockNumberOrHash, int _txIndex, std::string const &_session) override
EthashClient & asEthashClient(Interface &_c)
h256 blockHash(std::string const &_blockNumberOrHash) const
virtual Json::Value admin_eth_inspect(std::string const &_address, std::string const &_session) override
virtual std::string miner_hashrate() override
BlockReceipts receipts(h256 const &_hash) const
Get the transactions' receipts of a block (or the most recent mined if none given).
virtual u256 countAt(Address _a, BlockNumber _block) const override
h160 Address
An Ethereum address: 20 bytes.
virtual bytes codeAt(Address _a, BlockNumber _block) const override
virtual bool admin_eth_blockQueueRetryUnknown(std::string const &_session) override
void setExtraData(bytes const &_extraData)
Set the extra data that goes into sealed blocks.
virtual bool miner_setExtra(std::string const &_extraData) override
std::hash for asio::adress
virtual bool miner_setGasPrice(std::string const &_gasPrice) override
eth::KeyManager & m_keyManager
QueueStatus blockStatus(h256 const &_h) const
Get some infomration on the given block's status regarding us.
virtual u256 balanceAt(Address _a, BlockNumber _block) const override
Model of an Ethereum state, essentially a facade for the trie.
virtual std::map< h256, std::pair< u256, u256 > > storageAt(Address _a, BlockNumber _block) const override
h128 import(Secret const &_s, std::string const &_accountName, std::string const &_pass, std::string const &_passwordHint)
Active model of a block within the block chain.
bytes fromHex(std::string const &_s, WhenError _throw=WhenError::DontThrow)
std::string json(bool _styled=false) const
Base class for all exceptions.
High-level manager of password-encrypted keys for Ethereum.
BlockChain const & blockChain() const
Get the object representing the current canonical blockchain.
h256 numberHash(unsigned _i) const
Get the hash for a given block's number.
std::string toJS(FixedHash< S > const &_h)
virtual Json::Value admin_eth_allAccounts(std::string const &_session) override
virtual Json::Value admin_eth_getReceiptByHashAndIndex(std::string const &_blockNumberOrHash, int _txIndex, std::string const &_session) override
Main API hub for interfacing with Ethereum.
bytes asBytes(std::string const &_b)
Converts a string to a byte array containing the string's (byte) data.
virtual Json::Value admin_eth_blockQueueStatus(std::string const &_session) override
h256 firstUnknown() const
Return first block with an unknown parent.
Message-call/contract-creation executor; useful for executing transactions.
boost::multiprecision::number< boost::multiprecision::cpp_int_backend< 256, 256, boost::multiprecision::unsigned_magnitude, boost::multiprecision::unchecked, void >> u256
bool isKnown(h256 const &_hash, bool _isCurrent=true) const
Returns true if the given block is known (though not necessarily a part of the canon chain)...
std::string formatBalance(bigint const &_b)
User-friendly string representation of the amount _b in wei.
virtual bool admin_eth_setBidPrice(std::string const &_wei, std::string const &_session) override
Transactions const & pending() const
Get the list of pending transactions.
Encodes a transaction, ready to be exported to or freshly imported from RLP.
Address toAddress(Public const &_public)
Convert a public key to address.
void setBid(u256 const &_bid)
BlockQueueStatus status() const
Get some infomration on the current status.
virtual Json::Value admin_eth_newAccount(const Json::Value &_info, std::string const &_session) override
virtual bool admin_eth_setAskPrice(std::string const &_wei, std::string const &_session) override
virtual bool miner_stop() override
Address address(h128 const &_uuid) const
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
void retryUnknown()
Retries all blocks with unknown parents.
void setAsk(u256 const &_ask)
virtual Json::Value admin_eth_reprocess(std::string const &_blockNumberOrHash, std::string const &_session) override
std::function< void(Address const &)> m_setMiningBenefactor
struct evm_uint160be address(struct evm_env *env)
void startSealing() override
Start sealing.
Addresses accounts() const
virtual std::string admin_eth_blockQueueFirstUnknown(std::string const &_session) override
BlockQueue const & blockQueue() const
Get the block queue.
u256 jsToU256(std::string const &_s)
virtual void setAuthor(Address const &_us) override
Set the block author address.
std::string toUUID(h128 const &_uuid)