mirror of
https://github.com/kvazar-network/kevacoin.git
synced 2025-02-09 21:54:41 +00:00
Base64 encode namespace.
This commit is contained in:
parent
d341a86c09
commit
ff4cda4884
@ -76,11 +76,11 @@ CKevaScript::buildKevaPut(const CScript& addr, const valtype& nameSpace,
|
|||||||
return prefix + addr;
|
return prefix + addr;
|
||||||
}
|
}
|
||||||
|
|
||||||
CScript CKevaScript::buildKevaNamespace(const CScript& addr, const uint160& nameSpace,
|
CScript CKevaScript::buildKevaNamespace(const CScript& addr, const valtype& nameSpace,
|
||||||
const valtype& displayName)
|
const valtype& displayName)
|
||||||
{
|
{
|
||||||
CScript prefix;
|
CScript prefix;
|
||||||
prefix << OP_KEVA_NAMESPACE << ToByteVector(nameSpace) << displayName << OP_2DROP;
|
prefix << OP_KEVA_NAMESPACE << nameSpace << displayName << OP_2DROP;
|
||||||
|
|
||||||
return prefix + addr;
|
return prefix + addr;
|
||||||
}
|
}
|
||||||
|
@ -222,7 +222,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 uint160& nameSpace,
|
static CScript buildKevaNamespace(const CScript& addr, const valtype& nameSpace,
|
||||||
const valtype& displayName);
|
const valtype& displayName);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -72,10 +72,11 @@ UniValue keva_namespace(const JSONRPCRequest& request)
|
|||||||
// The namespace name is: Hash160(Hash160(keyId) || displayName)
|
// The namespace name is: Hash160(Hash160(keyId) || displayName)
|
||||||
valtype toHash = ToByteVector(Hash160(ToByteVector(keyId)));
|
valtype toHash = ToByteVector(Hash160(ToByteVector(keyId)));
|
||||||
toHash.insert(toHash.end(), displayName.begin(), displayName.end());
|
toHash.insert(toHash.end(), displayName.begin(), displayName.end());
|
||||||
const uint160 namespaceHash = Hash160(toHash);
|
const uint160 namespaceHashVal = Hash160(toHash);
|
||||||
|
const std::string namespaceHash = EncodeBase64(namespaceHashVal.begin(), namespaceHashVal.size());
|
||||||
|
|
||||||
const CScript addrName = GetScriptForDestination(keyId);
|
const CScript addrName = GetScriptForDestination(keyId);
|
||||||
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, namespaceHash, displayName);
|
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, ValtypeFromString(namespaceHash), displayName);
|
||||||
|
|
||||||
CCoinControl coinControl;
|
CCoinControl coinControl;
|
||||||
CWalletTx wtx;
|
CWalletTx wtx;
|
||||||
@ -86,11 +87,11 @@ UniValue keva_namespace(const JSONRPCRequest& request)
|
|||||||
|
|
||||||
const std::string txid = wtx.GetHash().GetHex();
|
const std::string txid = wtx.GetHash().GetHex();
|
||||||
LogPrintf("keva_namespace: namespace=%s, displayName=%s, tx=%s\n",
|
LogPrintf("keva_namespace: namespace=%s, displayName=%s, tx=%s\n",
|
||||||
namespaceHash.ToString().c_str(), displayNameStr.c_str(), txid.c_str());
|
namespaceHash.c_str(), displayNameStr.c_str(), txid.c_str());
|
||||||
|
|
||||||
UniValue res(UniValue::VARR);
|
UniValue res(UniValue::VARR);
|
||||||
res.push_back(txid);
|
res.push_back(txid);
|
||||||
res.push_back(namespaceHash.ToString());
|
res.push_back(namespaceHash);
|
||||||
|
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user