Add RPC owner_info.

This commit is contained in:
Arthur Britto
2012-07-14 17:21:43 -07:00
parent d6af13330a
commit 6feb16709e
5 changed files with 88 additions and 1 deletions

View File

@@ -948,6 +948,40 @@ Json::Value RPCServer::doOfferCancel(const Json::Value &params)
return obj;
}
// owner_info <account>|<nickname>|<account_public_key>
Json::Value RPCServer::doOwnerInfo(const Json::Value& params)
{
std::string strIdent = params[0u].asString();
bool bIndex;
int iIndex = 2 == params.size()? lexical_cast_s<int>(params[1u].asString()) : 0;
NewcoinAddress naAccount;
Json::Value ret;
// Get info on account.
uint256 uAccepted = mNetOps->getClosedLedger();
Json::Value jAccepted = accountFromString(uAccepted, naAccount, bIndex, strIdent, iIndex);
if (jAccepted.empty())
{
jAccepted["offers"] = mNetOps->getOwnerInfo(uAccepted, naAccount);
}
ret["accepted"] = jAccepted;
uint256 uCurrent = mNetOps->getCurrentLedger();
Json::Value jCurrent = accountFromString(uCurrent, naAccount, bIndex, strIdent, iIndex);
if (jCurrent.empty())
{
jCurrent["offers"] = mNetOps->getOwnerInfo(uCurrent, naAccount);
}
ret["current"] = jCurrent;
return ret;
}
// password_fund <seed> <paying_account> [<account>]
// YYY Make making account default to first account for seed.
Json::Value RPCServer::doPasswordFund(const Json::Value &params)
@@ -2105,6 +2139,7 @@ Json::Value RPCServer::doCommand(const std::string& command, Json::Value& params
{ "nickname_set", &RPCServer::doNicknameSet, 2, 3, false, optCurrent },
{ "offer_create", &RPCServer::doOfferCreate, 9, 10, false, optCurrent },
{ "offer_cancel", &RPCServer::doOfferCancel, 3, 3, false, optCurrent },
{ "owner_info", &RPCServer::doOwnerInfo, 1, 2, false, optCurrent },
{ "password_fund", &RPCServer::doPasswordFund, 2, 3, false, optCurrent },
{ "password_set", &RPCServer::doPasswordSet, 2, 3, false, optNetwork },
{ "peers", &RPCServer::doPeers, 0, 0, true },