const& _args, bool _canFail)
{
string request = "{\"jsonrpc\":\"2.0\",\"method\":\"" + _methodName + "\",\"params\":[";
for (size_t i = 0; i < _args.size(); ++i)
{
request += _args[i];
if (i + 1 != _args.size())
request += ", ";
}
request += "],\"id\":" + to_string(m_rpcSequence) + "}";
++m_rpcSequence;
//cout << "Request: " << request << endl;
string reply = m_ipcSocket.sendRequest(request);
//cout << "Reply: " << reply << endl;
Json::Value result;
Json::Reader().parse(reply, result, false);
if (result.isMember("error"))
{
if (_canFail)
return Json::Value();
BOOST_FAIL("Error on JSON-RPC call: " + result["error"]["message"].asString());
}
return result["result"];
}
string const& RPCSession::accountCreateIfNotExists(size_t _id)
{
if (_id >= m_accounts.size())
{
m_accounts.push_back(personal_newAccount(""));
personal_unlockAccount(m_accounts.back(), "", 100000);
}
return m_accounts[_id];
}
RPCSession::RPCSession(const string& _path):
m_ipcSocket(_path)
{
string account = personal_newAccount("");
personal_unlockAccount(account, "", 100000);
m_accounts.push_back(account);
test_setChainParams(m_accounts);
}
string RPCSession::TransactionData::toJson() const
{
Json::Value json;
json["from"] = (from.length() == 20) ? "0x" + from : from;
json["to"] = (to.length() == 20 || to == "") ? "0x" + to : to;
json["gas"] = gas;
json["gasprice"] = gasPrice;
json["value"] = value;
json["data"] = data;
return Json::FastWriter().write(json);
}
d>1 | -0/+1 |
* | Change BUILD_DEPENDS to EXTRACT_DEPENDS and unbreak. | knu | 2003-03-11 | 1 | -2/+2 |
* | De-pkg-comment my non-ruby ports as well. | knu | 2003-02-18 | 2 | -1/+1 |
* | Update SQLRelay to 0.30. | knu | 2002-02-24 | 1 | -1/+2 |
* | Use ${ECHO_CMD} instead of ${ECHO} where you mean the echo command; | knu | 2002-01-29 | 1 | -2/+2 |