mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Fix public member names of RPC::Context.
Conflicts: src/ripple/rpc/handlers/AccountTx.cpp src/ripple/rpc/handlers/AccountTxOld.cpp src/ripple/rpc/handlers/Ledger.cpp src/ripple/rpc/handlers/LedgerData.cpp src/ripple/rpc/handlers/RipplePathFind.cpp src/ripple/rpc/handlers/ServerInfo.cpp src/ripple/rpc/handlers/ServerState.cpp src/ripple/rpc/handlers/Submit.cpp src/ripple/rpc/handlers/Subscribe.cpp src/ripple/rpc/handlers/TxHistory.cpp src/ripple/rpc/handlers/Unsubscribe.cpp src/ripple/rpc/impl/Context.h
This commit is contained in:
committed by
Vinnie Falco
parent
150a3810a8
commit
b30b2a523f
@@ -24,11 +24,11 @@ namespace ripple {
|
||||
|
||||
Json::Value doAccountCurrencies (RPC::Context& context)
|
||||
{
|
||||
auto& params = context.params_;
|
||||
auto& params = context.params;
|
||||
|
||||
// Get the current ledger
|
||||
Ledger::pointer ledger;
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_));
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
|
||||
|
||||
if (!ledger)
|
||||
return result;
|
||||
@@ -50,7 +50,7 @@ Json::Value doAccountCurrencies (RPC::Context& context)
|
||||
bool bIndex; // out param
|
||||
RippleAddress naAccount; // out param
|
||||
Json::Value jvAccepted (RPC::accountFromString (
|
||||
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_));
|
||||
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps));
|
||||
|
||||
if (!jvAccepted.empty ())
|
||||
return jvAccepted;
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace ripple {
|
||||
// TODO(tom): what is that "default"?
|
||||
Json::Value doAccountInfo (RPC::Context& context)
|
||||
{
|
||||
auto& params = context.params_;
|
||||
auto& params = context.params;
|
||||
|
||||
Ledger::pointer ledger;
|
||||
Json::Value result = RPC::lookupLedger (params, ledger, context.netOps_);
|
||||
Json::Value result = RPC::lookupLedger (params, ledger, context.netOps);
|
||||
|
||||
if (!ledger)
|
||||
return result;
|
||||
@@ -53,12 +53,12 @@ Json::Value doAccountInfo (RPC::Context& context)
|
||||
// Get info on account.
|
||||
|
||||
Json::Value jvAccepted = RPC::accountFromString (
|
||||
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps_);
|
||||
ledger, naAccount, bIndex, strIdent, iIndex, bStrict, context.netOps);
|
||||
|
||||
if (!jvAccepted.empty ())
|
||||
return jvAccepted;
|
||||
|
||||
auto asAccepted = context.netOps_.getAccountState (ledger, naAccount);
|
||||
auto asAccepted = context.netOps.getAccountState (ledger, naAccount);
|
||||
|
||||
if (asAccepted)
|
||||
{
|
||||
|
||||
@@ -74,10 +74,10 @@ void addLine (Json::Value& jsonLines, RippleState const& line)
|
||||
// }
|
||||
Json::Value doAccountLines (RPC::Context& context)
|
||||
{
|
||||
auto& params = context.params_;
|
||||
auto& params = context.params;
|
||||
|
||||
Ledger::pointer ledger;
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_));
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
|
||||
|
||||
if (! ledger)
|
||||
return result;
|
||||
@@ -91,7 +91,7 @@ Json::Value doAccountLines (RPC::Context& context)
|
||||
RippleAddress rippleAddress;
|
||||
|
||||
result = RPC::accountFromString (
|
||||
ledger, rippleAddress, bIndex, strIdent, iIndex, false, context.netOps_);
|
||||
ledger, rippleAddress, bIndex, strIdent, iIndex, false, context.netOps);
|
||||
|
||||
if (! result.empty ())
|
||||
return result;
|
||||
@@ -114,7 +114,7 @@ Json::Value doAccountLines (RPC::Context& context)
|
||||
result[jss::peer_index] = iPeerIndex;
|
||||
|
||||
result = RPC::accountFromString (ledger, rippleAddressPeer, bPeerIndex, strPeer,
|
||||
iPeerIndex, false, context.netOps_);
|
||||
iPeerIndex, false, context.netOps);
|
||||
|
||||
if (! result.empty ())
|
||||
return result;
|
||||
@@ -212,7 +212,7 @@ Json::Value doAccountLines (RPC::Context& context)
|
||||
for (auto const& item : visitData.items)
|
||||
addLine (jsonLines, *item.get ());
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doAccountOffers (RPC::Context& context)
|
||||
{
|
||||
auto const& params (context.params_);
|
||||
auto const& params (context.params);
|
||||
|
||||
Ledger::pointer ledger;
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps_));
|
||||
Json::Value result (RPC::lookupLedger (params, ledger, context.netOps));
|
||||
|
||||
if (! ledger)
|
||||
return result;
|
||||
@@ -49,7 +49,7 @@ Json::Value doAccountOffers (RPC::Context& context)
|
||||
RippleAddress rippleAddress;
|
||||
|
||||
result = RPC::accountFromString (ledger, rippleAddress, bIndex, strIdent,
|
||||
iIndex, false, context.netOps_);
|
||||
iIndex, false, context.netOps);
|
||||
|
||||
if (! result.empty ())
|
||||
return result;
|
||||
@@ -151,7 +151,7 @@ Json::Value doAccountOffers (RPC::Context& context)
|
||||
obj[jss::flags] = offer->getFieldU32 (sfFlags);
|
||||
}
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -31,7 +32,7 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doAccountTx (RPC::Context& context)
|
||||
{
|
||||
auto& params = context.params_;
|
||||
auto& params = context.params;
|
||||
|
||||
RippleAddress raAccount;
|
||||
int limit = params.isMember (jss::limit) ?
|
||||
@@ -42,7 +43,7 @@ Json::Value doAccountTx (RPC::Context& context)
|
||||
std::uint32_t uLedgerMax;
|
||||
std::uint32_t uValidatedMin;
|
||||
std::uint32_t uValidatedMax;
|
||||
bool bValidated = context.netOps_.getValidatedRange (
|
||||
bool bValidated = context.netOps.getValidatedRange (
|
||||
uValidatedMin, uValidatedMax);
|
||||
|
||||
if (!bValidated)
|
||||
@@ -57,7 +58,7 @@ Json::Value doAccountTx (RPC::Context& context)
|
||||
if (!raAccount.setAccountID (params["account"].asString ()))
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (params.isMember ("ledger_index_min") ||
|
||||
params.isMember ("ledger_index_max"))
|
||||
@@ -76,7 +77,7 @@ Json::Value doAccountTx (RPC::Context& context)
|
||||
else
|
||||
{
|
||||
Ledger::pointer l;
|
||||
Json::Value ret = RPC::lookupLedger (params, l, context.netOps_);
|
||||
Json::Value ret = RPC::lookupLedger (params, l, context.netOps);
|
||||
|
||||
if (!l)
|
||||
return ret;
|
||||
@@ -101,9 +102,9 @@ Json::Value doAccountTx (RPC::Context& context)
|
||||
|
||||
if (bBinary)
|
||||
{
|
||||
auto txns = context.netOps_.getTxsAccountB (
|
||||
auto txns = context.netOps.getTxsAccountB (
|
||||
raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit,
|
||||
context.role_ == Role::ADMIN);
|
||||
context.role == Role::ADMIN);
|
||||
|
||||
for (auto& it: txns)
|
||||
{
|
||||
@@ -122,9 +123,9 @@ Json::Value doAccountTx (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto txns = context.netOps_.getTxsAccount (
|
||||
auto txns = context.netOps.getTxsAccount (
|
||||
raAccount, uLedgerMin, uLedgerMax, bForward, resumeToken, limit,
|
||||
context.role_ == Role::ADMIN);
|
||||
context.role == Role::ADMIN);
|
||||
|
||||
for (auto& it: txns)
|
||||
{
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -34,55 +35,55 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
||||
{
|
||||
RippleAddress raAccount;
|
||||
std::uint32_t offset
|
||||
= context.params_.isMember ("offset")
|
||||
? context.params_["offset"].asUInt () : 0;
|
||||
int limit = context.params_.isMember ("limit")
|
||||
? context.params_["limit"].asUInt () : -1;
|
||||
bool bBinary = context.params_.isMember ("binary")
|
||||
&& context.params_["binary"].asBool ();
|
||||
bool bDescending = context.params_.isMember ("descending")
|
||||
&& context.params_["descending"].asBool ();
|
||||
bool bCount = context.params_.isMember ("count")
|
||||
&& context.params_["count"].asBool ();
|
||||
= context.params.isMember ("offset")
|
||||
? context.params["offset"].asUInt () : 0;
|
||||
int limit = context.params.isMember ("limit")
|
||||
? context.params["limit"].asUInt () : -1;
|
||||
bool bBinary = context.params.isMember ("binary")
|
||||
&& context.params["binary"].asBool ();
|
||||
bool bDescending = context.params.isMember ("descending")
|
||||
&& context.params["descending"].asBool ();
|
||||
bool bCount = context.params.isMember ("count")
|
||||
&& context.params["count"].asBool ();
|
||||
std::uint32_t uLedgerMin;
|
||||
std::uint32_t uLedgerMax;
|
||||
std::uint32_t uValidatedMin;
|
||||
std::uint32_t uValidatedMax;
|
||||
bool bValidated = context.netOps_.getValidatedRange (
|
||||
bool bValidated = context.netOps.getValidatedRange (
|
||||
uValidatedMin, uValidatedMax);
|
||||
|
||||
if (!context.params_.isMember ("account"))
|
||||
if (!context.params.isMember ("account"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
if (!raAccount.setAccountID (context.params_["account"].asString ()))
|
||||
if (!raAccount.setAccountID (context.params["account"].asString ()))
|
||||
return rpcError (rpcACT_MALFORMED);
|
||||
|
||||
if (offset > 3000)
|
||||
return rpcError (rpcATX_DEPRECATED);
|
||||
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
|
||||
// DEPRECATED
|
||||
if (context.params_.isMember ("ledger_min"))
|
||||
if (context.params.isMember ("ledger_min"))
|
||||
{
|
||||
context.params_["ledger_index_min"] = context.params_["ledger_min"];
|
||||
context.params["ledger_index_min"] = context.params["ledger_min"];
|
||||
bDescending = true;
|
||||
}
|
||||
|
||||
// DEPRECATED
|
||||
if (context.params_.isMember ("ledger_max"))
|
||||
if (context.params.isMember ("ledger_max"))
|
||||
{
|
||||
context.params_["ledger_index_max"] = context.params_["ledger_max"];
|
||||
context.params["ledger_index_max"] = context.params["ledger_max"];
|
||||
bDescending = true;
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("ledger_index_min")
|
||||
|| context.params_.isMember ("ledger_index_max"))
|
||||
if (context.params.isMember ("ledger_index_min")
|
||||
|| context.params.isMember ("ledger_index_max"))
|
||||
{
|
||||
std::int64_t iLedgerMin = context.params_.isMember ("ledger_index_min")
|
||||
? context.params_["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = context.params_.isMember ("ledger_index_max")
|
||||
? context.params_["ledger_index_max"].asInt () : -1;
|
||||
std::int64_t iLedgerMin = context.params.isMember ("ledger_index_min")
|
||||
? context.params["ledger_index_min"].asInt () : -1;
|
||||
std::int64_t iLedgerMax = context.params.isMember ("ledger_index_max")
|
||||
? context.params["ledger_index_max"].asInt () : -1;
|
||||
|
||||
if (!bValidated && (iLedgerMin == -1 || iLedgerMax == -1))
|
||||
{
|
||||
@@ -101,7 +102,7 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
||||
else
|
||||
{
|
||||
Ledger::pointer l;
|
||||
Json::Value ret = RPC::lookupLedger (context.params_, l, context.netOps_);
|
||||
Json::Value ret = RPC::lookupLedger (context.params, l, context.netOps);
|
||||
|
||||
if (!l)
|
||||
return ret;
|
||||
@@ -124,9 +125,9 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
||||
|
||||
if (bBinary)
|
||||
{
|
||||
auto txns = context.netOps_.getAccountTxsB (
|
||||
auto txns = context.netOps.getAccountTxsB (
|
||||
raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit,
|
||||
context.role_ == Role::ADMIN);
|
||||
context.role == Role::ADMIN);
|
||||
|
||||
for (auto it = txns.begin (), end = txns.end (); it != end; ++it)
|
||||
{
|
||||
@@ -146,9 +147,9 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
auto txns = context.netOps_.getAccountTxs (
|
||||
auto txns = context.netOps.getAccountTxs (
|
||||
raAccount, uLedgerMin, uLedgerMax, bDescending, offset, limit,
|
||||
context.role_ == Role::ADMIN);
|
||||
context.role == Role::ADMIN);
|
||||
|
||||
for (auto it = txns.begin (), end = txns.end (); it != end; ++it)
|
||||
{
|
||||
@@ -187,7 +188,7 @@ Json::Value doAccountTxOld (RPC::Context& context)
|
||||
if (bCount)
|
||||
ret["count"] = count;
|
||||
|
||||
if (context.params_.isMember ("limit"))
|
||||
if (context.params.isMember ("limit"))
|
||||
ret["limit"] = limit;
|
||||
|
||||
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace ripple {
|
||||
// Temporary switching code until the old account_tx is removed
|
||||
Json::Value doAccountTxSwitch (RPC::Context& context)
|
||||
{
|
||||
if (context.params_.isMember("offset") ||
|
||||
context.params_.isMember("count") ||
|
||||
context.params_.isMember("descending") ||
|
||||
context.params_.isMember("ledger_max") ||
|
||||
context.params_.isMember("ledger_min"))
|
||||
if (context.params.isMember("offset") ||
|
||||
context.params.isMember("count") ||
|
||||
context.params.isMember("descending") ||
|
||||
context.params.isMember("ledger_max") ||
|
||||
context.params.isMember("ledger_min"))
|
||||
{
|
||||
return doAccountTxOld(context);
|
||||
}
|
||||
|
||||
@@ -23,8 +23,8 @@ namespace ripple {
|
||||
Json::Value doBlackList (RPC::Context& context)
|
||||
{
|
||||
auto& rm = getApp().getResourceManager();
|
||||
if (context.params_.isMember("threshold"))
|
||||
return rm.getJson(context.params_["threshold"].asInt());
|
||||
if (context.params.isMember("threshold"))
|
||||
return rm.getJson(context.params["threshold"].asInt());
|
||||
else
|
||||
return rm.getJson();
|
||||
}
|
||||
|
||||
@@ -29,24 +29,24 @@ Json::Value doBookOffers (RPC::Context& context)
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult (
|
||||
RPC::lookupLedger (context.params_, lpLedger, context.netOps_));
|
||||
RPC::lookupLedger (context.params, lpLedger, context.netOps));
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!context.params_.isMember ("taker_pays"))
|
||||
if (!context.params.isMember ("taker_pays"))
|
||||
return RPC::missing_field_error ("taker_pays");
|
||||
|
||||
if (!context.params_.isMember ("taker_gets"))
|
||||
if (!context.params.isMember ("taker_gets"))
|
||||
return RPC::missing_field_error ("taker_gets");
|
||||
|
||||
if (!context.params_["taker_pays"].isObject ())
|
||||
if (!context.params["taker_pays"].isObject ())
|
||||
return RPC::object_field_error ("taker_pays");
|
||||
|
||||
if (!context.params_["taker_gets"].isObject ())
|
||||
if (!context.params["taker_gets"].isObject ())
|
||||
return RPC::object_field_error ("taker_gets");
|
||||
|
||||
Json::Value const& taker_pays (context.params_["taker_pays"]);
|
||||
Json::Value const& taker_pays (context.params["taker_pays"]);
|
||||
|
||||
if (!taker_pays.isMember ("currency"))
|
||||
return RPC::missing_field_error ("taker_pays.currency");
|
||||
@@ -54,7 +54,7 @@ Json::Value doBookOffers (RPC::Context& context)
|
||||
if (! taker_pays ["currency"].isString ())
|
||||
return RPC::expected_field_error ("taker_pays.currency", "string");
|
||||
|
||||
Json::Value const& taker_gets = context.params_["taker_gets"];
|
||||
Json::Value const& taker_gets = context.params["taker_gets"];
|
||||
|
||||
if (! taker_gets.isMember ("currency"))
|
||||
return RPC::missing_field_error ("taker_gets.currency");
|
||||
@@ -143,12 +143,12 @@ Json::Value doBookOffers (RPC::Context& context)
|
||||
|
||||
RippleAddress raTakerID;
|
||||
|
||||
if (context.params_.isMember ("taker"))
|
||||
if (context.params.isMember ("taker"))
|
||||
{
|
||||
if (! context.params_ ["taker"].isString ())
|
||||
if (! context.params ["taker"].isString ())
|
||||
return RPC::expected_field_error ("taker", "string");
|
||||
|
||||
if (! raTakerID.setAccountID (context.params_ ["taker"].asString ()))
|
||||
if (! raTakerID.setAccountID (context.params ["taker"].asString ()))
|
||||
return RPC::invalid_field_error ("taker");
|
||||
}
|
||||
else
|
||||
@@ -162,28 +162,28 @@ Json::Value doBookOffers (RPC::Context& context)
|
||||
return RPC::make_error (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("limit") &&
|
||||
!context.params_ ["limit"].isIntegral())
|
||||
if (context.params.isMember ("limit") &&
|
||||
!context.params ["limit"].isIntegral())
|
||||
{
|
||||
return RPC::expected_field_error ("limit", "integer");
|
||||
}
|
||||
|
||||
unsigned int const iLimit (context.params_.isMember ("limit")
|
||||
? context.params_ ["limit"].asUInt ()
|
||||
unsigned int const iLimit (context.params.isMember ("limit")
|
||||
? context.params ["limit"].asUInt ()
|
||||
: 0);
|
||||
|
||||
bool const bProof (context.params_.isMember ("proof"));
|
||||
bool const bProof (context.params.isMember ("proof"));
|
||||
|
||||
Json::Value const jvMarker (context.params_.isMember ("marker")
|
||||
? context.params_["marker"]
|
||||
Json::Value const jvMarker (context.params.isMember ("marker")
|
||||
? context.params["marker"]
|
||||
: Json::Value (Json::nullValue));
|
||||
|
||||
context.netOps_.getBookPage (
|
||||
context.netOps.getBookPage (
|
||||
lpLedger,
|
||||
{{pay_currency, pay_issuer}, {get_currency, get_issuer}},
|
||||
raTakerID.getAccountID (), bProof, iLimit, jvMarker, jvResult);
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -32,24 +32,24 @@ Json::Value doConnect (RPC::Context& context)
|
||||
if (getConfig ().RUN_STANDALONE)
|
||||
return "cannot connect in standalone mode";
|
||||
|
||||
if (!context.params_.isMember ("ip"))
|
||||
if (!context.params.isMember ("ip"))
|
||||
return RPC::missing_field_error ("ip");
|
||||
|
||||
if (context.params_.isMember ("port") &&
|
||||
!context.params_["port"].isConvertibleTo (Json::intValue))
|
||||
if (context.params.isMember ("port") &&
|
||||
!context.params["port"].isConvertibleTo (Json::intValue))
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
int iPort;
|
||||
|
||||
if(context.params_.isMember ("port"))
|
||||
iPort = context.params_["port"].asInt ();
|
||||
if(context.params.isMember ("port"))
|
||||
iPort = context.params["port"].asInt ();
|
||||
else
|
||||
iPort = 6561;
|
||||
|
||||
auto ip = beast::IP::Endpoint::from_string(
|
||||
context.params_["ip"].asString ());
|
||||
context.params["ip"].asString ());
|
||||
|
||||
if (! is_unspecified (ip))
|
||||
getApp().overlay ().connect (ip.at_port(iPort));
|
||||
|
||||
@@ -25,7 +25,7 @@ Json::Value doConsensusInfo (RPC::Context& context)
|
||||
|
||||
{
|
||||
auto lock = getApp().masterLock();
|
||||
ret["info"] = context.netOps_.getConsensusInfo ();
|
||||
ret["info"] = context.netOps.getConsensusInfo ();
|
||||
}
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -43,7 +43,7 @@ static void textTime (
|
||||
|
||||
Json::Value doFeature (RPC::Context& context)
|
||||
{
|
||||
if (!context.params_.isMember ("feature"))
|
||||
if (!context.params.isMember ("feature"))
|
||||
{
|
||||
Json::Value jvReply = Json::objectValue;
|
||||
jvReply["features"] = getApp().getAmendmentTable ().getJson(0);
|
||||
@@ -52,17 +52,17 @@ Json::Value doFeature (RPC::Context& context)
|
||||
|
||||
uint256 uFeature
|
||||
= getApp().getAmendmentTable ().get(
|
||||
context.params_["feature"].asString());
|
||||
context.params["feature"].asString());
|
||||
|
||||
if (uFeature.isZero ())
|
||||
{
|
||||
uFeature.SetHex (context.params_["feature"].asString ());
|
||||
uFeature.SetHex (context.params["feature"].asString ());
|
||||
|
||||
if (uFeature.isZero ())
|
||||
return rpcError (rpcBAD_FEATURE);
|
||||
}
|
||||
|
||||
if (!context.params_.isMember ("vote"))
|
||||
if (!context.params.isMember ("vote"))
|
||||
return getApp().getAmendmentTable ().getJson(uFeature);
|
||||
|
||||
// WRITEME
|
||||
|
||||
@@ -24,13 +24,13 @@ Json::Value doFetchInfo (RPC::Context& context)
|
||||
{
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
if (context.params_.isMember("clear") && context.params_["clear"].asBool())
|
||||
if (context.params.isMember("clear") && context.params["clear"].asBool())
|
||||
{
|
||||
context.netOps_.clearLedgerFetch();
|
||||
context.netOps.clearLedgerFetch();
|
||||
ret["clear"] = true;
|
||||
}
|
||||
|
||||
ret["info"] = context.netOps_.getLedgerFetchInfo();
|
||||
ret["info"] = context.netOps.getLedgerFetchInfo();
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -31,8 +31,8 @@ Json::Value doGetCounts (RPC::Context& context)
|
||||
|
||||
int minCount = 10;
|
||||
|
||||
if (context.params_.isMember ("min_count"))
|
||||
minCount = context.params_["min_count"].asUInt ();
|
||||
if (context.params.isMember ("min_count"))
|
||||
minCount = context.params["min_count"].asUInt ();
|
||||
|
||||
auto objectCounts = CountedObjects::getInstance ().getCounts (minCount);
|
||||
|
||||
|
||||
@@ -26,11 +26,11 @@ RPC::InternalHandler* RPC::InternalHandler::headHandler = nullptr;
|
||||
Json::Value doInternal (RPC::Context& context)
|
||||
{
|
||||
// Used for debug or special-purpose RPC commands
|
||||
if (!context.params_.isMember ("internal_command"))
|
||||
if (!context.params.isMember ("internal_command"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
auto name = context.params_["internal_command"].asString ();
|
||||
auto params = context.params_["params"];
|
||||
auto name = context.params["internal_command"].asString ();
|
||||
auto params = context.params["params"];
|
||||
|
||||
for (auto* h = RPC::InternalHandler::headHandler; h; )
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/core/LoadFeeTrack.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -28,9 +29,9 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doLedger (RPC::Context& context)
|
||||
{
|
||||
if (!context.params_.isMember ("ledger")
|
||||
&& !context.params_.isMember ("ledger_hash")
|
||||
&& !context.params_.isMember ("ledger_index"))
|
||||
if (!context.params.isMember ("ledger")
|
||||
&& !context.params.isMember ("ledger_hash")
|
||||
&& !context.params.isMember ("ledger_index"))
|
||||
{
|
||||
Json::Value ret (Json::objectValue), current (Json::objectValue),
|
||||
closed (Json::objectValue);
|
||||
@@ -46,19 +47,19 @@ Json::Value doLedger (RPC::Context& context)
|
||||
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (
|
||||
context.params_, lpLedger, context.netOps_);
|
||||
context.params, lpLedger, context.netOps);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
bool bFull = context.params_.isMember ("full")
|
||||
&& context.params_["full"].asBool ();
|
||||
bool bTransactions = context.params_.isMember ("transactions")
|
||||
&& context.params_["transactions"].asBool ();
|
||||
bool bAccounts = context.params_.isMember ("accounts")
|
||||
&& context.params_["accounts"].asBool ();
|
||||
bool bExpand = context.params_.isMember ("expand")
|
||||
&& context.params_["expand"].asBool ();
|
||||
bool bFull = context.params.isMember ("full")
|
||||
&& context.params["full"].asBool ();
|
||||
bool bTransactions = context.params.isMember ("transactions")
|
||||
&& context.params["transactions"].asBool ();
|
||||
bool bAccounts = context.params.isMember ("accounts")
|
||||
&& context.params["accounts"].asBool ();
|
||||
bool bExpand = context.params.isMember ("expand")
|
||||
&& context.params["expand"].asBool ();
|
||||
int iOptions = (bFull ? LEDGER_JSON_FULL : 0)
|
||||
| (bExpand ? LEDGER_JSON_EXPAND : 0)
|
||||
| (bTransactions ? LEDGER_JSON_DUMP_TXRP : 0)
|
||||
@@ -67,7 +68,7 @@ Json::Value doLedger (RPC::Context& context)
|
||||
if (bFull || bAccounts)
|
||||
{
|
||||
|
||||
if (context.role_ != Role::ADMIN)
|
||||
if (context.role != Role::ADMIN)
|
||||
{
|
||||
// Until some sane way to get full ledgers has been implemented,
|
||||
// disallow retrieving all state nodes.
|
||||
@@ -75,12 +76,12 @@ Json::Value doLedger (RPC::Context& context)
|
||||
}
|
||||
|
||||
if (getApp().getFeeTrack().isLoadedLocal() &&
|
||||
context.role_ != Role::ADMIN)
|
||||
context.role != Role::ADMIN)
|
||||
{
|
||||
WriteLog (lsDEBUG, Peer) << "Too busy to give full ledger";
|
||||
return rpcError(rpcTOO_BUSY);
|
||||
}
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -31,10 +31,10 @@ Json::Value doLedgerAccept (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.netOps_.acceptLedger ();
|
||||
context.netOps.acceptLedger ();
|
||||
|
||||
jvResult["ledger_current_index"]
|
||||
= context.netOps_.getCurrentLedgerID ();
|
||||
= context.netOps.getCurrentLedgerID ();
|
||||
}
|
||||
|
||||
return jvResult;
|
||||
|
||||
@@ -22,7 +22,7 @@ namespace ripple {
|
||||
|
||||
Json::Value doLedgerCleaner (RPC::Context& context)
|
||||
{
|
||||
getApp().getLedgerMaster().doLedgerCleaner (context.params_);
|
||||
getApp().getLedgerMaster().doLedgerCleaner (context.params);
|
||||
return "Cleaner configured";
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ namespace ripple {
|
||||
|
||||
Json::Value doLedgerClosed (RPC::Context& context)
|
||||
{
|
||||
uint256 uLedger = context.netOps_.getClosedLedgerHash ();
|
||||
uint256 uLedger = context.netOps.getClosedLedgerHash ();
|
||||
|
||||
Json::Value jvResult;
|
||||
jvResult["ledger_index"] = context.netOps_.getLedgerID (uLedger);
|
||||
jvResult["ledger_index"] = context.netOps.getLedgerID (uLedger);
|
||||
jvResult["ledger_hash"] = to_string (uLedger);
|
||||
|
||||
return jvResult;
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ripple {
|
||||
Json::Value doLedgerCurrent (RPC::Context& context)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
jvResult["ledger_current_index"] = context.netOps_.getCurrentLedgerID ();
|
||||
jvResult["ledger_current_index"] = context.netOps.getCurrentLedgerID ();
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -38,14 +39,14 @@ Json::Value doLedgerData (RPC::Context& context)
|
||||
Ledger::pointer lpLedger;
|
||||
|
||||
Json::Value jvResult = RPC::lookupLedger (
|
||||
context.params_, lpLedger, context.netOps_);
|
||||
context.params, lpLedger, context.netOps);
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
uint256 resumePoint;
|
||||
if (context.params_.isMember ("marker"))
|
||||
if (context.params.isMember ("marker"))
|
||||
{
|
||||
Json::Value const& jMarker = context.params_["marker"];
|
||||
Json::Value const& jMarker = context.params["marker"];
|
||||
if (!jMarker.isString ())
|
||||
return RPC::expected_field_error ("marker", "valid");
|
||||
if (!resumePoint.SetHex (jMarker.asString ()))
|
||||
@@ -53,9 +54,9 @@ Json::Value doLedgerData (RPC::Context& context)
|
||||
}
|
||||
|
||||
bool isBinary = false;
|
||||
if (context.params_.isMember ("binary"))
|
||||
if (context.params.isMember ("binary"))
|
||||
{
|
||||
Json::Value const& jBinary = context.params_["binary"];
|
||||
Json::Value const& jBinary = context.params["binary"];
|
||||
if (!jBinary.isBool ())
|
||||
return RPC::expected_field_error ("binary", "bool");
|
||||
isBinary = jBinary.asBool ();
|
||||
@@ -64,16 +65,16 @@ Json::Value doLedgerData (RPC::Context& context)
|
||||
int limit = -1;
|
||||
int maxLimit = isBinary ? BINARY_PAGE_LENGTH : JSON_PAGE_LENGTH;
|
||||
|
||||
if (context.params_.isMember ("limit"))
|
||||
if (context.params.isMember ("limit"))
|
||||
{
|
||||
Json::Value const& jLimit = context.params_["limit"];
|
||||
Json::Value const& jLimit = context.params["limit"];
|
||||
if (!jLimit.isIntegral ())
|
||||
return RPC::expected_field_error ("limit", "integer");
|
||||
|
||||
limit = jLimit.asInt ();
|
||||
}
|
||||
|
||||
if ((limit < 0) || ((limit > maxLimit) && (context.role_ != Role::ADMIN)))
|
||||
if ((limit < 0) || ((limit > maxLimit) && (context.role != Role::ADMIN)))
|
||||
limit = maxLimit;
|
||||
|
||||
Json::Value jvReply = Json::objectValue;
|
||||
|
||||
@@ -29,7 +29,7 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (
|
||||
context.params_, lpLedger, context.netOps_);
|
||||
context.params, lpLedger, context.netOps);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
@@ -37,18 +37,18 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
uint256 uNodeIndex;
|
||||
bool bNodeBinary = false;
|
||||
|
||||
if (context.params_.isMember ("index"))
|
||||
if (context.params.isMember ("index"))
|
||||
{
|
||||
// XXX Needs to provide proof.
|
||||
uNodeIndex.SetHex (context.params_["index"].asString ());
|
||||
uNodeIndex.SetHex (context.params["index"].asString ());
|
||||
bNodeBinary = true;
|
||||
}
|
||||
else if (context.params_.isMember ("account_root"))
|
||||
else if (context.params.isMember ("account_root"))
|
||||
{
|
||||
RippleAddress naAccount;
|
||||
|
||||
if (!naAccount.setAccountID (
|
||||
context.params_["account_root"].asString ())
|
||||
context.params["account_root"].asString ())
|
||||
|| !naAccount.getAccountID ())
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
@@ -59,37 +59,37 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
= Ledger::getAccountRootIndex (naAccount.getAccountID ());
|
||||
}
|
||||
}
|
||||
else if (context.params_.isMember ("directory"))
|
||||
else if (context.params.isMember ("directory"))
|
||||
{
|
||||
if (!context.params_["directory"].isObject ())
|
||||
if (!context.params["directory"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (context.params_["directory"].asString ());
|
||||
uNodeIndex.SetHex (context.params["directory"].asString ());
|
||||
}
|
||||
else if (context.params_["directory"].isMember ("sub_index")
|
||||
&& !context.params_["directory"]["sub_index"].isIntegral ())
|
||||
else if (context.params["directory"].isMember ("sub_index")
|
||||
&& !context.params["directory"]["sub_index"].isIntegral ())
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else
|
||||
{
|
||||
std::uint64_t uSubIndex
|
||||
= context.params_["directory"].isMember ("sub_index")
|
||||
? context.params_["directory"]["sub_index"].asUInt () : 0;
|
||||
= context.params["directory"].isMember ("sub_index")
|
||||
? context.params["directory"]["sub_index"].asUInt () : 0;
|
||||
|
||||
if (context.params_["directory"].isMember ("dir_root"))
|
||||
if (context.params["directory"].isMember ("dir_root"))
|
||||
{
|
||||
uint256 uDirRoot;
|
||||
|
||||
uDirRoot.SetHex (context.params_["dir_root"].asString ());
|
||||
uDirRoot.SetHex (context.params["dir_root"].asString ());
|
||||
|
||||
uNodeIndex = Ledger::getDirNodeIndex (uDirRoot, uSubIndex);
|
||||
}
|
||||
else if (context.params_["directory"].isMember ("owner"))
|
||||
else if (context.params["directory"].isMember ("owner"))
|
||||
{
|
||||
RippleAddress naOwnerID;
|
||||
|
||||
if (!naOwnerID.setAccountID (
|
||||
context.params_["directory"]["owner"].asString ()))
|
||||
context.params["directory"]["owner"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
@@ -107,20 +107,20 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (context.params_.isMember ("generator"))
|
||||
else if (context.params.isMember ("generator"))
|
||||
{
|
||||
RippleAddress naGeneratorID;
|
||||
|
||||
if (!context.params_["generator"].isObject ())
|
||||
if (!context.params["generator"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (context.params_["generator"].asString ());
|
||||
uNodeIndex.SetHex (context.params["generator"].asString ());
|
||||
}
|
||||
else if (!context.params_["generator"].isMember ("regular_seed"))
|
||||
else if (!context.params["generator"].isMember ("regular_seed"))
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else if (!naGeneratorID.setSeedGeneric (
|
||||
context.params_["generator"]["regular_seed"].asString ()))
|
||||
context.params["generator"]["regular_seed"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
@@ -135,38 +135,38 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
uNodeIndex = Ledger::getGeneratorIndex (na0Public.getAccountID ());
|
||||
}
|
||||
}
|
||||
else if (context.params_.isMember ("offer"))
|
||||
else if (context.params.isMember ("offer"))
|
||||
{
|
||||
RippleAddress naAccountID;
|
||||
|
||||
if (!context.params_["offer"].isObject ())
|
||||
if (!context.params["offer"].isObject ())
|
||||
{
|
||||
uNodeIndex.SetHex (context.params_["offer"].asString ());
|
||||
uNodeIndex.SetHex (context.params["offer"].asString ());
|
||||
}
|
||||
else if (!context.params_["offer"].isMember ("account")
|
||||
|| !context.params_["offer"].isMember ("seq")
|
||||
|| !context.params_["offer"]["seq"].isIntegral ())
|
||||
else if (!context.params["offer"].isMember ("account")
|
||||
|| !context.params["offer"].isMember ("seq")
|
||||
|| !context.params["offer"]["seq"].isIntegral ())
|
||||
{
|
||||
jvResult["error"] = "malformedRequest";
|
||||
}
|
||||
else if (!naAccountID.setAccountID (
|
||||
context.params_["offer"]["account"].asString ()))
|
||||
context.params["offer"]["account"].asString ()))
|
||||
{
|
||||
jvResult["error"] = "malformedAddress";
|
||||
}
|
||||
else
|
||||
{
|
||||
auto uSequence = context.params_["offer"]["seq"].asUInt ();
|
||||
auto uSequence = context.params["offer"]["seq"].asUInt ();
|
||||
uNodeIndex = Ledger::getOfferIndex (
|
||||
naAccountID.getAccountID (), uSequence);
|
||||
}
|
||||
}
|
||||
else if (context.params_.isMember ("ripple_state"))
|
||||
else if (context.params.isMember ("ripple_state"))
|
||||
{
|
||||
RippleAddress naA;
|
||||
RippleAddress naB;
|
||||
Currency uCurrency;
|
||||
Json::Value jvRippleState = context.params_["ripple_state"];
|
||||
Json::Value jvRippleState = context.params["ripple_state"];
|
||||
|
||||
if (!jvRippleState.isObject ()
|
||||
|| !jvRippleState.isMember ("currency")
|
||||
@@ -206,10 +206,10 @@ Json::Value doLedgerEntry (RPC::Context& context)
|
||||
|
||||
if (uNodeIndex.isNonZero ())
|
||||
{
|
||||
auto sleNode = context.netOps_.getSLEi (lpLedger, uNodeIndex);
|
||||
auto sleNode = context.netOps.getSLEi (lpLedger, uNodeIndex);
|
||||
|
||||
if (context.params_.isMember("binary"))
|
||||
bNodeBinary = context.params_["binary"].asBool();
|
||||
if (context.params.isMember("binary"))
|
||||
bNodeBinary = context.params["binary"].asBool();
|
||||
|
||||
if (!sleNode)
|
||||
{
|
||||
|
||||
@@ -28,7 +28,7 @@ Json::Value doLedgerHeader (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (
|
||||
context.params_, lpLedger, context.netOps_);
|
||||
context.params, lpLedger, context.netOps);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
@@ -26,8 +26,8 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doLedgerRequest (RPC::Context& context)
|
||||
{
|
||||
auto const hasHash = context.params_.isMember (jss::ledger_hash);
|
||||
auto const hasIndex = context.params_.isMember (jss::ledger_index);
|
||||
auto const hasHash = context.params.isMember (jss::ledger_hash);
|
||||
auto const hasIndex = context.params.isMember (jss::ledger_index);
|
||||
|
||||
auto& ledgerMaster = getApp().getLedgerMaster();
|
||||
LedgerHash ledgerHash;
|
||||
@@ -40,11 +40,11 @@ Json::Value doLedgerRequest (RPC::Context& context)
|
||||
|
||||
if (hasHash)
|
||||
{
|
||||
auto const& jsonHash = context.params_[jss::ledger_hash];
|
||||
auto const& jsonHash = context.params[jss::ledger_hash];
|
||||
if (!jsonHash.isString() || !ledgerHash.SetHex (jsonHash.asString ()))
|
||||
return RPC::invalid_field_message ("ledger_hash");
|
||||
} else {
|
||||
auto const& jsonIndex = context.params_[jss::ledger_index];
|
||||
auto const& jsonIndex = context.params[jss::ledger_index];
|
||||
if (!jsonIndex.isNumeric ())
|
||||
return RPC::invalid_field_message ("ledger_index");
|
||||
|
||||
|
||||
@@ -23,7 +23,7 @@ namespace ripple {
|
||||
Json::Value doLogLevel (RPC::Context& context)
|
||||
{
|
||||
// log_level
|
||||
if (!context.params_.isMember ("severity"))
|
||||
if (!context.params.isMember ("severity"))
|
||||
{
|
||||
// get log severities
|
||||
Json::Value ret (Json::objectValue);
|
||||
@@ -42,14 +42,14 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
}
|
||||
|
||||
LogSeverity const sv (
|
||||
Logs::fromString (context.params_["severity"].asString ()));
|
||||
Logs::fromString (context.params["severity"].asString ()));
|
||||
|
||||
if (sv == lsINVALID)
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
auto severity = Logs::toSeverity(sv);
|
||||
// log_level severity
|
||||
if (!context.params_.isMember ("partition"))
|
||||
if (!context.params.isMember ("partition"))
|
||||
{
|
||||
// set base log severity
|
||||
deprecatedLogs().severity(severity);
|
||||
@@ -57,10 +57,10 @@ Json::Value doLogLevel (RPC::Context& context)
|
||||
}
|
||||
|
||||
// log_level partition severity base?
|
||||
if (context.params_.isMember ("partition"))
|
||||
if (context.params.isMember ("partition"))
|
||||
{
|
||||
// set partition severity
|
||||
std::string partition (context.params_["partition"].asString ());
|
||||
std::string partition (context.params["partition"].asString ());
|
||||
|
||||
if (boost::iequals (partition, "base"))
|
||||
deprecatedLogs().severity (severity);
|
||||
|
||||
@@ -27,24 +27,24 @@ namespace ripple {
|
||||
Json::Value doOwnerInfo (RPC::Context& context)
|
||||
{
|
||||
auto lock = getApp().masterLock();
|
||||
if (!context.params_.isMember ("account") &&
|
||||
!context.params_.isMember ("ident"))
|
||||
if (!context.params.isMember ("account") &&
|
||||
!context.params.isMember ("ident"))
|
||||
{
|
||||
return RPC::missing_field_error ("account");
|
||||
}
|
||||
|
||||
std::string strIdent = context.params_.isMember ("account")
|
||||
? context.params_["account"].asString ()
|
||||
: context.params_["ident"].asString ();
|
||||
std::string strIdent = context.params.isMember ("account")
|
||||
? context.params["account"].asString ()
|
||||
: context.params["ident"].asString ();
|
||||
bool bIndex;
|
||||
int iIndex = context.params_.isMember ("account_index")
|
||||
? context.params_["account_index"].asUInt () : 0;
|
||||
int iIndex = context.params.isMember ("account_index")
|
||||
? context.params["account_index"].asUInt () : 0;
|
||||
RippleAddress raAccount;
|
||||
Json::Value ret;
|
||||
|
||||
// Get info on account.
|
||||
|
||||
auto const& closedLedger = context.netOps_.getClosedLedger ();
|
||||
auto const& closedLedger = context.netOps.getClosedLedger ();
|
||||
Json::Value jAccepted = RPC::accountFromString (
|
||||
closedLedger,
|
||||
raAccount,
|
||||
@@ -52,12 +52,12 @@ Json::Value doOwnerInfo (RPC::Context& context)
|
||||
strIdent,
|
||||
iIndex,
|
||||
false,
|
||||
context.netOps_);
|
||||
context.netOps);
|
||||
|
||||
ret["accepted"] = jAccepted.empty () ? context.netOps_.getOwnerInfo (
|
||||
ret["accepted"] = jAccepted.empty () ? context.netOps.getOwnerInfo (
|
||||
closedLedger, raAccount) : jAccepted;
|
||||
|
||||
auto const& currentLedger = context.netOps_.getCurrentLedger ();
|
||||
auto const& currentLedger = context.netOps.getCurrentLedger ();
|
||||
Json::Value jCurrent = RPC::accountFromString (
|
||||
currentLedger,
|
||||
raAccount,
|
||||
@@ -65,9 +65,9 @@ Json::Value doOwnerInfo (RPC::Context& context)
|
||||
strIdent,
|
||||
iIndex,
|
||||
false,
|
||||
context.netOps_);
|
||||
context.netOps);
|
||||
|
||||
ret["current"] = jCurrent.empty () ? context.netOps_.getOwnerInfo (
|
||||
ret["current"] = jCurrent.empty () ? context.netOps.getOwnerInfo (
|
||||
currentLedger, raAccount) : jCurrent;
|
||||
|
||||
return ret;
|
||||
|
||||
@@ -22,46 +22,46 @@ namespace ripple {
|
||||
|
||||
Json::Value doPathFind (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger = context.netOps_.getClosedLedger();
|
||||
Ledger::pointer lpLedger = context.netOps.getClosedLedger();
|
||||
|
||||
if (!context.params_.isMember ("subcommand") ||
|
||||
!context.params_["subcommand"].isString ())
|
||||
if (!context.params.isMember ("subcommand") ||
|
||||
!context.params["subcommand"].isString ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (!context.infoSub_)
|
||||
if (!context.infoSub)
|
||||
return rpcError (rpcNO_EVENTS);
|
||||
|
||||
std::string sSubCommand = context.params_["subcommand"].asString ();
|
||||
std::string sSubCommand = context.params["subcommand"].asString ();
|
||||
|
||||
if (sSubCommand == "create")
|
||||
{
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.infoSub_->clearPathRequest ();
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
context.infoSub->clearPathRequest ();
|
||||
return getApp().getPathRequests().makePathRequest (
|
||||
context.infoSub_, lpLedger, context.params_);
|
||||
context.infoSub, lpLedger, context.params);
|
||||
}
|
||||
|
||||
if (sSubCommand == "close")
|
||||
{
|
||||
PathRequest::pointer request = context.infoSub_->getPathRequest ();
|
||||
PathRequest::pointer request = context.infoSub->getPathRequest ();
|
||||
|
||||
if (!request)
|
||||
return rpcError (rpcNO_PF_REQUEST);
|
||||
|
||||
context.infoSub_->clearPathRequest ();
|
||||
return request->doClose (context.params_);
|
||||
context.infoSub->clearPathRequest ();
|
||||
return request->doClose (context.params);
|
||||
}
|
||||
|
||||
if (sSubCommand == "status")
|
||||
{
|
||||
PathRequest::pointer request = context.infoSub_->getPathRequest ();
|
||||
PathRequest::pointer request = context.infoSub->getPathRequest ();
|
||||
|
||||
if (!request)
|
||||
return rpcError (rpcNO_PF_REQUEST);
|
||||
|
||||
return request->doStatus (context.params_);
|
||||
return request->doStatus (context.params);
|
||||
}
|
||||
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
@@ -23,11 +23,11 @@ namespace ripple {
|
||||
Json::Value doPrint (RPC::Context& context)
|
||||
{
|
||||
JsonPropertyStream stream;
|
||||
if (context.params_.isObject()
|
||||
&& context.params_["params"].isArray()
|
||||
&& context.params_["params"][0u].isString ())
|
||||
if (context.params.isObject()
|
||||
&& context.params["params"].isArray()
|
||||
&& context.params["params"][0u].isString ())
|
||||
{
|
||||
getApp().write (stream, context.params_["params"][0u].asString());
|
||||
getApp().write (stream, context.params["params"][0u].asString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -31,18 +31,18 @@ Json::Value doProofCreate (RPC::Context& context)
|
||||
// XXX: Add ability to create proof with arbitrary time
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
if (context.params_.isMember ("difficulty") ||
|
||||
context.params_.isMember ("secret"))
|
||||
if (context.params.isMember ("difficulty") ||
|
||||
context.params.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
auto pgGen = make_ProofOfWorkFactory ();
|
||||
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
if (context.params.isMember ("difficulty"))
|
||||
{
|
||||
if (!context.params_["difficulty"].isIntegral ())
|
||||
if (!context.params["difficulty"].isIntegral ())
|
||||
return RPC::invalid_field_error ("difficulty");
|
||||
|
||||
int const iDifficulty (context.params_["difficulty"].asInt ());
|
||||
int const iDifficulty (context.params["difficulty"].asInt ());
|
||||
|
||||
if (iDifficulty < 0 ||
|
||||
iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
|
||||
@@ -53,9 +53,9 @@ Json::Value doProofCreate (RPC::Context& context)
|
||||
pgGen->setDifficulty (iDifficulty);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("secret"))
|
||||
if (context.params.isMember ("secret"))
|
||||
{
|
||||
uint256 uSecret (context.params_["secret"].asString ());
|
||||
uint256 uSecret (context.params["secret"].asString ());
|
||||
pgGen->setSecret (uSecret);
|
||||
}
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ Json::Value doProofSolve (RPC::Context& context)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!context.params_.isMember ("token"))
|
||||
if (!context.params.isMember ("token"))
|
||||
return RPC::missing_field_error ("token");
|
||||
|
||||
std::string strToken = context.params_["token"].asString ();
|
||||
std::string strToken = context.params["token"].asString ();
|
||||
|
||||
if (!ProofOfWork::validateToken (strToken))
|
||||
return RPC::invalid_field_error ("token");
|
||||
|
||||
@@ -33,29 +33,29 @@ Json::Value doProofVerify (RPC::Context& context)
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!context.params_.isMember ("token"))
|
||||
if (!context.params.isMember ("token"))
|
||||
return RPC::missing_field_error ("token");
|
||||
|
||||
if (!context.params_.isMember ("solution"))
|
||||
if (!context.params.isMember ("solution"))
|
||||
return RPC::missing_field_error ("solution");
|
||||
|
||||
std::string strToken = context.params_["token"].asString ();
|
||||
uint256 uSolution (context.params_["solution"].asString ());
|
||||
std::string strToken = context.params["token"].asString ();
|
||||
uint256 uSolution (context.params["solution"].asString ());
|
||||
|
||||
PowResult prResult;
|
||||
|
||||
if (context.params_.isMember ("difficulty") ||
|
||||
context.params_.isMember ("secret"))
|
||||
if (context.params.isMember ("difficulty") ||
|
||||
context.params.isMember ("secret"))
|
||||
{
|
||||
// VFALCO TODO why aren't we using the app's factory?
|
||||
auto pgGen = make_ProofOfWorkFactory ();
|
||||
|
||||
if (context.params_.isMember ("difficulty"))
|
||||
if (context.params.isMember ("difficulty"))
|
||||
{
|
||||
if (!context.params_["difficulty"].isIntegral ())
|
||||
if (!context.params["difficulty"].isIntegral ())
|
||||
return RPC::invalid_field_error ("difficulty");
|
||||
|
||||
int iDifficulty = context.params_["difficulty"].asInt ();
|
||||
int iDifficulty = context.params["difficulty"].asInt ();
|
||||
|
||||
if (iDifficulty < 0 ||
|
||||
iDifficulty > ProofOfWorkFactory::kMaxDifficulty)
|
||||
@@ -66,9 +66,9 @@ Json::Value doProofVerify (RPC::Context& context)
|
||||
pgGen->setDifficulty (iDifficulty);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("secret"))
|
||||
if (context.params.isMember ("secret"))
|
||||
{
|
||||
uint256 uSecret (context.params_["secret"].asString ());
|
||||
uint256 uSecret (context.params["secret"].asString ());
|
||||
pgGen->setSecret (uSecret);
|
||||
}
|
||||
|
||||
|
||||
@@ -18,17 +18,18 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/rpc/impl/LegacyPathFind.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
// This interface is deprecated.
|
||||
Json::Value doRipplePathFind (RPC::Context& context)
|
||||
{
|
||||
RPC::LegacyPathFind lpf (context.role_ == Role::ADMIN);
|
||||
RPC::LegacyPathFind lpf (context.role == Role::ADMIN);
|
||||
if (!lpf.isOk ())
|
||||
return rpcError (rpcTOO_BUSY);
|
||||
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
|
||||
RippleAddress raSrc;
|
||||
RippleAddress raDst;
|
||||
@@ -38,41 +39,41 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
Json::Value jvResult;
|
||||
|
||||
if (getConfig().RUN_STANDALONE ||
|
||||
context.params_.isMember(jss::ledger) ||
|
||||
context.params_.isMember(jss::ledger_index) ||
|
||||
context.params_.isMember(jss::ledger_hash))
|
||||
context.params.isMember(jss::ledger) ||
|
||||
context.params.isMember(jss::ledger_index) ||
|
||||
context.params.isMember(jss::ledger_hash))
|
||||
{
|
||||
// The caller specified a ledger
|
||||
jvResult = RPC::lookupLedger (
|
||||
context.params_, lpLedger, context.netOps_);
|
||||
context.params, lpLedger, context.netOps);
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
if (!context.params_.isMember ("source_account"))
|
||||
if (!context.params.isMember ("source_account"))
|
||||
{
|
||||
jvResult = rpcError (rpcSRC_ACT_MISSING);
|
||||
}
|
||||
else if (!context.params_["source_account"].isString ()
|
||||
else if (!context.params["source_account"].isString ()
|
||||
|| !raSrc.setAccountID (
|
||||
context.params_["source_account"].asString ()))
|
||||
context.params["source_account"].asString ()))
|
||||
{
|
||||
jvResult = rpcError (rpcSRC_ACT_MALFORMED);
|
||||
}
|
||||
else if (!context.params_.isMember ("destination_account"))
|
||||
else if (!context.params.isMember ("destination_account"))
|
||||
{
|
||||
jvResult = rpcError (rpcDST_ACT_MISSING);
|
||||
}
|
||||
else if (!context.params_["destination_account"].isString ()
|
||||
else if (!context.params["destination_account"].isString ()
|
||||
|| !raDst.setAccountID (
|
||||
context.params_["destination_account"].asString ()))
|
||||
context.params["destination_account"].asString ()))
|
||||
{
|
||||
jvResult = rpcError (rpcDST_ACT_MALFORMED);
|
||||
}
|
||||
else if (
|
||||
// Parse saDstAmount.
|
||||
!context.params_.isMember ("destination_amount")
|
||||
|| ! amountFromJsonNoThrow(saDstAmount, context.params_["destination_amount"])
|
||||
!context.params.isMember ("destination_amount")
|
||||
|| ! amountFromJsonNoThrow(saDstAmount, context.params["destination_amount"])
|
||||
|| saDstAmount <= zero
|
||||
|| (!isXRP(saDstAmount.getCurrency ())
|
||||
&& (!saDstAmount.getIssuer () ||
|
||||
@@ -83,9 +84,9 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
}
|
||||
else if (
|
||||
// Checks on source_currencies.
|
||||
context.params_.isMember ("source_currencies")
|
||||
&& (!context.params_["source_currencies"].isArray ()
|
||||
|| !context.params_["source_currencies"].size ())
|
||||
context.params.isMember ("source_currencies")
|
||||
&& (!context.params["source_currencies"].isArray ()
|
||||
|| !context.params["source_currencies"].size ())
|
||||
// Don't allow empty currencies.
|
||||
)
|
||||
{
|
||||
@@ -94,7 +95,7 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
RippleLineCache::pointer cache;
|
||||
|
||||
if (lpLedger)
|
||||
@@ -107,15 +108,15 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
{
|
||||
// The closed ledger is recent and any nodes made resident
|
||||
// have the best chance to persist
|
||||
lpLedger = context.netOps_.getClosedLedger();
|
||||
lpLedger = context.netOps.getClosedLedger();
|
||||
cache = getApp().getPathRequests().getLineCache(lpLedger, false);
|
||||
}
|
||||
|
||||
Json::Value jvSrcCurrencies;
|
||||
|
||||
if (context.params_.isMember ("source_currencies"))
|
||||
if (context.params.isMember ("source_currencies"))
|
||||
{
|
||||
jvSrcCurrencies = context.params_["source_currencies"];
|
||||
jvSrcCurrencies = context.params["source_currencies"];
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -188,17 +189,17 @@ Json::Value doRipplePathFind (RPC::Context& context)
|
||||
{
|
||||
++level;
|
||||
}
|
||||
if (context.params_.isMember("depth")
|
||||
&& context.params_["depth"].isIntegral())
|
||||
if (context.params.isMember("depth")
|
||||
&& context.params["depth"].isIntegral())
|
||||
{
|
||||
int rLev = context.params_["search_depth"].asInt ();
|
||||
if ((rLev < level) || (context.role_ == Role::ADMIN))
|
||||
int rLev = context.params["search_depth"].asInt ();
|
||||
if ((rLev < level) || (context.role == Role::ADMIN))
|
||||
level = rLev;
|
||||
}
|
||||
|
||||
if (context.params_.isMember("paths"))
|
||||
if (context.params.isMember("paths"))
|
||||
{
|
||||
STParsedJSONObject paths ("paths", context.params_["paths"]);
|
||||
STParsedJSONObject paths ("paths", context.params["paths"]);
|
||||
if (paths.object.get() == nullptr)
|
||||
return paths.error;
|
||||
else
|
||||
|
||||
@@ -22,11 +22,11 @@ namespace ripple {
|
||||
|
||||
Json::Value doSMS (RPC::Context& context)
|
||||
{
|
||||
if (!context.params_.isMember ("text"))
|
||||
if (!context.params.isMember ("text"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
HTTPClient::sendSMS (
|
||||
getApp().getIOService (), context.params_["text"].asString ());
|
||||
getApp().getIOService (), context.params["text"].asString ());
|
||||
|
||||
return "sms dispatched";
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -25,8 +26,8 @@ Json::Value doServerInfo (RPC::Context& context)
|
||||
auto lock = getApp().masterLock();
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
ret["info"] = context.netOps_.getServerInfo (
|
||||
true, context.role_ == Role::ADMIN);
|
||||
ret["info"] = context.netOps.getServerInfo (
|
||||
true, context.role == Role::ADMIN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -25,8 +26,8 @@ Json::Value doServerState (RPC::Context& context)
|
||||
auto lock = getApp().masterLock();
|
||||
Json::Value ret (Json::objectValue);
|
||||
|
||||
ret["state"] = context.netOps_.getServerInfo (
|
||||
false, context.role_ == Role::ADMIN);
|
||||
ret["state"] = context.netOps.getServerInfo (
|
||||
false, context.role == Role::ADMIN);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -27,11 +27,11 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doSign (RPC::Context& context)
|
||||
{
|
||||
context.loadType_ = Resource::feeHighBurdenRPC;
|
||||
bool bFailHard = context.params_.isMember ("fail_hard")
|
||||
&& context.params_["fail_hard"].asBool ();
|
||||
context.loadType = Resource::feeHighBurdenRPC;
|
||||
bool bFailHard = context.params.isMember ("fail_hard")
|
||||
&& context.params["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (
|
||||
context.params_, false, bFailHard, context.netOps_, context.role_);
|
||||
context.params, false, bFailHard, context.netOps, context.role);
|
||||
}
|
||||
|
||||
} // ripple
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/basics/StringUtilities.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -27,19 +28,19 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doSubmit (RPC::Context& context)
|
||||
{
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (!context.params_.isMember ("tx_blob"))
|
||||
if (!context.params.isMember ("tx_blob"))
|
||||
{
|
||||
bool bFailHard = context.params_.isMember ("fail_hard")
|
||||
&& context.params_["fail_hard"].asBool ();
|
||||
bool bFailHard = context.params.isMember ("fail_hard")
|
||||
&& context.params["fail_hard"].asBool ();
|
||||
return RPC::transactionSign (
|
||||
context.params_, true, bFailHard, context.netOps_, context.role_);
|
||||
context.params, true, bFailHard, context.netOps, context.role);
|
||||
}
|
||||
|
||||
Json::Value jvResult;
|
||||
|
||||
std::pair<Blob, bool> ret(strUnHex (context.params_["tx_blob"].asString ()));
|
||||
std::pair<Blob, bool> ret(strUnHex (context.params["tx_blob"].asString ()));
|
||||
|
||||
if (!ret.second || !ret.first.size ())
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
@@ -85,10 +86,10 @@ Json::Value doSubmit (RPC::Context& context)
|
||||
|
||||
try
|
||||
{
|
||||
(void) context.netOps_.processTransaction (
|
||||
tpTrans, context.role_ == Role::ADMIN, true,
|
||||
context.params_.isMember ("fail_hard")
|
||||
&& context.params_["fail_hard"].asBool ());
|
||||
(void) context.netOps.processTransaction (
|
||||
tpTrans, context.role == Role::ADMIN, true,
|
||||
context.params.isMember ("fail_hard")
|
||||
&& context.params["fail_hard"].asBool ());
|
||||
}
|
||||
catch (std::exception& e)
|
||||
{
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/rpc/impl/ParseAccountIds.h>
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -30,12 +31,12 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
std::uint32_t uLedgerIndex = context.params_.isMember (jss::ledger_index)
|
||||
&& context.params_[jss::ledger_index].isNumeric ()
|
||||
? context.params_[jss::ledger_index].asUInt ()
|
||||
std::uint32_t uLedgerIndex = context.params.isMember (jss::ledger_index)
|
||||
&& context.params[jss::ledger_index].isNumeric ()
|
||||
? context.params[jss::ledger_index].asUInt ()
|
||||
: 0;
|
||||
|
||||
if (!context.infoSub_ && !context.params_.isMember ("url"))
|
||||
if (!context.infoSub && !context.params.isMember ("url"))
|
||||
{
|
||||
// Must be a JSON-RPC call.
|
||||
WriteLog (lsINFO, RPCHandler)
|
||||
@@ -44,26 +45,26 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("url"))
|
||||
if (context.params.isMember ("url"))
|
||||
{
|
||||
if (context.role_ != Role::ADMIN)
|
||||
if (context.role != Role::ADMIN)
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
std::string strUrl = context.params_["url"].asString ();
|
||||
std::string strUsername = context.params_.isMember ("url_username") ?
|
||||
context.params_["url_username"].asString () : "";
|
||||
std::string strPassword = context.params_.isMember ("url_password") ?
|
||||
context.params_["url_password"].asString () : "";
|
||||
std::string strUrl = context.params["url"].asString ();
|
||||
std::string strUsername = context.params.isMember ("url_username") ?
|
||||
context.params["url_username"].asString () : "";
|
||||
std::string strPassword = context.params.isMember ("url_password") ?
|
||||
context.params["url_password"].asString () : "";
|
||||
|
||||
// DEPRECATED
|
||||
if (context.params_.isMember ("username"))
|
||||
strUsername = context.params_["username"].asString ();
|
||||
if (context.params.isMember ("username"))
|
||||
strUsername = context.params["username"].asString ();
|
||||
|
||||
// DEPRECATED
|
||||
if (context.params_.isMember ("password"))
|
||||
strPassword = context.params_["password"].asString ();
|
||||
if (context.params.isMember ("password"))
|
||||
strPassword = context.params["password"].asString ();
|
||||
|
||||
ispSub = context.netOps_.findRpcSub (strUrl);
|
||||
ispSub = context.netOps.findRpcSub (strUrl);
|
||||
|
||||
if (!ispSub)
|
||||
{
|
||||
@@ -73,7 +74,7 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
RPCSub::pointer rspSub = RPCSub::New (getApp ().getOPs (),
|
||||
getApp ().getIOService (), getApp ().getJobQueue (),
|
||||
strUrl, strUsername, strPassword);
|
||||
ispSub = context.netOps_.addRpcSub (
|
||||
ispSub = context.netOps.addRpcSub (
|
||||
strUrl, std::dynamic_pointer_cast<InfoSub> (rspSub));
|
||||
}
|
||||
else
|
||||
@@ -81,22 +82,22 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
WriteLog (lsTRACE, RPCHandler)
|
||||
<< "doSubscribe: reusing: " << strUrl;
|
||||
|
||||
if (context.params_.isMember ("username"))
|
||||
if (context.params.isMember ("username"))
|
||||
dynamic_cast<RPCSub*> (&*ispSub)->setUsername (strUsername);
|
||||
|
||||
if (context.params_.isMember ("password"))
|
||||
if (context.params.isMember ("password"))
|
||||
dynamic_cast<RPCSub*> (&*ispSub)->setPassword (strPassword);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
ispSub = context.infoSub_;
|
||||
ispSub = context.infoSub;
|
||||
}
|
||||
|
||||
if (!context.params_.isMember ("streams"))
|
||||
if (!context.params.isMember ("streams"))
|
||||
{
|
||||
}
|
||||
else if (!context.params_["streams"].isArray ())
|
||||
else if (!context.params["streams"].isArray ())
|
||||
{
|
||||
WriteLog (lsINFO, RPCHandler)
|
||||
<< "doSubscribe: streams requires an array.";
|
||||
@@ -105,7 +106,7 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& it: context.params_["streams"])
|
||||
for (auto& it: context.params["streams"])
|
||||
{
|
||||
if (it.isString ())
|
||||
{
|
||||
@@ -113,21 +114,21 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
|
||||
if (streamName == "server")
|
||||
{
|
||||
context.netOps_.subServer (ispSub, jvResult,
|
||||
context.role_ == Role::ADMIN);
|
||||
context.netOps.subServer (ispSub, jvResult,
|
||||
context.role == Role::ADMIN);
|
||||
}
|
||||
else if (streamName == "ledger")
|
||||
{
|
||||
context.netOps_.subLedger (ispSub, jvResult);
|
||||
context.netOps.subLedger (ispSub, jvResult);
|
||||
}
|
||||
else if (streamName == "transactions")
|
||||
{
|
||||
context.netOps_.subTransactions (ispSub);
|
||||
context.netOps.subTransactions (ispSub);
|
||||
}
|
||||
else if (streamName == "transactions_proposed"
|
||||
|| streamName == "rt_transactions") // DEPRECATED
|
||||
{
|
||||
context.netOps_.subRTTransactions (ispSub);
|
||||
context.netOps.subRTTransactions (ispSub);
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -142,36 +143,36 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
}
|
||||
|
||||
std::string strAccountsProposed =
|
||||
context.params_.isMember ("accounts_proposed")
|
||||
context.params.isMember ("accounts_proposed")
|
||||
? "accounts_proposed" : "rt_accounts"; // DEPRECATED
|
||||
|
||||
if (!context.params_.isMember (strAccountsProposed))
|
||||
if (!context.params.isMember (strAccountsProposed))
|
||||
{
|
||||
}
|
||||
else if (!context.params_[strAccountsProposed].isArray ())
|
||||
else if (!context.params[strAccountsProposed].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ids = RPC::parseAccountIds (context.params_[strAccountsProposed]);
|
||||
auto ids = RPC::parseAccountIds (context.params[strAccountsProposed]);
|
||||
|
||||
if (ids.empty ())
|
||||
jvResult[jss::error] = "malformedAccount";
|
||||
else
|
||||
context.netOps_.subAccount (ispSub, ids, uLedgerIndex, true);
|
||||
context.netOps.subAccount (ispSub, ids, uLedgerIndex, true);
|
||||
}
|
||||
|
||||
if (!context.params_.isMember ("accounts"))
|
||||
if (!context.params.isMember ("accounts"))
|
||||
{
|
||||
}
|
||||
else if (!context.params_["accounts"].isArray ())
|
||||
else if (!context.params["accounts"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
auto ids = RPC::parseAccountIds (context.params_["accounts"]);
|
||||
auto ids = RPC::parseAccountIds (context.params["accounts"]);
|
||||
|
||||
if (ids.empty ())
|
||||
{
|
||||
@@ -179,23 +180,23 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.netOps_.subAccount (ispSub, ids, uLedgerIndex, false);
|
||||
context.netOps.subAccount (ispSub, ids, uLedgerIndex, false);
|
||||
WriteLog (lsDEBUG, RPCHandler)
|
||||
<< "doSubscribe: accounts: " << ids.size ();
|
||||
}
|
||||
}
|
||||
|
||||
bool bHaveMasterLock = true;
|
||||
if (!context.params_.isMember ("books"))
|
||||
if (!context.params.isMember ("books"))
|
||||
{
|
||||
}
|
||||
else if (!context.params_["books"].isArray ())
|
||||
else if (!context.params["books"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& j: context.params_["books"])
|
||||
for (auto& j: context.params["books"])
|
||||
{
|
||||
if (!j.isObject ()
|
||||
|| !j.isMember (jss::taker_pays)
|
||||
@@ -284,10 +285,10 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
return rpcError (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
context.netOps_.subBook (ispSub, book);
|
||||
context.netOps.subBook (ispSub, book);
|
||||
|
||||
if (bBoth)
|
||||
context.netOps_.subBook (ispSub, book);
|
||||
context.netOps.subBook (ispSub, book);
|
||||
|
||||
if (bSnapshot)
|
||||
{
|
||||
@@ -297,7 +298,7 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
bHaveMasterLock = false;
|
||||
}
|
||||
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
auto lpLedger = getApp().getLedgerMaster ().
|
||||
getPublishedLedger ();
|
||||
if (lpLedger)
|
||||
@@ -309,14 +310,14 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
Json::Value jvBids (Json::objectValue);
|
||||
Json::Value jvAsks (Json::objectValue);
|
||||
|
||||
context.netOps_.getBookPage (
|
||||
context.netOps.getBookPage (
|
||||
lpLedger, book, raTakerID.getAccountID (), false, 0,
|
||||
jvMarker, jvBids);
|
||||
|
||||
if (jvBids.isMember (jss::offers))
|
||||
jvResult[jss::bids] = jvBids[jss::offers];
|
||||
|
||||
context.netOps_.getBookPage (
|
||||
context.netOps.getBookPage (
|
||||
lpLedger, book, raTakerID.getAccountID (),
|
||||
false, 0, jvMarker, jvAsks);
|
||||
|
||||
@@ -325,7 +326,7 @@ Json::Value doSubscribe (RPC::Context& context)
|
||||
}
|
||||
else
|
||||
{
|
||||
context.netOps_.getBookPage (
|
||||
context.netOps.getBookPage (
|
||||
lpLedger, book, raTakerID.getAccountID (), false, 0,
|
||||
jvMarker, jvResult);
|
||||
}
|
||||
|
||||
@@ -31,19 +31,19 @@ Json::Value doTransactionEntry (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer lpLedger;
|
||||
Json::Value jvResult = RPC::lookupLedger (
|
||||
context.params_,
|
||||
context.params,
|
||||
lpLedger,
|
||||
context.netOps_);
|
||||
context.netOps);
|
||||
|
||||
if (!lpLedger)
|
||||
return jvResult;
|
||||
|
||||
if (!context.params_.isMember ("tx_hash"))
|
||||
if (!context.params.isMember ("tx_hash"))
|
||||
{
|
||||
jvResult["error"] = "fieldNotFoundTransaction";
|
||||
}
|
||||
else if (!context.params_.isMember ("ledger_hash")
|
||||
&& !context.params_.isMember ("ledger_index"))
|
||||
else if (!context.params.isMember ("ledger_hash")
|
||||
&& !context.params.isMember ("ledger_index"))
|
||||
{
|
||||
// We don't work on ledger current.
|
||||
|
||||
@@ -55,7 +55,7 @@ Json::Value doTransactionEntry (RPC::Context& context)
|
||||
uint256 uTransID;
|
||||
// XXX Relying on trusted WSS client. Would be better to have a strict
|
||||
// routine, returning success or failure.
|
||||
uTransID.SetHex (context.params_["tx_hash"].asString ());
|
||||
uTransID.SetHex (context.params["tx_hash"].asString ());
|
||||
|
||||
if (!lpLedger)
|
||||
{
|
||||
|
||||
@@ -25,13 +25,13 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doTx (RPC::Context& context)
|
||||
{
|
||||
if (!context.params_.isMember (jss::transaction))
|
||||
if (!context.params.isMember (jss::transaction))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
bool binary = context.params_.isMember (jss::binary)
|
||||
&& context.params_[jss::binary].asBool ();
|
||||
bool binary = context.params.isMember (jss::binary)
|
||||
&& context.params[jss::binary].asBool ();
|
||||
|
||||
std::string strTransaction = context.params_[jss::transaction].asString ();
|
||||
std::string strTransaction = context.params[jss::transaction].asString ();
|
||||
|
||||
if (Transaction::isHexTxID (strTransaction))
|
||||
{
|
||||
@@ -53,7 +53,7 @@ Json::Value doTx (RPC::Context& context)
|
||||
|
||||
if (txn->getLedger () != 0)
|
||||
{
|
||||
if (auto lgr = context.netOps_.getLedgerBySeq (txn->getLedger ()))
|
||||
if (auto lgr = context.netOps.getLedgerBySeq (txn->getLedger ()))
|
||||
{
|
||||
bool okay = false;
|
||||
if (binary)
|
||||
@@ -77,7 +77,7 @@ Json::Value doTx (RPC::Context& context)
|
||||
}
|
||||
|
||||
if (okay)
|
||||
ret[jss::validated] = context.netOps_.isValidated (lgr);
|
||||
ret[jss::validated] = context.netOps.isValidated (lgr);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -25,14 +26,14 @@ namespace ripple {
|
||||
// }
|
||||
Json::Value doTxHistory (RPC::Context& context)
|
||||
{
|
||||
context.loadType_ = Resource::feeMediumBurdenRPC;
|
||||
context.loadType = Resource::feeMediumBurdenRPC;
|
||||
|
||||
if (!context.params_.isMember ("start"))
|
||||
if (!context.params.isMember ("start"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
unsigned int startIndex = context.params_["start"].asUInt ();
|
||||
unsigned int startIndex = context.params["start"].asUInt ();
|
||||
|
||||
if ((startIndex > 10000) && (context.role_ != Role::ADMIN))
|
||||
if ((startIndex > 10000) && (context.role != Role::ADMIN))
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
Json::Value obj;
|
||||
|
||||
@@ -28,10 +28,10 @@ Json::Value doUnlAdd (RPC::Context& context)
|
||||
{
|
||||
auto lock = getApp().masterLock();
|
||||
|
||||
std::string strNode = context.params_.isMember ("node")
|
||||
? context.params_["node"].asString () : "";
|
||||
std::string strComment = context.params_.isMember ("comment")
|
||||
? context.params_["comment"].asString () : "";
|
||||
std::string strNode = context.params.isMember ("node")
|
||||
? context.params["node"].asString () : "";
|
||||
std::string strComment = context.params.isMember ("comment")
|
||||
? context.params["comment"].asString () : "";
|
||||
|
||||
RippleAddress raNodePublic;
|
||||
|
||||
|
||||
@@ -27,10 +27,10 @@ Json::Value doUnlDelete (RPC::Context& context)
|
||||
{
|
||||
auto lock = getApp().masterLock();
|
||||
|
||||
if (!context.params_.isMember ("node"))
|
||||
if (!context.params.isMember ("node"))
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
|
||||
auto strNode = context.params_["node"].asString ();
|
||||
auto strNode = context.params["node"].asString ();
|
||||
RippleAddress raNodePublic;
|
||||
|
||||
if (raNodePublic.setNodePublic (strNode))
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
*/
|
||||
//==============================================================================
|
||||
|
||||
#include <ripple/server/Role.h>
|
||||
|
||||
namespace ripple {
|
||||
|
||||
@@ -29,48 +30,48 @@ Json::Value doUnsubscribe (RPC::Context& context)
|
||||
InfoSub::pointer ispSub;
|
||||
Json::Value jvResult (Json::objectValue);
|
||||
|
||||
if (!context.infoSub_ && !context.params_.isMember ("url"))
|
||||
if (!context.infoSub && !context.params.isMember ("url"))
|
||||
{
|
||||
// Must be a JSON-RPC call.
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("url"))
|
||||
if (context.params.isMember ("url"))
|
||||
{
|
||||
if (context.role_ != Role::ADMIN)
|
||||
if (context.role != Role::ADMIN)
|
||||
return rpcError (rpcNO_PERMISSION);
|
||||
|
||||
std::string strUrl = context.params_["url"].asString ();
|
||||
ispSub = context.netOps_.findRpcSub (strUrl);
|
||||
std::string strUrl = context.params["url"].asString ();
|
||||
ispSub = context.netOps.findRpcSub (strUrl);
|
||||
|
||||
if (!ispSub)
|
||||
return jvResult;
|
||||
}
|
||||
else
|
||||
{
|
||||
ispSub = context.infoSub_;
|
||||
ispSub = context.infoSub;
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("streams"))
|
||||
if (context.params.isMember ("streams"))
|
||||
{
|
||||
for (auto& it: context.params_["streams"])
|
||||
for (auto& it: context.params["streams"])
|
||||
{
|
||||
if (it.isString ())
|
||||
{
|
||||
std::string streamName = it.asString ();
|
||||
|
||||
if (streamName == "server")
|
||||
context.netOps_.unsubServer (ispSub->getSeq ());
|
||||
context.netOps.unsubServer (ispSub->getSeq ());
|
||||
|
||||
else if (streamName == "ledger")
|
||||
context.netOps_.unsubLedger (ispSub->getSeq ());
|
||||
context.netOps.unsubLedger (ispSub->getSeq ());
|
||||
|
||||
else if (streamName == "transactions")
|
||||
context.netOps_.unsubTransactions (ispSub->getSeq ());
|
||||
context.netOps.unsubTransactions (ispSub->getSeq ());
|
||||
|
||||
else if (streamName == "transactions_proposed"
|
||||
|| streamName == "rt_transactions") // DEPRECATED
|
||||
context.netOps_.unsubRTTransactions (ispSub->getSeq ());
|
||||
context.netOps.unsubRTTransactions (ispSub->getSeq ());
|
||||
|
||||
else
|
||||
jvResult["error"] = "Unknown stream: " + streamName;
|
||||
@@ -82,40 +83,40 @@ Json::Value doUnsubscribe (RPC::Context& context)
|
||||
}
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("accounts_proposed")
|
||||
|| context.params_.isMember ("rt_accounts"))
|
||||
if (context.params.isMember ("accounts_proposed")
|
||||
|| context.params.isMember ("rt_accounts"))
|
||||
{
|
||||
auto accounts = RPC::parseAccountIds (
|
||||
context.params_.isMember ("accounts_proposed")
|
||||
? context.params_["accounts_proposed"]
|
||||
: context.params_["rt_accounts"]); // DEPRECATED
|
||||
context.params.isMember ("accounts_proposed")
|
||||
? context.params["accounts_proposed"]
|
||||
: context.params["rt_accounts"]); // DEPRECATED
|
||||
|
||||
if (accounts.empty ())
|
||||
jvResult["error"] = "malformedAccount";
|
||||
else
|
||||
context.netOps_.unsubAccount (ispSub->getSeq (), accounts, true);
|
||||
context.netOps.unsubAccount (ispSub->getSeq (), accounts, true);
|
||||
}
|
||||
|
||||
if (context.params_.isMember ("accounts"))
|
||||
if (context.params.isMember ("accounts"))
|
||||
{
|
||||
auto accounts = RPC::parseAccountIds (context.params_["accounts"]);
|
||||
auto accounts = RPC::parseAccountIds (context.params["accounts"]);
|
||||
|
||||
if (accounts.empty ())
|
||||
jvResult["error"] = "malformedAccount";
|
||||
else
|
||||
context.netOps_.unsubAccount (ispSub->getSeq (), accounts, false);
|
||||
context.netOps.unsubAccount (ispSub->getSeq (), accounts, false);
|
||||
}
|
||||
|
||||
if (!context.params_.isMember ("books"))
|
||||
if (!context.params.isMember ("books"))
|
||||
{
|
||||
}
|
||||
else if (!context.params_["books"].isArray ())
|
||||
else if (!context.params["books"].isArray ())
|
||||
{
|
||||
return rpcError (rpcINVALID_PARAMS);
|
||||
}
|
||||
else
|
||||
{
|
||||
for (auto& jv: context.params_["books"])
|
||||
for (auto& jv: context.params["books"])
|
||||
{
|
||||
if (!jv.isObject ()
|
||||
|| !jv.isMember ("taker_pays")
|
||||
@@ -185,10 +186,10 @@ Json::Value doUnsubscribe (RPC::Context& context)
|
||||
return rpcError (rpcBAD_MARKET);
|
||||
}
|
||||
|
||||
context.netOps_.unsubBook (ispSub->getSeq (), book);
|
||||
context.netOps.unsubBook (ispSub->getSeq (), book);
|
||||
|
||||
if (bBoth)
|
||||
context.netOps_.unsubBook (ispSub->getSeq (), book);
|
||||
context.netOps.unsubBook (ispSub->getSeq (), book);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -31,13 +31,13 @@ Json::Value doValidationCreate (RPC::Context& context)
|
||||
RippleAddress raSeed;
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
if (!context.params_.isMember ("secret"))
|
||||
if (!context.params.isMember ("secret"))
|
||||
{
|
||||
WriteLog (lsDEBUG, RPCHandler) << "Creating random validation seed.";
|
||||
|
||||
raSeed.setSeedRandom (); // Get a random seed.
|
||||
}
|
||||
else if (!raSeed.setSeedGeneric (context.params_["secret"].asString ()))
|
||||
else if (!raSeed.setSeedGeneric (context.params["secret"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
|
||||
@@ -28,7 +28,7 @@ Json::Value doValidationSeed (RPC::Context& context)
|
||||
auto lock = getApp().masterLock();
|
||||
Json::Value obj (Json::objectValue);
|
||||
|
||||
if (!context.params_.isMember ("secret"))
|
||||
if (!context.params.isMember ("secret"))
|
||||
{
|
||||
std::cerr << "Unset validation seed." << std::endl;
|
||||
|
||||
@@ -37,7 +37,7 @@ Json::Value doValidationSeed (RPC::Context& context)
|
||||
getConfig ().VALIDATION_PRIV.clear ();
|
||||
}
|
||||
else if (!getConfig ().VALIDATION_SEED.setSeedGeneric (
|
||||
context.params_["secret"].asString ()))
|
||||
context.params["secret"].asString ()))
|
||||
{
|
||||
getConfig ().VALIDATION_PUB.clear ();
|
||||
getConfig ().VALIDATION_PRIV.clear ();
|
||||
|
||||
@@ -31,15 +31,15 @@ Json::Value doWalletAccounts (RPC::Context& context)
|
||||
{
|
||||
Ledger::pointer ledger;
|
||||
Json::Value jvResult
|
||||
= RPC::lookupLedger (context.params_, ledger, context.netOps_);
|
||||
= RPC::lookupLedger (context.params, ledger, context.netOps);
|
||||
|
||||
if (!ledger)
|
||||
return jvResult;
|
||||
|
||||
RippleAddress naSeed;
|
||||
|
||||
if (!context.params_.isMember ("seed")
|
||||
|| !naSeed.setSeedGeneric (context.params_["seed"].asString ()))
|
||||
if (!context.params.isMember ("seed")
|
||||
|| !naSeed.setSeedGeneric (context.params["seed"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
@@ -49,19 +49,19 @@ Json::Value doWalletAccounts (RPC::Context& context)
|
||||
= RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
Json::Value jsonAccounts
|
||||
= RPC::accounts (ledger, naMasterGenerator, context.netOps_);
|
||||
= RPC::accounts (ledger, naMasterGenerator, context.netOps);
|
||||
|
||||
if (jsonAccounts.empty ())
|
||||
{
|
||||
// No account via seed as master, try seed a regular.
|
||||
Json::Value ret = RPC::getMasterGenerator (
|
||||
ledger, naSeed, naMasterGenerator, context.netOps_);
|
||||
ledger, naSeed, naMasterGenerator, context.netOps);
|
||||
|
||||
if (!ret.empty ())
|
||||
return ret;
|
||||
|
||||
ret["accounts"]
|
||||
= RPC::accounts (ledger, naMasterGenerator, context.netOps_);
|
||||
= RPC::accounts (ledger, naMasterGenerator, context.netOps);
|
||||
return ret;
|
||||
}
|
||||
else
|
||||
|
||||
@@ -28,10 +28,10 @@ Json::Value doWalletPropose (RPC::Context& context)
|
||||
RippleAddress naSeed;
|
||||
RippleAddress naAccount;
|
||||
|
||||
if (!context.params_.isMember ("passphrase"))
|
||||
if (!context.params.isMember ("passphrase"))
|
||||
naSeed.setSeedRandom ();
|
||||
|
||||
else if (!naSeed.setSeedGeneric (context.params_["passphrase"].asString ()))
|
||||
else if (!naSeed.setSeedGeneric (context.params["passphrase"].asString ()))
|
||||
return rpcError(rpcBAD_SEED);
|
||||
|
||||
RippleAddress naGenerator = RippleAddress::createGeneratorPublic (naSeed);
|
||||
|
||||
@@ -25,9 +25,9 @@ namespace ripple {
|
||||
Json::Value doWalletSeed (RPC::Context& context)
|
||||
{
|
||||
RippleAddress seed;
|
||||
bool bSecret = context.params_.isMember ("secret");
|
||||
bool bSecret = context.params.isMember ("secret");
|
||||
|
||||
if (bSecret && !seed.setSeedGeneric (context.params_["secret"].asString ()))
|
||||
if (bSecret && !seed.setSeedGeneric (context.params["secret"].asString ()))
|
||||
{
|
||||
return rpcError (rpcBAD_SEED);
|
||||
}
|
||||
|
||||
@@ -29,12 +29,11 @@ namespace RPC {
|
||||
/** The context of information needed to call an RPC. */
|
||||
struct Context
|
||||
{
|
||||
// VFALCO NOTE Public members should not have underscores appended
|
||||
Json::Value params_;
|
||||
Resource::Charge& loadType_;
|
||||
NetworkOPs& netOps_;
|
||||
InfoSub::pointer infoSub_;
|
||||
Role role_;
|
||||
Json::Value params;
|
||||
Resource::Charge& loadType;
|
||||
NetworkOPs& netOps;
|
||||
InfoSub::pointer infoSub;
|
||||
Role role;
|
||||
};
|
||||
|
||||
} // RPC
|
||||
|
||||
Reference in New Issue
Block a user