Browse Source

Base64 encode namespace.

0.16.3-insta
Jianping Wu 6 years ago
parent
commit
4dd5594881
  1. 4
      src/script/keva.cpp
  2. 2
      src/script/keva.h
  3. 9
      src/wallet/rpckeva.cpp

4
src/script/keva.cpp

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

2
src/script/keva.h

@ -222,7 +222,7 @@ public: @@ -222,7 +222,7 @@ public:
* @param hash The hash to use.
* @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);
/**

9
src/wallet/rpckeva.cpp

@ -72,10 +72,11 @@ UniValue keva_namespace(const JSONRPCRequest& request) @@ -72,10 +72,11 @@ UniValue keva_namespace(const JSONRPCRequest& request)
// The namespace name 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 uint160 namespaceHashVal = Hash160(toHash);
const std::string namespaceHash = EncodeBase64(namespaceHashVal.begin(), namespaceHashVal.size());
const CScript addrName = GetScriptForDestination(keyId);
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, namespaceHash, displayName);
const CScript newScript = CKevaScript::buildKevaNamespace(addrName, ValtypeFromString(namespaceHash), displayName);
CCoinControl coinControl;
CWalletTx wtx;
@ -86,11 +87,11 @@ UniValue keva_namespace(const JSONRPCRequest& request) @@ -86,11 +87,11 @@ UniValue keva_namespace(const JSONRPCRequest& request)
const std::string txid = wtx.GetHash().GetHex();
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);
res.push_back(txid);
res.push_back(namespaceHash.ToString());
res.push_back(namespaceHash);
return res;
}

Loading…
Cancel
Save