mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Add RPC owner_info.
This commit is contained in:
@@ -49,7 +49,7 @@ uint256 Ledger::getBookBase(const uint160& uCurrencyIn, const uint160& uAccountI
|
||||
|
||||
assert(!bInNative || !bOutNative); // Stamps to stamps not allowed.
|
||||
assert(bInNative == uAccountIn.isZero()); // Make sure issuer is specified as needed.
|
||||
assert(bOutNative == uAccountOut.isZero()); // Make sure issuer is specified as needed.
|
||||
assert(bOutNative == uAccountOut.isZero()); // Make sure issuer is specified as needed.
|
||||
assert(uCurrencyIn != uCurrencyOut || uAccountIn != uAccountOut); // Currencies or accounts must differ.
|
||||
|
||||
Serializer s(82);
|
||||
|
||||
@@ -215,6 +215,51 @@ NicknameState::pointer NetworkOPs::getNicknameState(const uint256& uLedger, cons
|
||||
return mLedgerMaster->getLedgerByHash(uLedger)->getNicknameState(strNickname);
|
||||
}
|
||||
|
||||
//
|
||||
// Owner functions
|
||||
//
|
||||
|
||||
Json::Value NetworkOPs::getOwnerInfo(const uint256& uLedger, const NewcoinAddress& naAccount)
|
||||
{
|
||||
Json::Value jvObjects(Json::arrayValue);
|
||||
|
||||
Ledger::pointer lpLedger = mLedgerMaster->getLedgerByHash(uLedger);
|
||||
uint256 uRootIndex = lpLedger->getOwnerDirIndex(naAccount.getAccountID());
|
||||
|
||||
LedgerStateParms lspNode = lepNONE;
|
||||
SLE::pointer sleNode = lpLedger->getDirNode(lspNode, uRootIndex);
|
||||
|
||||
if (sleNode)
|
||||
{
|
||||
uint64 uNodeDir;
|
||||
|
||||
do
|
||||
{
|
||||
STVector256 svIndexes = sleNode->getIFieldV256(sfIndexes);
|
||||
std::vector<uint256>& vuiIndexes = svIndexes.peekValue();
|
||||
|
||||
BOOST_FOREACH(uint256& uDirEntry, vuiIndexes)
|
||||
{
|
||||
LedgerStateParms lspOffer = lepNONE;
|
||||
SLE::pointer sleOffer = lpLedger->getOffer(lspOffer, uDirEntry);
|
||||
|
||||
jvObjects.append(sleOffer->getJson(0));
|
||||
}
|
||||
|
||||
uNodeDir = sleNode->getIFieldU64(sfIndexNext);
|
||||
if (uNodeDir)
|
||||
{
|
||||
lspNode = lepNONE;
|
||||
sleNode = lpLedger->getDirNode(lspNode, Ledger::getDirNodeIndex(uRootIndex, uNodeDir));
|
||||
|
||||
assert(sleNode);
|
||||
}
|
||||
} while (uNodeDir);
|
||||
}
|
||||
|
||||
return jvObjects;
|
||||
}
|
||||
|
||||
//
|
||||
// Ripple functions
|
||||
//
|
||||
|
||||
@@ -118,6 +118,12 @@ public:
|
||||
|
||||
NicknameState::pointer getNicknameState(const uint256& uLedger, const std::string& strNickname);
|
||||
|
||||
//
|
||||
// Owner functions
|
||||
//
|
||||
|
||||
Json::Value getOwnerInfo(const uint256& uLedger, const NewcoinAddress& naAccount);
|
||||
|
||||
//
|
||||
// Ripple functions
|
||||
//
|
||||
|
||||
@@ -948,6 +948,40 @@ Json::Value RPCServer::doOfferCancel(const Json::Value ¶ms)
|
||||
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 ¶ms)
|
||||
@@ -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 },
|
||||
|
||||
@@ -139,6 +139,7 @@ private:
|
||||
Json::Value doNicknameSet(const Json::Value& params);
|
||||
Json::Value doOfferCreate(const Json::Value& params);
|
||||
Json::Value doOfferCancel(const Json::Value& params);
|
||||
Json::Value doOwnerInfo(const Json::Value& params);
|
||||
Json::Value doPasswordFund(const Json::Value& params);
|
||||
Json::Value doPasswordSet(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
|
||||
Reference in New Issue
Block a user