diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp index 4df36eacc..733f310a5 100644 --- a/src/qt/walletmodel.cpp +++ b/src/qt/walletmodel.cpp @@ -816,52 +816,38 @@ void WalletModel::getKevaEntries(std::vector& vKevaEntries, std::stri void WalletModel::getNamespaceEntries(std::vector& vNamespaceEntries) { - LOCK2(cs_main, wallet->cs_wallet); std::map mapObjects; - for (const auto& item : wallet->mapWallet) { - const CWalletTx& tx = item.second; - if (!tx.tx->IsKevacoin()) { - continue; - } - - CKevaScript kevaOp; - int nOut = -1; - for (unsigned i = 0; i < tx.tx->vout.size(); ++i) { - const CKevaScript cur(tx.tx->vout[i].scriptPubKey); - if (cur.isKevaOp()) { - if (nOut != -1) { - LogPrintf("ERROR: wallet contains tx with multiple name outputs"); - } else { - kevaOp = cur; - nOut = i; - } + { + LOCK2(cs_main, wallet->cs_wallet); + std::set destinations; + std::vector vecOutputs; + bool include_unsafe = true; + CAmount nMinimumAmount = 0; + CAmount nMaximumAmount = MAX_MONEY; + CAmount nMinimumSumAmount = MAX_MONEY; + uint64_t nMaximumCount = 0; + int nMinDepth = 1; + int nMaxDepth = 99999999; + wallet->AvailableCoins(vecOutputs, !include_unsafe, nullptr, nMinimumAmount, nMaximumAmount, nMinimumSumAmount, nMaximumCount, nMinDepth, nMaxDepth); + for (const COutput& out : vecOutputs) { + CTxDestination address; + const CScript& scriptPubKey = out.tx->tx->vout[out.i].scriptPubKey; + 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. LOCK (mempool.cs);