From ebcf821d81ade97e86ccfc5a496ca1c7331fb003 Mon Sep 17 00:00:00 2001 From: Nik Bougalis Date: Fri, 3 Apr 2015 16:21:37 -0700 Subject: [PATCH] Return descriptive error from account_currencies RPC (RIPD-806): The 'account_index' field is expected to be an integer. If something else is specified, the error message should clearly indicate which field is at fault. --- src/ripple/rpc/handlers/AccountCurrencies.cpp | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/ripple/rpc/handlers/AccountCurrencies.cpp b/src/ripple/rpc/handlers/AccountCurrencies.cpp index c7993bfc6..cb877ecde 100644 --- a/src/ripple/rpc/handlers/AccountCurrencies.cpp +++ b/src/ripple/rpc/handlers/AccountCurrencies.cpp @@ -42,9 +42,16 @@ Json::Value doAccountCurrencies (RPC::Context& context) ? params[jss::account].asString () : params[jss::ident].asString ()); - int const iIndex (params.isMember (jss::account_index) - ? params[jss::account_index].asUInt () - : 0); + 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 ();