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

View File

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

View File

@@ -42,26 +42,12 @@ Json::Value doAccountCurrencies (RPC::Context& context)
? params[jss::account].asString () ? params[jss::account].asString ()
: params[jss::ident].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) && bool const bStrict = params.isMember (jss::strict) &&
params[jss::strict].asBool (); params[jss::strict].asBool ();
// Get info on account. // Get info on account.
bool bIndex; // out param
AccountID accountID; // out param AccountID accountID; // out param
Json::Value jvAccepted ( if (auto jvAccepted = RPC::accountFromString (accountID, strIdent, bStrict))
RPC::accountFromString (accountID, bIndex, strIdent, iIndex, bStrict));
if (jvAccepted)
return jvAccepted; return jvAccepted;
std::set<Currency> send, receive; std::set<Currency> send, receive;

View File

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

View File

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

View File

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

View File

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

View File

@@ -63,24 +63,12 @@ Json::Value doGatewayBalances (RPC::Context& context)
? params[jss::account].asString () ? params[jss::account].asString ()
: params[jss::ident].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) && bool const bStrict = params.isMember (jss::strict) &&
params[jss::strict].asBool (); params[jss::strict].asBool ();
// Get info on account. // Get info on account.
bool bIndex; // out param
AccountID accountID; AccountID accountID;
Json::Value jvAccepted = RPC::accountFromString ( auto jvAccepted = RPC::accountFromString (accountID, strIdent, bStrict);
accountID, bIndex, strIdent, iIndex, bStrict);
if (jvAccepted) if (jvAccepted)
return jvAccepted; return jvAccepted;

View File

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

View File

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

View File

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

View File

@@ -26,17 +26,17 @@
namespace ripple { namespace ripple {
namespace RPC { 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. // --> strIdent: public key, account ID, or regular seed.
// --> bStrict: Only allow account id or public key. // --> 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. // Returns a Json::objectValue, containing error information if there was one.
Json::Value accountFromString ( Json::Value accountFromString (
AccountID& result, AccountID& result,
bool& bIndex,
std::string const& strIdent, std::string const& strIdent,
int iIndex, bool bStrict = false);
bool bStrict);
} // RPC } // RPC
} // ripple } // ripple