Browse Source

Used DecodeBase58Check to match EncodeBase58Check.

Max value length is MAX_SCRIPT_ELEMENT_SIZE.
cn
Jianping Wu 6 years ago
parent
commit
f947286c8b
  1. 3
      src/keva/main.h
  2. 6
      src/wallet/rpckeva.cpp

3
src/keva/main.h

@ -10,6 +10,7 @@ @@ -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; @@ -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;

6
src/wallet/rpckeva.cpp

@ -226,7 +226,7 @@ UniValue keva_put(const JSONRPCRequest& request) @@ -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) @@ -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) @@ -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");
}
}

Loading…
Cancel
Save