diff --git a/src/ripple/net/impl/RPCCall.cpp b/src/ripple/net/impl/RPCCall.cpp index 444cb74adf..dccdfccefe 100644 --- a/src/ripple/net/impl/RPCCall.cpp +++ b/src/ripple/net/impl/RPCCall.cpp @@ -569,9 +569,6 @@ private: if (bPeer && iCursor >= 2) strPeer = jvParams[iCursor].asString (); - int iIndex = 0; - // int iIndex = jvParams.size() >= 2 ? beast::lexicalCast (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; diff --git a/src/ripple/protocol/JsonFields.h b/src/ripple/protocol/JsonFields.h index 03b8ee7d63..ce3427fd27 100644 --- a/src/ripple/protocol/JsonFields.h +++ b/src/ripple/protocol/JsonFields.h @@ -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 diff --git a/src/ripple/rpc/handlers/AccountCurrencies.cpp b/src/ripple/rpc/handlers/AccountCurrencies.cpp index 475e57d8f8..15dd0d9049 100644 --- a/src/ripple/rpc/handlers/AccountCurrencies.cpp +++ b/src/ripple/rpc/handlers/AccountCurrencies.cpp @@ -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 send, receive; diff --git a/src/ripple/rpc/handlers/AccountInfo.cpp b/src/ripple/rpc/handlers/AccountInfo.cpp index 3f2bdd4212..2c71cddd8d 100644 --- a/src/ripple/rpc/handlers/AccountInfo.cpp +++ b/src/ripple/rpc/handlers/AccountInfo.cpp @@ -26,7 +26,6 @@ namespace ripple { // { // account: , -// account_index : // optional // strict: // if true, only allow public keys and addresses. false, default. // ledger_hash : @@ -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; diff --git a/src/ripple/rpc/handlers/AccountLines.cpp b/src/ripple/rpc/handlers/AccountLines.cpp index 61265d42fa..03bc887b4b 100644 --- a/src/ripple/rpc/handlers/AccountLines.cpp +++ b/src/ripple/rpc/handlers/AccountLines.cpp @@ -70,7 +70,6 @@ void addLine (Json::Value& jsonLines, RippleState const& line) // { // account: | -// account_index: // optional, defaults to 0. // ledger_hash : // 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; diff --git a/src/ripple/rpc/handlers/AccountObjects.cpp b/src/ripple/rpc/handlers/AccountObjects.cpp index 4e6ad68363..3fc83ebb5c 100644 --- a/src/ripple/rpc/handlers/AccountObjects.cpp +++ b/src/ripple/rpc/handlers/AccountObjects.cpp @@ -32,7 +32,6 @@ namespace ripple { /** General RPC command that can retrieve objects in the account root. { account: | - account_index: // optional, defaults to 0 ledger_hash: // optional ledger_index: // optional type: // 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 (); diff --git a/src/ripple/rpc/handlers/AccountOffers.cpp b/src/ripple/rpc/handlers/AccountOffers.cpp index 886a153107..9b2a3d0477 100644 --- a/src/ripple/rpc/handlers/AccountOffers.cpp +++ b/src/ripple/rpc/handlers/AccountOffers.cpp @@ -26,7 +26,6 @@ namespace ripple { // { // account: | -// account_index: // optional, defaults to 0. // ledger_hash : // 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); diff --git a/src/ripple/rpc/handlers/GatewayBalances.cpp b/src/ripple/rpc/handlers/GatewayBalances.cpp index 9763d3a77f..f30e4a502f 100644 --- a/src/ripple/rpc/handlers/GatewayBalances.cpp +++ b/src/ripple/rpc/handlers/GatewayBalances.cpp @@ -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; diff --git a/src/ripple/rpc/handlers/NoRippleCheck.cpp b/src/ripple/rpc/handlers/NoRippleCheck.cpp index 96dd5b32d0..7e75d8f23b 100644 --- a/src/ripple/rpc/handlers/NoRippleCheck.cpp +++ b/src/ripple/rpc/handlers/NoRippleCheck.cpp @@ -42,7 +42,6 @@ static void fillTransaction ( // { // account: | -// account_index: // optional, defaults to 0. // ledger_hash : // 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; diff --git a/src/ripple/rpc/handlers/OwnerInfo.cpp b/src/ripple/rpc/handlers/OwnerInfo.cpp index 654961a9d1..b3dd7c4f2e 100644 --- a/src/ripple/rpc/handlers/OwnerInfo.cpp +++ b/src/ripple/rpc/handlers/OwnerInfo.cpp @@ -23,7 +23,6 @@ namespace ripple { // { // 'ident' : , -// 'account_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; diff --git a/src/ripple/rpc/impl/AccountFromString.cpp b/src/ripple/rpc/impl/AccountFromString.cpp index e04ef1962e..213a44d818 100644 --- a/src/ripple/rpc/impl/AccountFromString.cpp +++ b/src/ripple/rpc/impl/AccountFromString.cpp @@ -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 accountFromStringStrict (std::string const& account) { - // VFALCO Use AnyPublicKey - // Try public key + boost::optional 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 (account); + return result; +} - // Try AccountID - auto accountID = - parseBase58(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; } diff --git a/src/ripple/rpc/impl/AccountFromString.h b/src/ripple/rpc/impl/AccountFromString.h index b118169c22..527f611f32 100644 --- a/src/ripple/rpc/impl/AccountFromString.h +++ b/src/ripple/rpc/impl/AccountFromString.h @@ -26,17 +26,17 @@ namespace ripple { namespace RPC { +/** Get an AccountID from an account ID or public key. */ +boost::optional 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