Browse Source

N or M for namespace.

TODO: make sure it is N only!
cn
Jianping Wu 6 years ago
parent
commit
66f3985021
  1. 2
      src/script/keva.cpp
  2. 11
      src/wallet/rpckeva.cpp
  3. 2
      src/wallet/wallet.cpp

2
src/script/keva.cpp

@ -8,7 +8,7 @@
const std::string CKevaScript::KEVA_DISPLAY_NAME_KEY = "_KEVA_NS_"; const std::string CKevaScript::KEVA_DISPLAY_NAME_KEY = "_KEVA_NS_";
const unsigned char CKevaScript::NAMESPACE_PREFIX = 21; // 2 in base58 const unsigned char CKevaScript::NAMESPACE_PREFIX = 52; // M in Base58Check
CKevaScript::CKevaScript (const CScript& script) CKevaScript::CKevaScript (const CScript& script)
: op(OP_NOP), address(script) : op(OP_NOP), address(script)

11
src/wallet/rpckeva.cpp

@ -90,7 +90,7 @@ UniValue keva_namespace(const JSONRPCRequest& request)
KEVA_LOCKED_AMOUNT, false, wtx, coinControl); KEVA_LOCKED_AMOUNT, false, wtx, coinControl);
keyName.KeepKey(); keyName.KeepKey();
std::string kevaNamespaceBase58 = EncodeBase58(kevaNamespace); std::string kevaNamespaceBase58 = EncodeBase58Check(kevaNamespace);
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",
kevaNamespaceBase58.c_str(), displayNameStr.c_str(), txid.c_str()); kevaNamespaceBase58.c_str(), displayNameStr.c_str(), txid.c_str());
@ -98,7 +98,6 @@ UniValue keva_namespace(const JSONRPCRequest& request)
UniValue res(UniValue::VARR); UniValue res(UniValue::VARR);
res.push_back(txid); res.push_back(txid);
res.push_back(kevaNamespaceBase58); res.push_back(kevaNamespaceBase58);
return res; return res;
} }
@ -161,7 +160,7 @@ UniValue keva_list_namespaces(const JSONRPCRequest& request)
} }
const valtype nameSpace = kevaOp.getOpNamespace(); const valtype nameSpace = kevaOp.getOpNamespace();
const std::string nameSpaceStr = EncodeBase58(nameSpace); const std::string nameSpaceStr = EncodeBase58Check(nameSpace);
const CBlockIndex* pindex; const CBlockIndex* pindex;
const int depth = tx.GetDepthInMainChain(pindex); const int depth = tx.GetDepthInMainChain(pindex);
if (depth <= 0) { if (depth <= 0) {
@ -188,7 +187,7 @@ UniValue keva_list_namespaces(const JSONRPCRequest& request)
std::vector<std::tuple<valtype, valtype, uint256>> unconfirmedNamespaces; std::vector<std::tuple<valtype, valtype, uint256>> unconfirmedNamespaces;
mempool.getUnconfirmedNamespaceList(unconfirmedNamespaces); mempool.getUnconfirmedNamespaceList(unconfirmedNamespaces);
for (auto entry : unconfirmedNamespaces) { for (auto entry : unconfirmedNamespaces) {
res.push_back(EncodeBase58(std::get<0>(entry)) + " : " + ValtypeToString(std::get<1>(entry))); res.push_back(EncodeBase58Check(std::get<0>(entry)) + " : " + ValtypeToString(std::get<1>(entry)));
} }
} }
@ -393,7 +392,7 @@ UniValue keva_pending(const JSONRPCRequest& request)
for (auto entry: unconfirmedNamespaces) { for (auto entry: unconfirmedNamespaces) {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.pushKV("op", opKevaNamepsace); obj.pushKV("op", opKevaNamepsace);
obj.pushKV("namespace", EncodeBase58(std::get<0>(entry))); obj.pushKV("namespace", EncodeBase58Check(std::get<0>(entry)));
obj.pushKV("display name", ValtypeToString(std::get<1>(entry))); obj.pushKV("display name", ValtypeToString(std::get<1>(entry)));
obj.pushKV("txid", std::get<2>(entry).ToString()); obj.pushKV("txid", std::get<2>(entry).ToString());
arr.push_back(obj); arr.push_back(obj);
@ -402,7 +401,7 @@ UniValue keva_pending(const JSONRPCRequest& request)
for (auto entry: unconfirmedKeyValueList) { for (auto entry: unconfirmedKeyValueList) {
UniValue obj(UniValue::VOBJ); UniValue obj(UniValue::VOBJ);
obj.pushKV("op", opKevaPut); obj.pushKV("op", opKevaPut);
obj.pushKV("namespace", EncodeBase58(std::get<0>(entry))); obj.pushKV("namespace", EncodeBase58Check(std::get<0>(entry)));
obj.pushKV("key", ValtypeToString(std::get<1>(entry))); obj.pushKV("key", ValtypeToString(std::get<1>(entry)));
obj.pushKV("value", ValtypeToString(std::get<2>(entry))); obj.pushKV("value", ValtypeToString(std::get<2>(entry)));
obj.pushKV("txid", std::get<3>(entry).ToString()); obj.pushKV("txid", std::get<3>(entry).ToString());

2
src/wallet/wallet.cpp

@ -2277,7 +2277,7 @@ void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const
CKevaScript kevaOp(pcoin->tx->vout[i].scriptPubKey); CKevaScript kevaOp(pcoin->tx->vout[i].scriptPubKey);
if (kevaOp.isKevaOp()) { if (kevaOp.isKevaOp()) {
if (kevaNamespace) { if (kevaNamespace) {
if (*kevaNamespace == EncodeBase58(kevaOp.getOpNamespace())) { if (*kevaNamespace == EncodeBase58Check(kevaOp.getOpNamespace())) {
vCoins.push_back(COutput(pcoin, i, nDepth, fSpendableIn, fSolvableIn, safeTx)); vCoins.push_back(COutput(pcoin, i, nDepth, fSpendableIn, fSolvableIn, safeTx));
return; return;
} }

Loading…
Cancel
Save