Used DecodeBase58Check to match EncodeBase58Check.

Max value length is MAX_SCRIPT_ELEMENT_SIZE.
This commit is contained in:
Jianping Wu 2018-11-21 16:36:29 -08:00
parent e30e56ef11
commit f947286c8b
2 changed files with 5 additions and 4 deletions

View File

@ -10,6 +10,7 @@
#define H_BITCOIN_KEVA_MAIN
#include <amount.h>
#include <script/script.h>
#include <keva/common.h>
#include <primitives/transaction.h>
#include <serialize.h>
@ -33,7 +34,7 @@ typedef std::vector<unsigned char> valtype;
/* Some constants defining namespace, key and value limits. */
static const unsigned MAX_NAMESPACE_LENGTH = 255;
static const unsigned MAX_KEY_LENGTH = 255;
static const unsigned MAX_VALUE_LENGTH = 1023;
static const unsigned MAX_VALUE_LENGTH = MAX_SCRIPT_ELEMENT_SIZE; // As defined in script.h
/** The amount of coins to lock in created transactions. */
static const CAmount KEVA_LOCKED_AMOUNT = COIN / 100;

View File

@ -226,7 +226,7 @@ UniValue keva_put(const JSONRPCRequest& request)
const std::string namespaceStr = request.params[0].get_str();
valtype nameSpace;
if (!DecodeBase58(namespaceStr, nameSpace)) {
if (!DecodeBase58Check(namespaceStr, nameSpace)) {
throw JSONRPCError (RPC_INVALID_PARAMETER, "failed to decode namespace");
}
if (nameSpace.size () > MAX_NAMESPACE_LENGTH)
@ -307,7 +307,7 @@ UniValue keva_get(const JSONRPCRequest& request)
const std::string namespaceStr = request.params[0].get_str ();
valtype nameSpace;
if (!DecodeBase58(namespaceStr, nameSpace)) {
if (!DecodeBase58Check(namespaceStr, nameSpace)) {
throw JSONRPCError (RPC_INVALID_PARAMETER, "failed to decode namespace");
}
if (nameSpace.size () > MAX_NAMESPACE_LENGTH)
@ -372,7 +372,7 @@ UniValue keva_pending(const JSONRPCRequest& request)
if (request.params.size() == 1) {
RPCTypeCheckArgument(request.params[0], UniValue::VSTR);
namespaceStr = request.params[0].get_str();
if (!DecodeBase58(namespaceStr, nameSpace)) {
if (!DecodeBase58Check(namespaceStr, nameSpace)) {
throw JSONRPCError (RPC_INVALID_PARAMETER, "failed to decode namespace");
}
}