Browse Source

Fixed keva_list_namespaces in GUI.

issue_19
kevacoin 4 years ago
parent
commit
512e038939
  1. 70
      src/qt/walletmodel.cpp

70
src/qt/walletmodel.cpp

@ -816,52 +816,38 @@ void WalletModel::getKevaEntries(std::vector<KevaEntry>& vKevaEntries, std::stri
void WalletModel::getNamespaceEntries(std::vector<NamespaceEntry>& vNamespaceEntries) void WalletModel::getNamespaceEntries(std::vector<NamespaceEntry>& vNamespaceEntries)
{ {
LOCK2(cs_main, wallet->cs_wallet);
std::map<std::string, std::string> mapObjects; std::map<std::string, std::string> mapObjects;
for (const auto& item : wallet->mapWallet) { {
const CWalletTx& tx = item.second; LOCK2(cs_main, wallet->cs_wallet);
if (!tx.tx->IsKevacoin()) { std::set<CTxDestination> destinations;
continue; std::vector<COutput> vecOutputs;
} bool include_unsafe = true;
CAmount nMinimumAmount = 0;
CKevaScript kevaOp; CAmount nMaximumAmount = MAX_MONEY;
int nOut = -1; CAmount nMinimumSumAmount = MAX_MONEY;
for (unsigned i = 0; i < tx.tx->vout.size(); ++i) { uint64_t nMaximumCount = 0;
const CKevaScript cur(tx.tx->vout[i].scriptPubKey); int nMinDepth = 1;
if (cur.isKevaOp()) { int nMaxDepth = 99999999;
if (nOut != -1) { wallet->AvailableCoins(vecOutputs, !include_unsafe, nullptr, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth);
LogPrintf("ERROR: wallet contains tx with multiple name outputs"); for (const COutput& out : vecOutputs) {
} else { CTxDestination address;
kevaOp = cur; const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey;
nOut = i; const CKevaScript kevaOp(scriptPubKey);
} if (!kevaOp.isKevaOp()) {
continue;
}
if (!kevaOp.isNamespaceRegistration() && !kevaOp.isAnyUpdate()) {
continue;
}
const valtype nameSpace = kevaOp.getOpNamespace();
const std::string nameSpaceStr = EncodeBase58Check(nameSpace);
CKevaData data;
if (pcoinsTip->GetNamespace(nameSpace, data)) {
std::string displayName = ValtypeToString(data.getValue());
mapObjects[nameSpaceStr] = displayName;
} }
}
if (nOut == -1) {
continue;
}
if (!kevaOp.isNamespaceRegistration() && !kevaOp.isAnyUpdate()) {
continue;
}
const valtype nameSpace = kevaOp.getOpNamespace();
const std::string nameSpaceStr = EncodeBase58Check(nameSpace);
const CBlockIndex* pindex;
const int depth = tx.GetDepthInMainChain(pindex);
if (depth <= 0) {
continue;
}
const bool mine = IsMine(*wallet, kevaOp.getAddress());
CKevaData data;
if (mine && pcoinsTip->GetNamespace(nameSpace, data)) {
std::string displayName = ValtypeToString(data.getValue());
mapObjects[nameSpaceStr] = displayName;
} }
} }
{ {
// Also get the unconfirmed namespaces and list them at the beginning. // Also get the unconfirmed namespaces and list them at the beginning.
LOCK (mempool.cs); LOCK (mempool.cs);

Loading…
Cancel
Save