mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-30 07:55:51 +00:00
broke up RPCServer
This commit is contained in:
@@ -142,6 +142,7 @@
|
||||
<ClCompile Include="src\rpc.cpp" />
|
||||
<ClCompile Include="src\RPCCommands.cpp" />
|
||||
<ClCompile Include="src\RPCDoor.cpp" />
|
||||
<ClCompile Include="src\RPCHandler.cpp" />
|
||||
<ClCompile Include="src\RPCServer.cpp" />
|
||||
<ClCompile Include="src\ScriptData.cpp" />
|
||||
<ClCompile Include="src\SerializedLedger.cpp" />
|
||||
@@ -236,6 +237,7 @@
|
||||
<ClInclude Include="src\RPC.h" />
|
||||
<ClInclude Include="src\RPCCommands.h" />
|
||||
<ClInclude Include="src\RPCDoor.h" />
|
||||
<ClInclude Include="src\RPCHandler.h" />
|
||||
<ClInclude Include="src\RPCServer.h" />
|
||||
<ClInclude Include="src\ScopedLock.h" />
|
||||
<ClInclude Include="src\ScriptData.h" />
|
||||
|
||||
@@ -303,6 +303,9 @@
|
||||
<ClCompile Include="src\HTTPRequest.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\RPCHandler.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="KnownNodeList.h">
|
||||
@@ -557,6 +560,9 @@
|
||||
<ClInclude Include="src\Operation.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="src\RPCHandler.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="wallet.xml" />
|
||||
|
||||
@@ -1019,7 +1019,7 @@ void NetworkOPs::pubLedger(Ledger::ref lpAccepted)
|
||||
}
|
||||
}
|
||||
|
||||
// Publish bootsrap information for accounts.
|
||||
// Publish bootstrap information for accounts.
|
||||
{
|
||||
boost::interprocess::scoped_lock<boost::interprocess::interprocess_upgradable_mutex> sl(mMonitorLock);
|
||||
|
||||
|
||||
2713
src/RPCHandler.cpp
Normal file
2713
src/RPCHandler.cpp
Normal file
File diff suppressed because it is too large
Load Diff
159
src/RPCHandler.h
Normal file
159
src/RPCHandler.h
Normal file
@@ -0,0 +1,159 @@
|
||||
// used by the RPCServer or WSDoor to carry out these RPC commands
|
||||
class NetworkOPs;
|
||||
|
||||
class RPCHandler
|
||||
{
|
||||
NetworkOPs* mNetOps;
|
||||
|
||||
typedef Json::Value (RPCHandler::*doFuncPtr)(const Json::Value ¶ms);
|
||||
enum {
|
||||
optNetwork = 1, // Need network
|
||||
optCurrent = 2+optNetwork, // Need current ledger
|
||||
optClosed = 4+optNetwork, // Need closed ledger
|
||||
};
|
||||
|
||||
int getParamCount(const Json::Value& params);
|
||||
bool extractString(std::string& param, const Json::Value& params, int index);
|
||||
|
||||
Json::Value getMasterGenerator(const uint256& uLedger, const NewcoinAddress& naRegularSeed, NewcoinAddress& naMasterGenerator);
|
||||
Json::Value authorize(const uint256& uLedger, const NewcoinAddress& naRegularSeed, const NewcoinAddress& naSrcAccountID,
|
||||
NewcoinAddress& naAccountPublic, NewcoinAddress& naAccountPrivate,
|
||||
STAmount& saSrcBalance, const STAmount& saFee, AccountState::pointer& asSrc,
|
||||
const NewcoinAddress& naVerifyGenerator);
|
||||
Json::Value accounts(const uint256& uLedger, const NewcoinAddress& naMasterGenerator);
|
||||
|
||||
Json::Value accountFromString(const uint256& uLedger, NewcoinAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
||||
|
||||
Json::Value doAcceptLedger(const Json::Value ¶ms);
|
||||
Json::Value doAccountDomainSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountEmailSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountInfo(const Json::Value& params);
|
||||
Json::Value doAccountMessageSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountPublishSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountRateSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountTransactions(const Json::Value& params);
|
||||
Json::Value doAccountWalletSet(const Json::Value ¶ms);
|
||||
Json::Value doConnect(const Json::Value& params);
|
||||
Json::Value doDataDelete(const Json::Value& params);
|
||||
Json::Value doDataFetch(const Json::Value& params);
|
||||
Json::Value doDataStore(const Json::Value& params);
|
||||
Json::Value doLedger(const Json::Value& params);
|
||||
Json::Value doLogRotate(const Json::Value& params);
|
||||
Json::Value doNicknameInfo(const Json::Value& params);
|
||||
Json::Value doNicknameSet(const Json::Value& params);
|
||||
Json::Value doOfferCreate(const Json::Value& params);
|
||||
Json::Value doOfferCancel(const Json::Value& params);
|
||||
Json::Value doOwnerInfo(const Json::Value& params);
|
||||
Json::Value doPasswordFund(const Json::Value& params);
|
||||
Json::Value doPasswordSet(const Json::Value& params);
|
||||
Json::Value doProfile(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
Json::Value doRipple(const Json::Value ¶ms);
|
||||
Json::Value doRippleLinesGet(const Json::Value ¶ms);
|
||||
Json::Value doRippleLineSet(const Json::Value& params);
|
||||
Json::Value doSend(const Json::Value& params);
|
||||
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 doTransitSet(const Json::Value& params);
|
||||
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);
|
||||
Json::Value doUnlDelete(const Json::Value& params);
|
||||
Json::Value doUnlFetch(const Json::Value& params);
|
||||
Json::Value doUnlList(const Json::Value& params);
|
||||
Json::Value doUnlLoad(const Json::Value& params);
|
||||
Json::Value doUnlNetwork(const Json::Value& params);
|
||||
Json::Value doUnlReset(const Json::Value& params);
|
||||
Json::Value doUnlScore(const Json::Value& params);
|
||||
|
||||
Json::Value doValidationCreate(const Json::Value& params);
|
||||
Json::Value doValidationSeed(const Json::Value& params);
|
||||
|
||||
Json::Value doWalletAccounts(const Json::Value& params);
|
||||
Json::Value doWalletAdd(const Json::Value& params);
|
||||
Json::Value doWalletClaim(const Json::Value& params);
|
||||
Json::Value doWalletCreate(const Json::Value& params);
|
||||
Json::Value doWalletLock(const Json::Value& params);
|
||||
Json::Value doWalletPropose(const Json::Value& params);
|
||||
Json::Value doWalletSeed(const Json::Value& params);
|
||||
Json::Value doWalletUnlock(const Json::Value& params);
|
||||
Json::Value doWalletVerify(const Json::Value& params);
|
||||
|
||||
Json::Value doLogin(const Json::Value& params);
|
||||
|
||||
|
||||
public:
|
||||
|
||||
enum {
|
||||
rpcSUCCESS,
|
||||
|
||||
// Misc failure
|
||||
rpcLOAD_FAILED,
|
||||
rpcNO_PERMISSION,
|
||||
rpcNOT_STANDALONE,
|
||||
|
||||
// Networking
|
||||
rpcNO_CLOSED,
|
||||
rpcNO_CURRENT,
|
||||
rpcNO_NETWORK,
|
||||
|
||||
// Ledger state
|
||||
rpcACT_EXISTS,
|
||||
rpcACT_NOT_FOUND,
|
||||
rpcINSUF_FUNDS,
|
||||
rpcLGR_NOT_FOUND,
|
||||
rpcNICKNAME_MISSING,
|
||||
rpcNO_ACCOUNT,
|
||||
rpcPASSWD_CHANGED,
|
||||
rpcSRC_MISSING,
|
||||
rpcSRC_UNCLAIMED,
|
||||
rpcTXN_NOT_FOUND,
|
||||
rpcWRONG_SEED,
|
||||
|
||||
// Malformed command
|
||||
rpcINVALID_PARAMS,
|
||||
rpcUNKNOWN_COMMAND,
|
||||
|
||||
// Bad parameter
|
||||
rpcACT_MALFORMED,
|
||||
rpcQUALITY_MALFORMED,
|
||||
rpcBAD_SEED,
|
||||
rpcDST_ACT_MALFORMED,
|
||||
rpcDST_ACT_MISSING,
|
||||
rpcDST_AMT_MALFORMED,
|
||||
rpcGETS_ACT_MALFORMED,
|
||||
rpcGETS_AMT_MALFORMED,
|
||||
rpcHOST_IP_MALFORMED,
|
||||
rpcLGR_IDXS_INVALID,
|
||||
rpcLGR_IDX_MALFORMED,
|
||||
rpcNICKNAME_MALFORMED,
|
||||
rpcNICKNAME_PERM,
|
||||
rpcPAYS_ACT_MALFORMED,
|
||||
rpcPAYS_AMT_MALFORMED,
|
||||
rpcPORT_MALFORMED,
|
||||
rpcPUBLIC_MALFORMED,
|
||||
rpcSRC_ACT_MALFORMED,
|
||||
rpcSRC_ACT_MISSING,
|
||||
rpcSRC_AMT_MALFORMED,
|
||||
|
||||
// Internal error (should never happen)
|
||||
rpcINTERNAL, // Generic internal error.
|
||||
rpcFAIL_GEN_DECRPYT,
|
||||
rpcNOT_IMPL,
|
||||
rpcNO_GEN_DECRPYT,
|
||||
};
|
||||
|
||||
enum { GUEST, USER, ADMIN };
|
||||
|
||||
RPCHandler(NetworkOPs* netOps);
|
||||
|
||||
Json::Value doCommand(const std::string& command, Json::Value& params,int role);
|
||||
Json::Value rpcError(int iError);
|
||||
|
||||
};
|
||||
2702
src/RPCServer.cpp
2702
src/RPCServer.cpp
File diff suppressed because it is too large
Load Diff
153
src/RPCServer.h
153
src/RPCServer.h
@@ -12,82 +12,19 @@
|
||||
#include "NewcoinAddress.h"
|
||||
#include "NetworkOPs.h"
|
||||
#include "SerializedLedger.h"
|
||||
#include "RPCHandler.h"
|
||||
|
||||
class RPCServer : public boost::enable_shared_from_this<RPCServer>
|
||||
{
|
||||
public:
|
||||
enum {
|
||||
rpcSUCCESS,
|
||||
|
||||
// Misc failure
|
||||
rpcLOAD_FAILED,
|
||||
rpcNO_PERMISSION,
|
||||
rpcNOT_STANDALONE,
|
||||
|
||||
// Networking
|
||||
rpcNO_CLOSED,
|
||||
rpcNO_CURRENT,
|
||||
rpcNO_NETWORK,
|
||||
|
||||
// Ledger state
|
||||
rpcACT_EXISTS,
|
||||
rpcACT_NOT_FOUND,
|
||||
rpcINSUF_FUNDS,
|
||||
rpcLGR_NOT_FOUND,
|
||||
rpcNICKNAME_MISSING,
|
||||
rpcNO_ACCOUNT,
|
||||
rpcPASSWD_CHANGED,
|
||||
rpcSRC_MISSING,
|
||||
rpcSRC_UNCLAIMED,
|
||||
rpcTXN_NOT_FOUND,
|
||||
rpcWRONG_SEED,
|
||||
|
||||
// Malformed command
|
||||
rpcINVALID_PARAMS,
|
||||
rpcUNKNOWN_COMMAND,
|
||||
|
||||
// Bad parameter
|
||||
rpcACT_MALFORMED,
|
||||
rpcQUALITY_MALFORMED,
|
||||
rpcBAD_SEED,
|
||||
rpcDST_ACT_MALFORMED,
|
||||
rpcDST_ACT_MISSING,
|
||||
rpcDST_AMT_MALFORMED,
|
||||
rpcGETS_ACT_MALFORMED,
|
||||
rpcGETS_AMT_MALFORMED,
|
||||
rpcHOST_IP_MALFORMED,
|
||||
rpcLGR_IDXS_INVALID,
|
||||
rpcLGR_IDX_MALFORMED,
|
||||
rpcNICKNAME_MALFORMED,
|
||||
rpcNICKNAME_PERM,
|
||||
rpcPAYS_ACT_MALFORMED,
|
||||
rpcPAYS_AMT_MALFORMED,
|
||||
rpcPORT_MALFORMED,
|
||||
rpcPUBLIC_MALFORMED,
|
||||
rpcSRC_ACT_MALFORMED,
|
||||
rpcSRC_ACT_MISSING,
|
||||
rpcSRC_AMT_MALFORMED,
|
||||
|
||||
// Internal error (should never happen)
|
||||
rpcINTERNAL, // Generic internal error.
|
||||
rpcFAIL_GEN_DECRPYT,
|
||||
rpcNOT_IMPL,
|
||||
rpcNO_GEN_DECRPYT,
|
||||
};
|
||||
|
||||
Json::Value RPCError(int iError);
|
||||
|
||||
|
||||
typedef boost::shared_ptr<RPCServer> pointer;
|
||||
|
||||
private:
|
||||
typedef Json::Value (RPCServer::*doFuncPtr)(const Json::Value ¶ms);
|
||||
enum {
|
||||
optNetwork = 1, // Need network
|
||||
optCurrent = 2+optNetwork, // Need current ledger
|
||||
optClosed = 4+optNetwork, // Need closed ledger
|
||||
};
|
||||
|
||||
|
||||
NetworkOPs* mNetOps;
|
||||
RPCHandler mRPCHandler;
|
||||
|
||||
boost::asio::ip::tcp::socket mSocket;
|
||||
|
||||
@@ -97,7 +34,7 @@ private:
|
||||
|
||||
HTTPRequest mHTTPRequest;
|
||||
|
||||
enum { GUEST, USER, ADMIN };
|
||||
|
||||
int mRole;
|
||||
|
||||
RPCServer(boost::asio::io_service& io_service, NetworkOPs* nopNetwork);
|
||||
@@ -111,86 +48,6 @@ private:
|
||||
|
||||
std::string handleRequest(const std::string& requestStr);
|
||||
|
||||
Json::Value doCommand(const std::string& command, Json::Value& params);
|
||||
int getParamCount(const Json::Value& params);
|
||||
bool extractString(std::string& param, const Json::Value& params, int index);
|
||||
|
||||
Json::Value getMasterGenerator(const uint256& uLedger, const NewcoinAddress& naRegularSeed, NewcoinAddress& naMasterGenerator);
|
||||
Json::Value authorize(const uint256& uLedger, const NewcoinAddress& naRegularSeed, const NewcoinAddress& naSrcAccountID,
|
||||
NewcoinAddress& naAccountPublic, NewcoinAddress& naAccountPrivate,
|
||||
STAmount& saSrcBalance, const STAmount& saFee, AccountState::pointer& asSrc,
|
||||
const NewcoinAddress& naVerifyGenerator);
|
||||
Json::Value accounts(const uint256& uLedger, const NewcoinAddress& naMasterGenerator);
|
||||
|
||||
Json::Value accountFromString(const uint256& uLedger, NewcoinAddress& naAccount, bool& bIndex, const std::string& strIdent, const int iIndex);
|
||||
|
||||
Json::Value doAcceptLedger(const Json::Value ¶ms);
|
||||
Json::Value doAccountDomainSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountEmailSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountInfo(const Json::Value& params);
|
||||
Json::Value doAccountMessageSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountPublishSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountRateSet(const Json::Value ¶ms);
|
||||
Json::Value doAccountTransactions(const Json::Value& params);
|
||||
Json::Value doAccountWalletSet(const Json::Value ¶ms);
|
||||
Json::Value doConnect(const Json::Value& params);
|
||||
Json::Value doDataDelete(const Json::Value& params);
|
||||
Json::Value doDataFetch(const Json::Value& params);
|
||||
Json::Value doDataStore(const Json::Value& params);
|
||||
Json::Value doLedger(const Json::Value& params);
|
||||
Json::Value doLogRotate(const Json::Value& params);
|
||||
Json::Value doNicknameInfo(const Json::Value& params);
|
||||
Json::Value doNicknameSet(const Json::Value& params);
|
||||
Json::Value doOfferCreate(const Json::Value& params);
|
||||
Json::Value doOfferCancel(const Json::Value& params);
|
||||
Json::Value doOwnerInfo(const Json::Value& params);
|
||||
Json::Value doPasswordFund(const Json::Value& params);
|
||||
Json::Value doPasswordSet(const Json::Value& params);
|
||||
Json::Value doProfile(const Json::Value& params);
|
||||
Json::Value doPeers(const Json::Value& params);
|
||||
Json::Value doRipple(const Json::Value ¶ms);
|
||||
Json::Value doRippleLinesGet(const Json::Value ¶ms);
|
||||
Json::Value doRippleLineSet(const Json::Value& params);
|
||||
Json::Value doSend(const Json::Value& params);
|
||||
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 doTransitSet(const Json::Value& params);
|
||||
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);
|
||||
Json::Value doUnlDelete(const Json::Value& params);
|
||||
Json::Value doUnlFetch(const Json::Value& params);
|
||||
Json::Value doUnlList(const Json::Value& params);
|
||||
Json::Value doUnlLoad(const Json::Value& params);
|
||||
Json::Value doUnlNetwork(const Json::Value& params);
|
||||
Json::Value doUnlReset(const Json::Value& params);
|
||||
Json::Value doUnlScore(const Json::Value& params);
|
||||
|
||||
Json::Value doValidationCreate(const Json::Value& params);
|
||||
Json::Value doValidationSeed(const Json::Value& params);
|
||||
|
||||
Json::Value doWalletAccounts(const Json::Value& params);
|
||||
Json::Value doWalletAdd(const Json::Value& params);
|
||||
Json::Value doWalletClaim(const Json::Value& params);
|
||||
Json::Value doWalletCreate(const Json::Value& params);
|
||||
Json::Value doWalletLock(const Json::Value& params);
|
||||
Json::Value doWalletPropose(const Json::Value& params);
|
||||
Json::Value doWalletSeed(const Json::Value& params);
|
||||
Json::Value doWalletUnlock(const Json::Value& params);
|
||||
Json::Value doWalletVerify(const Json::Value& params);
|
||||
|
||||
Json::Value doLogin(const Json::Value& params);
|
||||
|
||||
|
||||
// deprecated
|
||||
|
||||
|
||||
public:
|
||||
static pointer create(boost::asio::io_service& io_service, NetworkOPs* mNetOps)
|
||||
{
|
||||
|
||||
@@ -80,20 +80,21 @@ public:
|
||||
Json::Value invokeCommand(const Json::Value& jvRequest);
|
||||
boost::unordered_set<NewcoinAddress> parseAccountIds(const Json::Value& jvArray);
|
||||
|
||||
// Request-Response Commands
|
||||
void doLedgerAccept(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerClosed(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerCurrent(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
// Commands
|
||||
void doSubmit(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doTransactionEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
|
||||
// Streaming Commands
|
||||
void doRPC(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doSubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doUnsubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
|
||||
|
||||
|
||||
// deprecated
|
||||
void doLedgerAccept(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerClosed(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerCurrent(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doLedgerEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doTransactionEntry(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
|
||||
void doAccountInfoSubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doAccountInfoUnsubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
void doAccountTransactionSubscribe(Json::Value& jvResult, const Json::Value& jvRequest);
|
||||
@@ -911,6 +912,15 @@ void WSConnection::doServerUnsubscribe(Json::Value& jvResult, const Json::Value&
|
||||
}
|
||||
}
|
||||
|
||||
void WSConnection::doRPC(Json::Value& jvResult, const Json::Value& jvRequest)
|
||||
{
|
||||
if (jvRequest.isMember("commandline"))
|
||||
{
|
||||
|
||||
}else jvResult["error"] = "fieldNotFoundCommandline";
|
||||
|
||||
}
|
||||
|
||||
// XXX Current requires secret. Allow signed transaction as an alternative.
|
||||
void WSConnection::doSubmit(Json::Value& jvResult, const Json::Value& jvRequest)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user