diff --git a/libethrpc/EthStubServer.cpp b/libethrpc/EthStubServer.cpp index 3e579116e..f7083aa45 100644 --- a/libethrpc/EthStubServer.cpp +++ b/libethrpc/EthStubServer.cpp @@ -79,6 +79,20 @@ static Json::Value toJson(const dev::eth::PastMessages& pms) return res; } +static Json::Value toJson(const dev::eth::Transaction& t) +{ + Json::Value res; + res["hash"] = toJS(t.sha3()); + res["input"] = jsFromBinary(t.data); + res["to"] = toJS(t.receiveAddress); + res["from"] = toJS(t.sender()); + res["gas"] = (int)t.gas; + res["gasPrice"] = toJS(t.gasPrice); + res["nonce"] = toJS(t.nonce); + res["value"] = toJS(t.value); + return res; +} + EthStubServer::EthStubServer(jsonrpc::AbstractServerConnector* _conn, WebThreeDirect& _web3): AbstractEthStubServer(_conn), m_web3(_web3) @@ -380,18 +394,7 @@ Json::Value EthStubServer::transaction(const int &i, const string &numberOrHash) } auto n = jsToU256(numberOrHash); auto h = n < client()->number() ? client()->hashFromNumber((unsigned)n) : jsToFixed<32>(numberOrHash); - dev::eth::Transaction t = client()->transaction(h, i); - Json::Value res; - res["hash"] = boost::lexical_cast(t.sha3()); - res["input"] = jsFromBinary(t.data); - res["to"] = boost::lexical_cast(t.receiveAddress); - res["from"] = boost::lexical_cast(t.sender()); - res["gas"] = (int)t.gas; - res["gasPrice"] = boost::lexical_cast(t.gasPrice); - res["nonce"] = boost::lexical_cast(t.nonce); - res["value"] = boost::lexical_cast(t.value); - - return res; + return toJson(client()->transaction(h, i)); } Json::Value EthStubServer::uncle(const int &i, const string &numberOrHash) diff --git a/test/jsonrpc.cpp b/test/jsonrpc.cpp index f04e3109d..80354bc33 100644 --- a/test/jsonrpc.cpp +++ b/test/jsonrpc.cpp @@ -1,6 +1,6 @@ -//#if ETH_JSONRPC && 1 +#if ETH_JSONRPC && 1 #include #include @@ -286,13 +286,18 @@ BOOST_AUTO_TEST_CASE(jsonrpc_transact) dev::eth::mine(*(web3.ethereum()), 1); auto balance2 = web3.ethereum()->balanceAt(receiver.address()); + auto number = web3.ethereum()->number(); BOOST_REQUIRE(balance2 > 0); BOOST_CHECK_EQUAL(txAmount, balance2); + + // auto ax = jsToFixed(number); + // Json::Value p = jsonrpcClient->transaction(0, jsToFixed(number)); + // TODO, check transactions } BOOST_AUTO_TEST_CASE(jsonrpc_transaction) { - + } @@ -310,7 +315,7 @@ BOOST_AUTO_TEST_CASE(jsonrpc_watch) } -//#endif +#endif