Remove jss::account_index and jss::peer_index.

This commit is contained in:
Tom Ritchford
2015-06-26 18:11:32 -04:00
committed by Vinnie Falco
parent 1e7588d0ab
commit ea67a2d051
12 changed files with 33 additions and 130 deletions

View File

@@ -569,9 +569,6 @@ private:
if (bPeer && iCursor >= 2)
strPeer = jvParams[iCursor].asString ();
int iIndex = 0;
// int iIndex = jvParams.size() >= 2 ? beast::lexicalCast <int>(jvParams[1u].asString()) : 0;
RippleAddress raAddress;
if (! raAddress.setAccountPublic (strIdent) &&
@@ -587,9 +584,6 @@ private:
if (bStrict)
jvRequest[jss::strict] = 1;
if (iIndex)
jvRequest[jss::account_index] = iIndex;
if (!strPeer.empty ())
{
RippleAddress raPeer;

View File

@@ -65,10 +65,6 @@ JSS ( accountTreeHash ); // out: ledger/Ledger.cpp
JSS ( account_data ); // out: AccountInfo
JSS ( account_hash ); // out: LedgerToJson
JSS ( account_id ); // out: WalletPropose
JSS ( account_index ); // in: AccountCurrencies, AccountOffers,
// AccountInfo, AccountLines,
// AccountObjects, OwnerInfo
// out: AccountOffers
JSS ( account_objects ); // out: AccountObjects
JSS ( account_root ); // in: LedgerEntry
JSS ( accounts ); // in: LedgerEntry, Subscribe,
@@ -275,7 +271,6 @@ JSS ( paths_computed ); // out: PathRequest, RipplePathFind
JSS ( peer ); // in: AccountLines
JSS ( peer_authorized ); // out: AccountLines
JSS ( peer_id ); // out: LedgerProposal
JSS ( peer_index ); // in/out: AccountLines
JSS ( peers ); // out: InboundLedger, handlers/Peers
JSS ( port ); // in: Connect
JSS ( previous_ledger ); // out: LedgerPropose

View File

@@ -42,26 +42,12 @@ Json::Value doAccountCurrencies (RPC::Context& context)
? params[jss::account].asString ()
: params[jss::ident].asString ());
int iIndex = 0;
if (params.isMember (jss::account_index))
{
auto const& accountIndex = params[jss::account_index];
if (!accountIndex.isUInt() && !accountIndex.isInt ())
return RPC::invalid_field_message (jss::account_index);
iIndex = accountIndex.asUInt ();
}
bool const bStrict = params.isMember (jss::strict) &&
params[jss::strict].asBool ();
// Get info on account.
bool bIndex; // out param
AccountID accountID; // out param
Json::Value jvAccepted (
RPC::accountFromString (accountID, bIndex, strIdent, iIndex, bStrict));
if (jvAccepted)
if (auto jvAccepted = RPC::accountFromString (accountID, strIdent, bStrict))
return jvAccepted;
std::set<Currency> send, receive;

View File

@@ -26,7 +26,6 @@ namespace ripple {
// {
// account: <indent>,
// account_index : <index> // optional
// strict: <bool>
// if true, only allow public keys and addresses. false, default.
// ledger_hash : <ledger>
@@ -49,16 +48,12 @@ Json::Value doAccountInfo (RPC::Context& context)
std::string strIdent = params.isMember (jss::account)
? params[jss::account].asString () : params[jss::ident].asString ();
bool bIndex;
int iIndex = params.isMember (jss::account_index)
? params[jss::account_index].asUInt () : 0;
bool bStrict = params.isMember (jss::strict) && params[jss::strict].asBool ();
AccountID accountID;
// Get info on account.
auto jvAccepted = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, bStrict);
auto jvAccepted = RPC::accountFromString (accountID, strIdent, bStrict);
if (jvAccepted)
return jvAccepted;

View File

@@ -70,7 +70,6 @@ void addLine (Json::Value& jsonLines, RippleState const& line)
// {
// account: <account>|<account_public_key>
// account_index: <number> // optional, defaults to 0.
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// limit: integer // optional
@@ -88,14 +87,9 @@ Json::Value doAccountLines (RPC::Context& context)
return result;
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
AccountID accountID;
auto jv = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, false);
if (jv)
if (auto jv = RPC::accountFromString (accountID, strIdent))
{
for (auto it = jv.begin (); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
@@ -114,16 +108,8 @@ Json::Value doAccountLines (RPC::Context& context)
AccountID raPeerAccount;
if (hasPeer)
{
bool bPeerIndex (params.isMember (jss::peer_index));
int iPeerIndex (bIndex ? params[jss::peer_index].asUInt () : 0);
result[jss::peer] = getApp().accountIDCache().toBase58 (accountID);
if (bPeerIndex)
result[jss::peer_index] = iPeerIndex;
result = RPC::accountFromString (
raPeerAccount, bPeerIndex, strPeer, iPeerIndex, false);
result = RPC::accountFromString (raPeerAccount, strPeer);
if (result)
return result;

View File

@@ -32,7 +32,6 @@ namespace ripple {
/** General RPC command that can retrieve objects in the account root.
{
account: <account>|<account_public_key>
account_index: <integer> // optional, defaults to 0
ledger_hash: <string> // optional
ledger_index: <string | unsigned integer> // optional
type: <string> // optional, defaults to all account objects types
@@ -54,13 +53,8 @@ Json::Value doAccountObjects (RPC::Context& context)
AccountID accountID;
{
bool bIndex;
auto const strIdent = params[jss::account].asString ();
auto iIndex = context.params.isMember (jss::account_index)
? context.params[jss::account_index].asUInt () : 0;
auto jv = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, false);
if (jv)
if (auto jv = RPC::accountFromString (accountID, strIdent))
{
for (auto it = jv.begin (); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();

View File

@@ -26,7 +26,6 @@ namespace ripple {
// {
// account: <account>|<account_public_key>
// account_index: <number> // optional, defaults to 0.
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// limit: integer // optional
@@ -44,15 +43,11 @@ Json::Value doAccountOffers (RPC::Context& context)
return result;
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int const iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
AccountID accountID;
Json::Value const jv = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, false);
if (jv)
if (auto jv = RPC::accountFromString (accountID, strIdent))
{
for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
for (auto it = jv.begin (); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
return result;
@@ -61,9 +56,6 @@ Json::Value doAccountOffers (RPC::Context& context)
// Get info on account.
result[jss::account] = getApp().accountIDCache().toBase58 (accountID);
if (bIndex)
result[jss::account_index] = iIndex;
if (! ledger->exists(keylet::account (accountID)))
return rpcError (rpcACT_NOT_FOUND);

View File

@@ -63,24 +63,12 @@ Json::Value doGatewayBalances (RPC::Context& context)
? params[jss::account].asString ()
: params[jss::ident].asString ());
int iIndex = 0;
if (params.isMember (jss::account_index))
{
auto const& accountIndex = params[jss::account_index];
if (!accountIndex.isUInt() && !accountIndex.isInt ())
return RPC::invalid_field_message (jss::account_index);
iIndex = accountIndex.asUInt ();
}
bool const bStrict = params.isMember (jss::strict) &&
params[jss::strict].asBool ();
// Get info on account.
bool bIndex; // out param
AccountID accountID;
Json::Value jvAccepted = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, bStrict);
auto jvAccepted = RPC::accountFromString (accountID, strIdent, bStrict);
if (jvAccepted)
return jvAccepted;

View File

@@ -42,7 +42,6 @@ static void fillTransaction (
// {
// account: <account>|<account_public_key>
// account_index: <number> // optional, defaults to 0.
// ledger_hash : <ledger>
// ledger_index : <ledger_index>
// limit: integer // optional, number of problems
@@ -95,15 +94,11 @@ Json::Value doNoRippleCheck (RPC::Context& context)
transactions ? (result[jss::transactions] = Json::arrayValue) : dummy;
std::string strIdent (params[jss::account].asString ());
bool bIndex (params.isMember (jss::account_index));
int iIndex (bIndex ? params[jss::account_index].asUInt () : 0);
AccountID accountID;
Json::Value const jv = RPC::accountFromString (
accountID, bIndex, strIdent, iIndex, false);
if (jv)
if (auto jv = RPC::accountFromString (accountID, strIdent))
{
for (Json::Value::const_iterator it (jv.begin ()); it != jv.end (); ++it)
for (auto it (jv.begin ()); it != jv.end (); ++it)
result[it.memberName ()] = it.key ();
return result;

View File

@@ -23,7 +23,6 @@ namespace ripple {
// {
// 'ident' : <indent>,
// 'account_index' : <index> // optional
// }
Json::Value doOwnerInfo (RPC::Context& context)
{
@@ -36,32 +35,19 @@ Json::Value doOwnerInfo (RPC::Context& context)
std::string strIdent = context.params.isMember (jss::account)
? context.params[jss::account].asString ()
: context.params[jss::ident].asString ();
bool bIndex;
int iIndex = context.params.isMember (jss::account_index)
? context.params[jss::account_index].asUInt () : 0;
Json::Value ret;
// Get info on account.
auto const& closedLedger = context.netOps.getClosedLedger ();
AccountID accountID;
Json::Value jAccepted = RPC::accountFromString (
accountID,
bIndex,
strIdent,
iIndex,
false);
auto jAccepted = RPC::accountFromString (accountID, strIdent);
ret[jss::accepted] = ! jAccepted ?
context.netOps.getOwnerInfo (closedLedger, accountID) : jAccepted;
auto const& currentLedger = context.netOps.getCurrentLedger ();
Json::Value jCurrent = RPC::accountFromString (
accountID,
bIndex,
strIdent,
iIndex,
false);
auto jCurrent = RPC::accountFromString (accountID, strIdent);
ret[jss::current] = ! jCurrent ?
context.netOps.getOwnerInfo (currentLedger, accountID) : jCurrent;

View File

@@ -23,37 +23,30 @@
namespace ripple {
namespace RPC {
Json::Value accountFromString (
AccountID& result,
bool& bIndex,
std::string const& strIdent,
int const iIndex,
bool const bStrict)
boost::optional <AccountID> accountFromStringStrict (std::string const& account)
{
// VFALCO Use AnyPublicKey
// Try public key
boost::optional <AccountID> result;
RippleAddress naAccount;
if (naAccount.setAccountPublic(strIdent))
{
result = calcAccountID(naAccount);
bIndex = false;
return Json::objectValue;
}
if (naAccount.setAccountPublic (account))
result = calcAccountID (naAccount);
else
result = parseBase58<AccountID> (account);
return result;
}
// Try AccountID
auto accountID =
parseBase58<AccountID>(strIdent);
if (accountID)
Json::Value accountFromString (
AccountID& result, std::string const& strIdent, bool bStrict)
{
if (auto accountID = accountFromStringStrict (strIdent))
{
result = *accountID;
bIndex = false;
return Json::objectValue;
}
if (bStrict)
{
accountID = deprecatedParseBitcoinAccountID(strIdent);
return rpcError (accountID ? rpcACT_BITCOIN : rpcACT_MALFORMED);
auto id = deprecatedParseBitcoinAccountID (strIdent);
return rpcError (id ? rpcACT_BITCOIN : rpcACT_MALFORMED);
}
RippleAddress naSeed;
@@ -70,10 +63,9 @@ Json::Value accountFromString (
// Generator maps don't exist. Assume it is a master
// generator.
bIndex = !iIndex;
naAccount.setAccountPublic (naGenerator, iIndex);
result = calcAccountID(naAccount);
RippleAddress naAccount;
naAccount.setAccountPublic (naGenerator, 0);
result = calcAccountID (naAccount);
return Json::objectValue;
}

View File

@@ -26,17 +26,17 @@
namespace ripple {
namespace RPC {
/** Get an AccountID from an account ID or public key. */
boost::optional<AccountID> accountFromStringStrict (std::string const&);
// --> strIdent: public key, account ID, or regular seed.
// --> bStrict: Only allow account id or public key.
// <-- bIndex: true if iIndex > 0 and used the index.
//
// Returns a Json::objectValue, containing error information if there was one.
Json::Value accountFromString (
AccountID& result,
bool& bIndex,
std::string const& strIdent,
int iIndex,
bool bStrict);
bool bStrict = false);
} // RPC
} // ripple