mirror of
https://github.com/XRPLF/rippled.git
synced 2025-11-26 22:15:52 +00:00
Merge branch 'master' of github.com:jedmccaleb/NewCoin
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "AccountSetTransactor.h"
|
||||
#include "Config.h"
|
||||
|
||||
SETUP_LOG();
|
||||
|
||||
@@ -94,15 +95,22 @@ TER AccountSetTransactor::doApply()
|
||||
// MessageKey
|
||||
//
|
||||
|
||||
if (!mTxn.isFieldPresent(sfMessageKey))
|
||||
if (mTxn.isFieldPresent(sfMessageKey))
|
||||
{
|
||||
nothing();
|
||||
}
|
||||
else
|
||||
{
|
||||
cLog(lsINFO) << "AccountSet: set message key";
|
||||
std::vector<unsigned char> vucPublic = mTxn.getFieldVL(sfMessageKey);
|
||||
|
||||
mTxnAccount->setFieldVL(sfMessageKey, mTxn.getFieldVL(sfMessageKey));
|
||||
if (vucPublic.size() > PUBLIC_BYTES_MAX)
|
||||
{
|
||||
cLog(lsINFO) << "AccountSet: message key too long";
|
||||
|
||||
return telBAD_PUBLIC_KEY;
|
||||
}
|
||||
else
|
||||
{
|
||||
cLog(lsINFO) << "AccountSet: set message key";
|
||||
|
||||
mTxnAccount->setFieldVL(sfMessageKey, vucPublic);
|
||||
}
|
||||
}
|
||||
|
||||
//
|
||||
@@ -119,6 +127,12 @@ TER AccountSetTransactor::doApply()
|
||||
|
||||
mTxnAccount->makeFieldAbsent(sfDomain);
|
||||
}
|
||||
else if (vucDomain.size() > DOMAIN_BYTES_MAX)
|
||||
{
|
||||
cLog(lsINFO) << "AccountSet: domain too long";
|
||||
|
||||
return telBAD_DOMAIN;
|
||||
}
|
||||
else
|
||||
{
|
||||
cLog(lsINFO) << "AccountSet: set domain";
|
||||
|
||||
@@ -18,6 +18,7 @@
|
||||
#include <boost/thread.hpp>
|
||||
|
||||
SETUP_LOG();
|
||||
|
||||
LogPartition TaggedCachePartition("TaggedCache");
|
||||
Application* theApp = NULL;
|
||||
|
||||
|
||||
@@ -6,6 +6,7 @@
|
||||
#include <boost/iostreams/concepts.hpp>
|
||||
#include <boost/iostreams/stream.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
|
||||
#include <openssl/buffer.h>
|
||||
#include <openssl/evp.h>
|
||||
@@ -13,6 +14,7 @@
|
||||
#include "../json/value.h"
|
||||
#include "../json/reader.h"
|
||||
|
||||
#include "Application.h"
|
||||
#include "RPC.h"
|
||||
#include "Log.h"
|
||||
#include "RPCErr.h"
|
||||
@@ -54,8 +56,10 @@ std::string EncodeBase64(const std::string& s)
|
||||
Json::Value RPCParser::parseAsIs(const Json::Value& jvParams)
|
||||
{
|
||||
Json::Value v(Json::objectValue);
|
||||
|
||||
if (jvParams.isArray() && (jvParams.size() > 0))
|
||||
v["params"] = jvParams;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
@@ -656,7 +660,7 @@ int commandLineRPC(const std::vector<std::string>& vCmd)
|
||||
return nRet;
|
||||
}
|
||||
|
||||
Json::Value callRPC(const std::string& strIp, const int iPort, const std::string& strUsername, const std::string& strPassword, const std::string& strPath, const std::string& strMethod, const Json::Value& params)
|
||||
Json::Value callRPC(const std::string& strIp, const int iPort, const std::string& strUsername, const std::string& strPassword, const std::string& strPath, const std::string& strMethod, const Json::Value& jvParams)
|
||||
{
|
||||
// Connect to localhost
|
||||
if (!theConfig.QUIET)
|
||||
@@ -684,7 +688,7 @@ Json::Value callRPC(const std::string& strIp, const int iPort, const std::string
|
||||
// Log(lsDEBUG) << "requesting" << std::endl;
|
||||
|
||||
// Send request
|
||||
std::string strRequest = JSONRPCRequest(strMethod, params, Json::Value(1));
|
||||
std::string strRequest = JSONRPCRequest(strMethod, jvParams, Json::Value(1));
|
||||
// cLog(lsDEBUG) << "send request " << strMethod << " : " << strRequest << std::endl;
|
||||
|
||||
std::string strPost = createHTTPPost(strPath, strRequest, mapRequestHeaders);
|
||||
|
||||
@@ -1,17 +1,18 @@
|
||||
//
|
||||
// TODO: Check permissions on config file before using it.
|
||||
//
|
||||
#include <algorithm>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <boost/foreach.hpp>
|
||||
#include <boost/lexical_cast.hpp>
|
||||
|
||||
#include "Config.h"
|
||||
|
||||
#include "utils.h"
|
||||
#include "HashPrefixes.h"
|
||||
|
||||
#include <boost/lexical_cast.hpp>
|
||||
#include <boost/algorithm/string.hpp>
|
||||
#include <fstream>
|
||||
#include <iostream>
|
||||
#include <algorithm>
|
||||
|
||||
#define SECTION_ACCOUNT_PROBE_MAX "account_probe_max"
|
||||
#define SECTION_CLUSTER_NODES "cluster_nodes"
|
||||
#define SECTION_DATABASE_PATH "database_path"
|
||||
@@ -36,6 +37,7 @@
|
||||
#define SECTION_RPC_ALLOW_REMOTE "rpc_allow_remote"
|
||||
#define SECTION_RPC_IP "rpc_ip"
|
||||
#define SECTION_RPC_PORT "rpc_port"
|
||||
#define SECTION_RPC_STARTUP "rpc_startup"
|
||||
#define SECTION_SNTP "sntp_servers"
|
||||
#define SECTION_VALIDATORS_FILE "validators_file"
|
||||
#define SECTION_VALIDATION_QUORUM "validation_quorum"
|
||||
@@ -268,6 +270,21 @@ void Config::load()
|
||||
SNTP_SERVERS = *smtTmp;
|
||||
}
|
||||
|
||||
smtTmp = sectionEntries(secConfig, SECTION_RPC_STARTUP);
|
||||
if (smtTmp)
|
||||
{
|
||||
BOOST_FOREACH(const std::string& strJson, *smtTmp)
|
||||
{
|
||||
Json::Reader jrReader;
|
||||
Json::Value jvCommand;
|
||||
|
||||
if (!jrReader.parse(strJson, jvCommand))
|
||||
throw std::runtime_error(boost::str(boost::format("Couldn't parse ["SECTION_RPC_STARTUP"] command: %s") % strJson));
|
||||
|
||||
RPC_STARTUP.push_back(jvCommand);
|
||||
}
|
||||
}
|
||||
|
||||
if (sectionSingleB(secConfig, SECTION_DATABASE_PATH, DATABASE_PATH))
|
||||
DATA_DIR = DATABASE_PATH;
|
||||
|
||||
|
||||
@@ -1,13 +1,15 @@
|
||||
#ifndef __CONFIG__
|
||||
#define __CONFIG__
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
|
||||
#include "types.h"
|
||||
#include "RippleAddress.h"
|
||||
#include "ParseSection.h"
|
||||
#include "SerializedTypes.h"
|
||||
|
||||
#include <string>
|
||||
#include <boost/filesystem.hpp>
|
||||
#include "../json/value.h"
|
||||
|
||||
#define ENABLE_INSECURE 0 // 1, to enable unnecessary features.
|
||||
|
||||
@@ -26,6 +28,9 @@
|
||||
#define DEFAULT_VALIDATORS_SITE ""
|
||||
#define VALIDATORS_FILE_NAME "validators.txt"
|
||||
|
||||
const int DOMAIN_BYTES_MAX = 256;
|
||||
const int PUBLIC_BYTES_MAX = 2048; // Maximum bytes for an account public key.
|
||||
|
||||
const int SYSTEM_PEER_PORT = 6561;
|
||||
const int SYSTEM_WEBSOCKET_PORT = 6562;
|
||||
const int SYSTEM_WEBSOCKET_PUBLIC_PORT = 6563; // XXX Going away.
|
||||
@@ -110,6 +115,7 @@ public:
|
||||
std::string RPC_USER;
|
||||
std::string RPC_PASSWORD;
|
||||
bool RPC_ALLOW_REMOTE;
|
||||
std::vector<Json::Value> RPC_STARTUP;
|
||||
|
||||
// Validation
|
||||
RippleAddress VALIDATION_SEED, VALIDATION_PUB, VALIDATION_PRIV;
|
||||
|
||||
@@ -21,6 +21,7 @@ Json::Value rpcError(int iError, Json::Value jvResult)
|
||||
{ rpcBAD_BLOB, "badBlob", "Blob must be a non-empty hex string." },
|
||||
{ rpcBAD_SEED, "badSeed", "Disallowed seed." },
|
||||
{ rpcBAD_SYNTAX, "badSyntax", "Syntax error." },
|
||||
{ rpcCOMMAND_MISSING, "commandMissing", "Missing command entry." },
|
||||
{ rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed." },
|
||||
{ rpcDST_ACT_MISSING, "dstActMissing", "Destination account does not exists." },
|
||||
{ rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency/issuer is malformed." },
|
||||
|
||||
@@ -45,6 +45,7 @@ enum {
|
||||
rpcQUALITY_MALFORMED,
|
||||
rpcBAD_BLOB,
|
||||
rpcBAD_SEED,
|
||||
rpcCOMMAND_MISSING,
|
||||
rpcDST_ACT_MALFORMED,
|
||||
rpcDST_ACT_MISSING,
|
||||
rpcDST_AMT_MALFORMED,
|
||||
|
||||
@@ -2374,12 +2374,12 @@ Json::Value RPCHandler::doSubscribe(Json::Value jvRequest)
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["error"] = str(boost::format("Unknown stream: %s") % streamName);
|
||||
jvResult["error"] = "unknownStream";
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
jvResult["error"] = "malformedSteam";
|
||||
jvResult["error"] = "malformedStream";
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2553,10 +2553,10 @@ Json::Value RPCHandler::doInternal(Json::Value jvRequest)
|
||||
return RPCInternalHandler::runHandler(jvRequest["internal_command"].asString(), jvRequest["params"]);
|
||||
}
|
||||
|
||||
Json::Value RPCHandler::doCommand(Json::Value& jvRequest, int iRole)
|
||||
Json::Value RPCHandler::doCommand(const Json::Value& jvRequest, int iRole)
|
||||
{
|
||||
if (!jvRequest.isMember("command"))
|
||||
return rpcError(rpcINVALID_PARAMS);
|
||||
return rpcError(rpcCOMMAND_MISSING);
|
||||
|
||||
std::string strCommand = jvRequest["command"].asString();
|
||||
|
||||
|
||||
@@ -115,7 +115,7 @@ public:
|
||||
RPCHandler(NetworkOPs* netOps);
|
||||
RPCHandler(NetworkOPs* netOps, InfoSub* infoSub);
|
||||
|
||||
Json::Value doCommand(Json::Value& jvRequest, int role);
|
||||
Json::Value doCommand(const Json::Value& jvRequest, int role);
|
||||
Json::Value doRpcCommand(const std::string& strCommand, Json::Value& jvParams, int iRole);
|
||||
};
|
||||
|
||||
|
||||
@@ -35,7 +35,9 @@ bool transResultInfo(TER terCode, std::string& strToken, std::string& strHuman)
|
||||
{ tefPAST_SEQ, "tefPAST_SEQ", "This sequence number has already past." },
|
||||
|
||||
{ telLOCAL_ERROR, "telLOCAL_ERROR", "Local failure." },
|
||||
{ telBAD_DOMAIN, "telBAD_DOMAIN", "Domain too long." },
|
||||
{ telBAD_PATH_COUNT, "telBAD_PATH_COUNT", "Malformed: Too many paths." },
|
||||
{ telBAD_PUBLIC_KEY, "telBAD_PUBLIC_KEY", "Public key too long." },
|
||||
{ telINSUF_FEE_P, "telINSUF_FEE_P", "Fee insufficient." },
|
||||
|
||||
{ temMALFORMED, "temMALFORMED", "Malformed transaction." },
|
||||
|
||||
@@ -13,7 +13,9 @@ enum TER // aka TransactionEngineResult
|
||||
// - Not forwarded
|
||||
// - No fee check
|
||||
telLOCAL_ERROR = -399,
|
||||
telBAD_DOMAIN,
|
||||
telBAD_PATH_COUNT,
|
||||
telBAD_PUBLIC_KEY,
|
||||
telINSUF_FEE_P,
|
||||
|
||||
// -299 .. -200: M Malformed (bad signature)
|
||||
|
||||
@@ -9,8 +9,9 @@
|
||||
#include "Application.h"
|
||||
#include "CallRPC.h"
|
||||
#include "Config.h"
|
||||
#include "utils.h"
|
||||
#include "Log.h"
|
||||
#include "RPCHandler.h"
|
||||
#include "utils.h"
|
||||
|
||||
namespace po = boost::program_options;
|
||||
|
||||
@@ -26,6 +27,21 @@ void setupServer()
|
||||
|
||||
void startServer()
|
||||
{
|
||||
//
|
||||
// Execute start up rpc commands.
|
||||
//
|
||||
BOOST_FOREACH(const Json::Value& jvCommand, theConfig.RPC_STARTUP)
|
||||
{
|
||||
if (!theConfig.QUIET)
|
||||
cerr << "Startup RPC: " << jvCommand << endl;
|
||||
|
||||
RPCHandler rhHandler(&theApp->getOPs());
|
||||
|
||||
std::cerr << "Result: "
|
||||
<< rhHandler.doCommand(jvCommand, RPCHandler::ADMIN)
|
||||
<< std::endl;
|
||||
}
|
||||
|
||||
theApp->run(); // Blocks till we get a stop RPC.
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user