mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
More fixes for API changes.
This commit is contained in:
@@ -1195,8 +1195,10 @@ bool NetworkOPs::unsubLedger(InfoSub* ispListener)
|
||||
}
|
||||
|
||||
// <-- bool: true=added, false=already there
|
||||
bool NetworkOPs::subServer(InfoSub* ispListener)
|
||||
bool NetworkOPs::subServer(InfoSub* ispListener, Json::Value& jvResult)
|
||||
{
|
||||
jvResult["stand_alone"] = theConfig.RUN_STANDALONE;
|
||||
|
||||
return mSubServer.insert(ispListener).second;
|
||||
}
|
||||
|
||||
|
||||
@@ -228,7 +228,7 @@ public:
|
||||
bool subLedger(InfoSub* ispListener, Json::Value& jvResult);
|
||||
bool unsubLedger(InfoSub* ispListener);
|
||||
|
||||
bool subServer(InfoSub* ispListener);
|
||||
bool subServer(InfoSub* ispListener, Json::Value& jvResult);
|
||||
bool unsubServer(InfoSub* ispListener);
|
||||
|
||||
bool subTransactions(InfoSub* ispListener);
|
||||
|
||||
@@ -326,8 +326,6 @@ Json::Value RPCHandler::doAcceptLedger(const Json::Value ¶ms)
|
||||
return obj;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// account_info <account>|<nickname>|<account_public_key>
|
||||
// account_info <seed>|<pass_phrase>|<key> [<index>]
|
||||
Json::Value RPCHandler::doAccountInfo(const Json::Value ¶ms)
|
||||
@@ -690,9 +688,10 @@ Json::Value RPCHandler::doRippleLinesGet(const Json::Value ¶ms)
|
||||
// submit private_key json
|
||||
Json::Value RPCHandler::doSubmit(const Json::Value& params)
|
||||
{
|
||||
Json::Value txJSON;
|
||||
Json::Reader reader;
|
||||
if(reader.parse(params[1u].asString(),txJSON))
|
||||
Json::Value txJSON;
|
||||
Json::Reader reader;
|
||||
|
||||
if (reader.parse(params[1u].asString(), txJSON))
|
||||
{
|
||||
Json::Value jvRequest;
|
||||
|
||||
@@ -702,7 +701,12 @@ Json::Value RPCHandler::doSubmit(const Json::Value& params)
|
||||
return handleJSONSubmit(jvRequest);
|
||||
}
|
||||
|
||||
return rpcError(rpcSRC_ACT_MALFORMED);
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doSubmitJson(const Json::Value& jvRequest)
|
||||
{
|
||||
return handleJSONSubmit(jvRequest);
|
||||
}
|
||||
|
||||
|
||||
@@ -711,9 +715,9 @@ Json::Value RPCHandler::handleJSONSubmit(const Json::Value& jvRequest)
|
||||
Json::Value jvResult;
|
||||
RippleAddress naSeed;
|
||||
RippleAddress srcAddress;
|
||||
Json::Value txJSON = jvResult["tx_json"];
|
||||
Json::Value txJSON = jvRequest["tx_json"];
|
||||
|
||||
if (!naSeed.setSeedGeneric(jvResult["secret"].asString()))
|
||||
if (!naSeed.setSeedGeneric(jvRequest["secret"].asString()))
|
||||
{
|
||||
return rpcError(rpcBAD_SEED);
|
||||
}
|
||||
@@ -820,7 +824,7 @@ Json::Value RPCHandler::handleJSONSubmit(const Json::Value& jvRequest)
|
||||
RippleAddress naAuthorizedPublic;
|
||||
|
||||
|
||||
RippleAddress naSecret = RippleAddress::createSeedGeneric(jvResult["secret"].asString());
|
||||
RippleAddress naSecret = RippleAddress::createSeedGeneric(jvRequest["secret"].asString());
|
||||
RippleAddress naMasterGenerator = RippleAddress::createGeneratorPublic(naSecret);
|
||||
|
||||
// Find the index of Account from the master generator, so we can generate the public and private keys.
|
||||
@@ -1288,22 +1292,22 @@ Json::Value RPCHandler::doWalletAccounts(const Json::Value& params)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Json::Value RPCHandler::doLogRotate(const Json::Value& params)
|
||||
Json::Value RPCHandler::doLogRotate(const Json::Value& params)
|
||||
{
|
||||
return Log::rotateLog();
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& params,int role)
|
||||
Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& params, int role)
|
||||
{
|
||||
cLog(lsTRACE) << "RPC:" << command;
|
||||
cLog(lsTRACE) << "RPC params:" << params;
|
||||
|
||||
static struct {
|
||||
const char* pCommand;
|
||||
doFuncPtr dfpFunc;
|
||||
int iMinParams;
|
||||
int iMaxParams;
|
||||
bool mAdminRequired;
|
||||
const char* pCommand;
|
||||
doFuncPtr dfpFunc;
|
||||
int iMinParams;
|
||||
int iMaxParams;
|
||||
bool mAdminRequired;
|
||||
unsigned int iOptions;
|
||||
} commandsA[] = {
|
||||
{ "accept_ledger", &RPCHandler::doAcceptLedger, 0, 0, true },
|
||||
@@ -1315,6 +1319,10 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
{ "data_store", &RPCHandler::doDataStore, 2, 2, true },
|
||||
{ "get_counts", &RPCHandler::doGetCounts, 0, 1, true },
|
||||
{ "ledger", &RPCHandler::doLedger, 0, 2, false, optNetwork },
|
||||
{ "ledger_accept", &RPCHandler::doLedgerAccept, 0, 0, true, optCurrent },
|
||||
{ "ledger_closed", &RPCHandler::doLedgerClosed, 0, 0, false, optClosed },
|
||||
{ "ledger_current", &RPCHandler::doLedgerCurrent, 0, 0, false, optCurrent },
|
||||
{ "ledger_entry", &RPCHandler::doLedgerEntry, -1, -1, false, optCurrent },
|
||||
{ "log_level", &RPCHandler::doLogLevel, 0, 2, true },
|
||||
{ "logrotate", &RPCHandler::doLogRotate, 0, 0, true },
|
||||
{ "nickname_info", &RPCHandler::doNicknameInfo, 1, 1, false, optCurrent },
|
||||
@@ -1323,8 +1331,10 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
{ "profile", &RPCHandler::doProfile, 1, 9, false, optCurrent },
|
||||
{ "ripple_lines_get", &RPCHandler::doRippleLinesGet, 1, 2, false, optCurrent },
|
||||
{ "submit", &RPCHandler::doSubmit, 2, 2, false, optCurrent },
|
||||
{ "submit_json", &RPCHandler::doSubmitJson, -1, -1, false, optCurrent },
|
||||
{ "server_info", &RPCHandler::doServerInfo, 0, 0, true },
|
||||
{ "stop", &RPCHandler::doStop, 0, 0, true },
|
||||
{ "transaction_entry", &RPCHandler::doTransactionEntry, -1, -1, false, optCurrent },
|
||||
{ "tx", &RPCHandler::doTx, 1, 1, true },
|
||||
{ "tx_history", &RPCHandler::doTxHistory, 1, 1, false, },
|
||||
|
||||
@@ -1359,8 +1369,12 @@ Json::Value RPCHandler::doCommand(const std::string& command, Json::Value& param
|
||||
{
|
||||
return rpcError(rpcNO_PERMISSION);
|
||||
}
|
||||
else if (params.size() < commandsA[i].iMinParams
|
||||
|| (commandsA[i].iMaxParams >= 0 && params.size() > commandsA[i].iMaxParams))
|
||||
else if (commandsA[i].iMinParams >= 0
|
||||
? commandsA[i].iMaxParams
|
||||
? (params.size() < commandsA[i].iMinParams
|
||||
|| (commandsA[i].iMaxParams >= 0 && params.size() > commandsA[i].iMaxParams))
|
||||
: false
|
||||
: params.isArray())
|
||||
{
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
}
|
||||
@@ -1605,6 +1619,7 @@ Json::Value RPCHandler::doUnlLoad(const Json::Value& params)
|
||||
Json::Value RPCHandler::doLedgerAccept(const Json::Value& )
|
||||
{
|
||||
Json::Value jvResult;
|
||||
|
||||
if (!theConfig.RUN_STANDALONE)
|
||||
{
|
||||
jvResult["error"] = "notStandAlone";
|
||||
@@ -1615,16 +1630,13 @@ Json::Value RPCHandler::doLedgerAccept(const Json::Value& )
|
||||
|
||||
jvResult["ledger_current_index"] = mNetOps->getCurrentLedgerID();
|
||||
}
|
||||
return(jvResult);
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doTransactionEntry(const Json::Value& params)
|
||||
Json::Value RPCHandler::doTransactionEntry(const Json::Value& jvRequest)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
Json::Value jvRequest;
|
||||
Json::Reader reader;
|
||||
if(!reader.parse(params[0u].asString(),jvRequest))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
if (!jvRequest.isMember("tx_hash"))
|
||||
{
|
||||
@@ -1672,13 +1684,9 @@ Json::Value RPCHandler::doTransactionEntry(const Json::Value& params)
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doLedgerEntry(const Json::Value& params)
|
||||
Json::Value RPCHandler::doLedgerEntry(const Json::Value& jvRequest)
|
||||
{
|
||||
Json::Value jvResult;
|
||||
Json::Value jvRequest;
|
||||
Json::Reader reader;
|
||||
if(!reader.parse(params[0u].asString(),jvRequest))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
|
||||
uint256 uLedger = jvRequest.isMember("ledger_hash") ? uint256(jvRequest["ledger_hash"].asString()) : 0;
|
||||
uint32 uLedgerIndex = jvRequest.isMember("ledger_index") && jvRequest["ledger_index"].isNumeric() ? jvRequest["ledger_index"].asUInt() : 0;
|
||||
|
||||
@@ -28,7 +28,7 @@ class RPCHandler
|
||||
Json::Value accountFromString(const uint256& uLedger, RippleAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
||||
|
||||
Json::Value doAcceptLedger(const Json::Value ¶ms);
|
||||
|
||||
|
||||
Json::Value doAccountInfo(const Json::Value& params);
|
||||
Json::Value doAccountTransactions(const Json::Value& params);
|
||||
Json::Value doConnect(const Json::Value& params);
|
||||
@@ -39,21 +39,22 @@ class RPCHandler
|
||||
Json::Value doLedger(const Json::Value& params);
|
||||
Json::Value doLogRotate(const Json::Value& params);
|
||||
Json::Value doNicknameInfo(const Json::Value& params);
|
||||
|
||||
|
||||
Json::Value doOwnerInfo(const Json::Value& params);
|
||||
|
||||
|
||||
Json::Value doProfile(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
|
||||
|
||||
Json::Value doRippleLinesGet(const Json::Value ¶ms);
|
||||
Json::Value doServerInfo(const Json::Value& params);
|
||||
Json::Value doSessionClose(const Json::Value& params);
|
||||
Json::Value doSessionOpen(const Json::Value& params);
|
||||
Json::Value doLogLevel(const Json::Value& params);
|
||||
Json::Value doStop(const Json::Value& params);
|
||||
Json::Value doSubmit(const Json::Value& params);
|
||||
Json::Value doSubmitJson(const Json::Value& jvRequest);
|
||||
Json::Value doTx(const Json::Value& params);
|
||||
Json::Value doTxHistory(const Json::Value& params);
|
||||
Json::Value doSubmit(const Json::Value& params);
|
||||
|
||||
|
||||
Json::Value doUnlAdd(const Json::Value& params);
|
||||
|
||||
@@ -65,8 +65,6 @@ Json::Value WSConnection::invokeCommand(Json::Value& jvRequest)
|
||||
|
||||
Json::Value jvResult(Json::objectValue);
|
||||
|
||||
jvResult["type"] = "response";
|
||||
|
||||
if (i < 0)
|
||||
{
|
||||
jvResult["error"] = "unknownCommand"; // Unknown command.
|
||||
@@ -91,6 +89,8 @@ Json::Value WSConnection::invokeCommand(Json::Value& jvRequest)
|
||||
jvResult["result"] = "success";
|
||||
}
|
||||
|
||||
jvResult["type"] = "response";
|
||||
|
||||
return jvResult;
|
||||
}
|
||||
|
||||
@@ -134,13 +134,13 @@ void WSConnection::doSubscribe(Json::Value& jvResult, Json::Value& jvRequest)
|
||||
{
|
||||
for (Json::Value::iterator it = jvRequest["streams"].begin(); it != jvRequest["streams"].end(); it++)
|
||||
{
|
||||
if ((*it).isString() )
|
||||
if ((*it).isString())
|
||||
{
|
||||
std::string streamName=(*it).asString();
|
||||
|
||||
if(streamName=="server")
|
||||
{
|
||||
mNetwork.subServer(this);
|
||||
mNetwork.subServer(this, jvResult);
|
||||
}else if(streamName=="ledger")
|
||||
{
|
||||
mNetwork.subLedger(this, jvResult);
|
||||
@@ -280,14 +280,19 @@ void WSConnection::doRPC(Json::Value& jvResult, Json::Value& jvRequest)
|
||||
{
|
||||
if (jvRequest.isMember("rpc_command") )
|
||||
{
|
||||
jvResult=theApp->getRPCHandler().doCommand(
|
||||
jvResult = theApp->getRPCHandler().doCommand(
|
||||
jvRequest["rpc_command"].asString(),
|
||||
jvRequest["params"],
|
||||
jvRequest.isMember("params")
|
||||
? jvRequest["params"]
|
||||
: jvRequest,
|
||||
mHandler->getPublic() ? RPCHandler::GUEST : RPCHandler::ADMIN);
|
||||
|
||||
jvResult["type"] = "rpc_response";
|
||||
}else jvResult["error"] = "fieldNotCommand";
|
||||
|
||||
jvResult["type"] = "response";
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["error"] = "fieldNotCommand";
|
||||
}
|
||||
}
|
||||
|
||||
// XXX Currently requires secret. Allow signed transaction as an alternative.
|
||||
|
||||
Reference in New Issue
Block a user