Browse Source

Used DecodeBase58Check to match EncodeBase58Check.

Max value length is MAX_SCRIPT_ELEMENT_SIZE.
0.16.3-insta
Jianping Wu 6 years ago
parent
commit
0f8e9b11db
  1. 3
      src/keva/main.h
  2. 6
      src/wallet/rpckeva.cpp

3
src/keva/main.h

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

6
src/wallet/rpckeva.cpp

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

Loading…
Cancel
Save