mirror of
https://github.com/XRPLF/rippled.git
synced 2025-12-06 17:27:55 +00:00
Allow qualities to be specified as a float for RPC.
This commit is contained in:
@@ -44,8 +44,8 @@ Json::Value RPCServer::RPCError(int iError)
|
|||||||
{ rpcACT_NOT_FOUND, "actNotFound", "Account not found." },
|
{ rpcACT_NOT_FOUND, "actNotFound", "Account not found." },
|
||||||
{ rpcBAD_SEED, "badSeed", "Disallowed seed." },
|
{ rpcBAD_SEED, "badSeed", "Disallowed seed." },
|
||||||
{ rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed." },
|
{ rpcDST_ACT_MALFORMED, "dstActMalformed", "Destination account is malformed." },
|
||||||
{ rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency is malformed." },
|
|
||||||
{ rpcDST_ACT_MISSING, "dstActMissing", "Destination account does not exists." },
|
{ rpcDST_ACT_MISSING, "dstActMissing", "Destination account does not exists." },
|
||||||
|
{ rpcDST_AMT_MALFORMED, "dstAmtMalformed", "Destination amount/currency is malformed." },
|
||||||
{ rpcFAIL_GEN_DECRPYT, "failGenDecrypt", "Failed to decrypt generator." },
|
{ rpcFAIL_GEN_DECRPYT, "failGenDecrypt", "Failed to decrypt generator." },
|
||||||
{ rpcGETS_ACT_MALFORMED, "getsActMalformed", "Gets account malformed." },
|
{ rpcGETS_ACT_MALFORMED, "getsActMalformed", "Gets account malformed." },
|
||||||
{ rpcGETS_AMT_MALFORMED, "getsAmtMalformed", "Gets ammount malformed." },
|
{ rpcGETS_AMT_MALFORMED, "getsAmtMalformed", "Gets ammount malformed." },
|
||||||
@@ -71,6 +71,7 @@ Json::Value RPCServer::RPCError(int iError)
|
|||||||
{ rpcPAYS_AMT_MALFORMED, "paysAmtMalformed", "Pays amount malformed." },
|
{ rpcPAYS_AMT_MALFORMED, "paysAmtMalformed", "Pays amount malformed." },
|
||||||
{ rpcPORT_MALFORMED, "portMalformed", "Port is malformed." },
|
{ rpcPORT_MALFORMED, "portMalformed", "Port is malformed." },
|
||||||
{ rpcPUBLIC_MALFORMED, "publicMalformed", "Public key is malformed." },
|
{ rpcPUBLIC_MALFORMED, "publicMalformed", "Public key is malformed." },
|
||||||
|
{ rpcQUALITY_MALFORMED, "qualityMalformed", "Quality malformed." },
|
||||||
{ rpcSRC_ACT_MALFORMED, "srcActMalformed", "Source account is malformed." },
|
{ rpcSRC_ACT_MALFORMED, "srcActMalformed", "Source account is malformed." },
|
||||||
{ rpcSRC_ACT_MISSING, "srcActMissing", "Source account does not exist." },
|
{ rpcSRC_ACT_MISSING, "srcActMissing", "Source account does not exist." },
|
||||||
{ rpcSRC_AMT_MALFORMED, "srcAmtMalformed", "Source amount/currency is malformed." },
|
{ rpcSRC_AMT_MALFORMED, "srcAmtMalformed", "Source amount/currency is malformed." },
|
||||||
@@ -1573,8 +1574,8 @@ Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
|||||||
bool bLimitAmount = true;
|
bool bLimitAmount = true;
|
||||||
bool bQualityIn = params.size() >= 6;
|
bool bQualityIn = params.size() >= 6;
|
||||||
bool bQualityOut = params.size() >= 7;
|
bool bQualityOut = params.size() >= 7;
|
||||||
uint32 uQualityIn = bQualityIn ? lexical_cast_s<uint32>(params[5u].asString()) : 0;
|
uint32 uQualityIn = 0;
|
||||||
uint32 uQualityOut = bQualityOut ? lexical_cast_s<uint32>(params[6u].asString()) : 0;
|
uint32 uQualityOut = 0;
|
||||||
|
|
||||||
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
if (!naSeed.setSeedGeneric(params[0u].asString()))
|
||||||
{
|
{
|
||||||
@@ -1592,6 +1593,14 @@ Json::Value RPCServer::doRippleLineSet(const Json::Value& params)
|
|||||||
{
|
{
|
||||||
return RPCError(rpcSRC_AMT_MALFORMED);
|
return RPCError(rpcSRC_AMT_MALFORMED);
|
||||||
}
|
}
|
||||||
|
else if (bQualityIn && !parseQuality(params[5u].asString(), uQualityIn))
|
||||||
|
{
|
||||||
|
return RPCError(rpcQUALITY_MALFORMED);
|
||||||
|
}
|
||||||
|
else if (bQualityOut && !parseQuality(params[6u].asString(), uQualityOut))
|
||||||
|
{
|
||||||
|
return RPCError(rpcQUALITY_MALFORMED);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
NewcoinAddress naMasterGenerator;
|
NewcoinAddress naMasterGenerator;
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ public:
|
|||||||
|
|
||||||
// Bad parameter
|
// Bad parameter
|
||||||
rpcACT_MALFORMED,
|
rpcACT_MALFORMED,
|
||||||
|
rpcQUALITY_MALFORMED,
|
||||||
rpcBAD_SEED,
|
rpcBAD_SEED,
|
||||||
rpcDST_ACT_MALFORMED,
|
rpcDST_ACT_MALFORMED,
|
||||||
rpcDST_ACT_MISSING,
|
rpcDST_ACT_MISSING,
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ enum PathFlags
|
|||||||
PF_ISSUE = 0x80,
|
PF_ISSUE = 0x80,
|
||||||
};
|
};
|
||||||
|
|
||||||
#define QUALITY_ONE 1000000000 // 10e9
|
|
||||||
#define CURRENCY_XNS uint160(0)
|
#define CURRENCY_XNS uint160(0)
|
||||||
#define CURRENCY_ONE uint160(1) // Used as a place holder
|
#define CURRENCY_ONE uint160(1) // Used as a place holder
|
||||||
#define ACCOUNT_XNS uint160(0)
|
#define ACCOUNT_XNS uint160(0)
|
||||||
|
|||||||
@@ -156,6 +156,25 @@ bool parseIpPort(const std::string& strSource, std::string& strIP, int& iPort)
|
|||||||
return bValid;
|
return bValid;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// Quality parsing
|
||||||
|
// - integers as is.
|
||||||
|
// - floats multiplied by a billion
|
||||||
|
bool parseQuality(const std::string& strSource, uint32& uQuality)
|
||||||
|
{
|
||||||
|
uQuality = lexical_cast_s<uint32>(strSource);
|
||||||
|
|
||||||
|
if (!uQuality)
|
||||||
|
{
|
||||||
|
float fQuality = lexical_cast_s<float>(strSource);
|
||||||
|
|
||||||
|
if (fQuality)
|
||||||
|
uQuality = QUALITY_ONE*fQuality;
|
||||||
|
}
|
||||||
|
|
||||||
|
return !!uQuality;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
void intIPtoStr(int ip,std::string& retStr)
|
void intIPtoStr(int ip,std::string& retStr)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -8,6 +8,8 @@
|
|||||||
|
|
||||||
#include "types.h"
|
#include "types.h"
|
||||||
|
|
||||||
|
#define QUALITY_ONE 1000000000 // 10e9
|
||||||
|
|
||||||
#define nothing() do {} while (0)
|
#define nothing() do {} while (0)
|
||||||
#define fallthru() do {} while (0)
|
#define fallthru() do {} while (0)
|
||||||
#define NUMBER(x) (sizeof(x)/sizeof((x)[0]))
|
#define NUMBER(x) (sizeof(x)/sizeof((x)[0]))
|
||||||
@@ -153,6 +155,7 @@ std::vector<unsigned char> strCopy(const std::string& strSrc);
|
|||||||
std::string strCopy(const std::vector<unsigned char>& vucSrc);
|
std::string strCopy(const std::vector<unsigned char>& vucSrc);
|
||||||
|
|
||||||
bool parseIpPort(const std::string& strSource, std::string& strIP, int& iPort);
|
bool parseIpPort(const std::string& strSource, std::string& strIP, int& iPort);
|
||||||
|
bool parseQuality(const std::string& strSource, uint32& uQuality);
|
||||||
|
|
||||||
DH* DH_der_load(const std::string& strDer);
|
DH* DH_der_load(const std::string& strDer);
|
||||||
std::string DH_der_gen(int iKeyLength);
|
std::string DH_der_gen(int iKeyLength);
|
||||||
|
|||||||
Reference in New Issue
Block a user