Started fixing compilation errors.

This commit is contained in:
Jianping Wu 2018-10-20 11:51:22 -07:00
parent fb0acfc6d9
commit ec2f335382
9 changed files with 28 additions and 12 deletions

View File

@ -10,6 +10,8 @@
#include <script/keva.h> #include <script/keva.h>
typedef std::vector<unsigned char> valtype;
bool fNameHistory = false; bool fNameHistory = false;
/* ************************************************************************** */ /* ************************************************************************** */

View File

@ -21,6 +21,8 @@
class CKevaScript; class CKevaScript;
class CDBBatch; class CDBBatch;
typedef std::vector<unsigned char> valtype;
/** Whether or not name history is enabled. */ /** Whether or not name history is enabled. */
extern bool fNameHistory; extern bool fNameHistory;

View File

@ -28,6 +28,8 @@ class CTxMemPool;
class CTxMemPoolEntry; class CTxMemPoolEntry;
class CValidationState; class CValidationState;
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;

View File

@ -72,11 +72,11 @@ CKevaScript::buildKevaPut(const CScript& addr, const valtype& nameSpace,
return prefix + addr; return prefix + addr;
} }
CScript CKevaScript::buildKevaNamespace(const CScript& addr, const valtype& nameSpace, CScript CKevaScript::buildKevaNamespace(const CScript& addr, const uint160& nameSpace,
const valtype& displayName) const valtype& displayName)
{ {
CScript prefix; CScript prefix;
prefix << OP_KEVA_NAMESPACE << nameSpace << displayName << OP_2DROP; prefix << OP_KEVA_NAMESPACE << ToByteVector(nameSpace) << displayName << OP_2DROP;
return prefix + addr; return prefix + addr;
} }

View File

@ -7,6 +7,8 @@
#include <script/script.h> #include <script/script.h>
typedef std::vector<unsigned char> valtype;
class uint160; class uint160;
/** /**
@ -191,7 +193,7 @@ public:
* @param hash The hash to use. * @param hash The hash to use.
* @return The full KEVA_NAMESPACE script. * @return The full KEVA_NAMESPACE script.
*/ */
static CScript buildKevaNamespace(const CScript& addr, const valtype& nameSpace, static CScript buildKevaNamespace(const CScript& addr, const uint160& nameSpace,
const valtype& displayName); const valtype& displayName);
/** /**

View File

@ -63,16 +63,22 @@ keva_namespace (const JSONRPCRequest& request)
CReserveKey keyName(pwallet); CReserveKey keyName(pwallet);
CPubKey pubKey; CPubKey pubKey;
const bool ok = keyName.GetReservedKey (pubKey, true); const bool ok = keyName.GetReservedKey(pubKey, true);
assert (ok); assert (ok);
const CScript addrName = GetScriptForDestination(pubKey.GetID());
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, namespaceHash, displayName);
//const uint160 hash = Hash160(toHash); CKeyID keyId = pubKey.GetID()
// The namespace is: Hash160(Hash160(keyId) || displayName)
valtype toHash = ToByteVector(Hash160(ToByteVector(keyId)));
toHash.insert(toHash.end(), displayName.begin(), displayName.end());
const uint160 namespaceHash = Hash160(toHash);
const CScript addrName = GetScriptForDestination(keyId);
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, namespaceHash, displayName);
CCoinControl coinControl; CCoinControl coinControl;
CWalletTx wtx; CWalletTx wtx;
SendMoneyToScript (pwallet, newScript, nullptr, SendMoneyToScript(pwallet, newScript, nullptr,
NAME_LOCKED_AMOUNT, false, wtx, coinControl); NAME_LOCKED_AMOUNT, false, wtx, coinControl);
keyName.KeepKey(); keyName.KeepKey();

View File

@ -428,7 +428,7 @@ static void SendMoney(CWallet * const pwallet, const CTxDestination &address, CA
int nChangePosRet = -1; int nChangePosRet = -1;
CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount}; CRecipient recipient = {scriptPubKey, nValue, fSubtractFeeFromAmount};
vecSend.push_back(recipient); vecSend.push_back(recipient);
if (!pwallet->CreateTransaction(vecSend, wtxNew, reservekey, nFeeRequired, nChangePosRet, strError, coin_control)) { if (!pwallet->CreateTransaction(vecSend, nullptr, wtxNew, reservekey, nFeeRequired, nChangePosRet, strError, coin_control)) {
if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance) if (!fSubtractFeeFromAmount && nValue + nFeeRequired > curBalance)
strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired)); strError = strprintf("Error: This transaction requires a transaction fee of at least %s", FormatMoney(nFeeRequired));
throw JSONRPCError(RPC_WALLET_ERROR, strError); throw JSONRPCError(RPC_WALLET_ERROR, strError);
@ -1200,7 +1200,7 @@ UniValue sendmany(const JSONRPCRequest& request)
CAmount nFeeRequired = 0; CAmount nFeeRequired = 0;
int nChangePosRet = -1; int nChangePosRet = -1;
std::string strFailReason; std::string strFailReason;
bool fCreated = pwallet->CreateTransaction(vecSend, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason, coin_control); bool fCreated = pwallet->CreateTransaction(vecSend, nullptr, wtx, keyChange, nFeeRequired, nChangePosRet, strFailReason, coin_control);
if (!fCreated) if (!fCreated)
throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason); throw JSONRPCError(RPC_WALLET_INSUFFICIENT_FUNDS, strFailReason);
CValidationState state; CValidationState state;
@ -3643,7 +3643,7 @@ static const CRPCCommand commands[] =
{ "generating", "generate", &generate, {"nblocks","maxtries"} }, { "generating", "generate", &generate, {"nblocks","maxtries"} },
// Kevacoin-specific wallet calls. // Kevacoin-specific wallet calls.
{ "kevacoin", "keva_namespace", &keva_namespace, {"namespace", "key", "value", "create_namespace"} } { "kevacoin", "keva_namespace", &keva_namespace, {"namespace", "key", "value", "create_namespace"} },
{ "kevacoin", "keva_put", &keva_put, {"namespace", "key", "value", "put_value"} } { "kevacoin", "keva_put", &keva_put, {"namespace", "key", "value", "put_value"} }
}; };

View File

@ -7,8 +7,10 @@
#include <string> #include <string>
class CCoinControl;
class CRPCTable; class CRPCTable;
class CWallet; class CWallet;
class CWalletTx;
class JSONRPCRequest; class JSONRPCRequest;
void RegisterWalletRPCCommands(CRPCTable &t); void RegisterWalletRPCCommands(CRPCTable &t);

View File

@ -2603,7 +2603,7 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
CReserveKey reservekey(this); CReserveKey reservekey(this);
CWalletTx wtx; CWalletTx wtx;
if (!CreateTransaction(vecSend, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false)) { if (!CreateTransaction(vecSend, nullptr, wtx, reservekey, nFeeRet, nChangePosInOut, strFailReason, coinControl, false)) {
return false; return false;
} }