25 #include <jsonrpccpp/common/exception.h> 53 m_ethAccounts(_ethAccounts)
73 catch (InvalidSealEngine&)
75 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
85 catch (InvalidSealEngine&)
87 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
115 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
127 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
139 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
151 if (pending.sender() == account)
153 ours.push_back(pending);
170 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
178 h256 blockHash = jsToFixed<32>(_blockHash);
182 return toJS(
client()->transactionCount(blockHash));
186 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
195 if (!
client()->isKnown(blockNumber))
202 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
210 h256 blockHash = jsToFixed<32>(_blockHash);
218 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
227 if (!
client()->isKnown(blockNumber))
230 return toJS(
client()->uncleCount(blockNumber));
234 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
246 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
265 case TransactionRepercussion::Success:
267 case TransactionRepercussion::ProxySuccess:
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."));
279 catch (JsonRpcException&)
285 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
287 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
300 case TransactionRepercussion::Success:
302 case TransactionRepercussion::ProxySuccess:
306 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
311 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
323 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
341 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
356 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
366 int64_t gas =
static_cast<int64_t
>(t.
gas);
371 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
385 h256 h = jsToFixed<32>(_blockHash);
389 if (_includeTransactions)
396 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
405 if (!
client()->isKnown(h))
408 if (_includeTransactions)
415 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
423 h256 h = jsToFixed<32>(_transactionHash);
431 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
439 h256 bh = jsToFixed<32>(_blockHash);
440 unsigned ti =
jsToInt(_transactionIndex);
441 if (!
client()->isKnownTransaction(bh, ti))
448 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
458 unsigned ti =
jsToInt(_transactionIndex);
459 if (!
client()->isKnownTransaction(bh, ti))
466 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
474 h256 h = jsToFixed<32>(_transactionHash);
478 return toJson(
client()->localisedTransactionReceipt(h));
482 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
494 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
506 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
518 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
530 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
536 h256 filter = dev::eth::ChainChangedFilter;
542 h256 filter = dev::eth::PendingChangedFilter;
554 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
570 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
586 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
598 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
610 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
622 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
634 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
644 ret.append(
toJS(get<0>(r)));
645 ret.append(
toJS(get<1>(r)));
646 ret.append(
toJS(get<2>(r)));
651 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
676 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
689 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
701 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
713 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
731 BOOST_THROW_EXCEPTION(JsonRpcException(Errors::ERROR_RPC_INVALID_PARAMS));
Adapted from code found on http://stackoverflow.com/questions/180947/base64-decode-snippet-in-c Origi...
virtual std::string eth_getStorageAt(std::string const &_address, std::string const &_position, std::string const &_blockNumber) override
unsigned startBlockNumber
virtual Json::Value eth_getBlockTransactionCountByNumber(std::string const &_blockNumber) override
virtual std::string eth_blockNumber() override
const unsigned c_protocolVersion
Current protocol version.
virtual Json::Value eth_getTransactionByHash(std::string const &_transactionHash) override
virtual std::string eth_signTransaction(Json::Value const &_transaction) override
Manages real accounts (where we know the secret key) and proxy accounts (where transactions to be sen...
virtual std::string eth_getTransactionCount(std::string const &_address, std::string const &_blockNumber) override
virtual Json::Value eth_getTransactionReceipt(std::string const &_transactionHash) override
EthashClient & asEthashClient(Interface &_c)
virtual std::string eth_newFilter(Json::Value const &_json) override
eth::AccountHolder & m_ethAccounts
virtual Json::Value eth_getLogs(Json::Value const &_json) override
virtual bool isKnown(BlockNumber _block) const =0
virtual Json::Value eth_inspectTransaction(std::string const &_rlp) override
virtual std::string eth_register(std::string const &_address) override
std::vector< Transaction > Transactions
Nice name for vector of Transaction.
virtual std::string eth_hashrate() override
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
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
void submitExternalHashrate(u256 const &_rate, h256 const &_id)
virtual bool eth_submitHashrate(std::string const &_hashes, std::string const &_id) override
virtual std::string eth_estimateGas(Json::Value const &_json) override
std::string toString(string32 const &_s)
Make normal string from fixed-length string.
virtual Json::Value eth_getFilterChanges(std::string const &_filterId) override
Description of the result of executing a transaction.
virtual std::string eth_getStorageRoot(std::string const &_address, std::string const &_blockNumber) override
virtual Json::Value eth_getLogsEx(Json::Value const &_json) override
TransactionSkeleton toTransactionSkeleton(Json::Value const &_json)
virtual std::string eth_newFilterEx(Json::Value const &_json) override
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...
virtual std::string eth_gasPrice() override
virtual bool eth_unregister(std::string const &_accountId) override
virtual Json::Value eth_getUncleCountByBlockHash(std::string const &_blockHash) override
virtual bool isKnownTransaction(h256 const &_transactionHash) const =0
virtual Json::Value eth_getUncleByBlockNumberAndIndex(std::string const &_blockNumber, std::string const &_uncleIndex) override
eth::Interface * client()
virtual Json::Value eth_syncing() override
virtual bool eth_uninstallFilter(std::string const &_filterId) override
virtual Json::Value eth_accounts() override
virtual Json::Value eth_fetchQueuedTransactions(std::string const &_accountId) override
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)
Address jsToAddress(std::string const &_s)
Leniently convert string to Address (h160). Accepts integers, "0x" prefixing, non-exact length...
virtual Json::Value eth_getTransactionByBlockHashAndIndex(std::string const &_blockHash, std::string const &_transactionIndex) override
bool isMining() const
Are we mining now?
virtual std::string eth_sendTransaction(Json::Value const &_json) override
bytes toCompactBigEndian(T _val, unsigned _min=0)
Convenience function for toBigEndian.
dev::eth::LogFilter toLogFilter(Json::Value const &_json)
Fixed-size raw-byte array container type, with an API optimised for storing hashes.
h256 sha3(IncludeSignature _sig=WithSignature) const
virtual std::string eth_call(Json::Value const &_json, std::string const &_blockNumber) override
std::vector< eth::TransactionSkeleton > const & queuedTransactions(int _id) const
virtual Json::Value eth_getWork() override
virtual Json::Value eth_getTransactionByBlockNumberAndIndex(std::string const &_blockNumber, std::string const &_transactionIndex) override
void setTransactionDefaults(eth::TransactionSkeleton &_t)
virtual LocalisedLogEntries checkWatch(unsigned _watchId)=0
TransactionRepercussion r
const unsigned SensibleHttpPort
virtual bool eth_flush() override
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)
virtual std::string eth_getCode(std::string const &_address, std::string const &_blockNumber) override
virtual SyncStatus syncStatus() const =0
Get some information on the block queue.
Json::Value toJson(unordered_map< u256, u256 > const &_storage)
virtual Json::Value eth_getBlockByHash(std::string const &_blockHash, bool _includeTransactions) override
unsigned currentBlockNumber
virtual std::string eth_pendingTransactions() override
virtual std::string eth_sendRawTransaction(std::string const &_rlp) override
virtual std::string eth_coinbase() override
virtual std::string eth_newPendingTransactionFilter() override
virtual bool eth_mining() override
const unsigned SensibleHttpThreads
virtual std::string eth_protocolVersion() override
virtual Json::Value eth_getFilterLogs(std::string const &_filterId) override
virtual Json::Value eth_getUncleByBlockHashAndIndex(std::string const &_blockHash, std::string const &_uncleIndex) override
virtual std::string eth_getBalance(std::string const &_address, std::string const &_blockNumber) override
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...
bool removeProxyAccount(unsigned _id)
virtual std::string eth_newBlockFilter() override
unsigned highestBlockNumber
virtual Json::Value eth_getUncleCountByBlockNumber(std::string const &_blockNumber) override
virtual Json::Value eth_getFilterLogsEx(std::string const &_filterId) override
u256 jsToU256(std::string const &_s)
virtual bool eth_submitWork(std::string const &_nonce, std::string const &, std::string const &_mixHash) override
virtual Json::Value eth_getFilterChangesEx(std::string const &_filterId) override
Address const & defaultTransactAccount() const
Addresses allAccounts() const
virtual bool uninstallWatch(unsigned _watchId)=0
virtual Json::Value eth_getBlockTransactionCountByHash(std::string const &_blockHash) override
virtual void flushTransactions()=0
Blocks until all pending transactions have been processed.