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 @@ -816,52 +816,38 @@ void WalletModel::getKevaEntries(std::vector<KevaEntry>& vKevaEntries, std::stri
void WalletModel::getNamespaceEntries(std::vector<NamespaceEntry>& vNamespaceEntries)
{
LOCK2(cs_main, wallet->cs_wallet);
std::map<std::string, std::string> 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<CTxDestination> destinations;
std::vector<COutput> 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);

Loading…
Cancel
Save