diff --git a/src/kernelrecord.cpp b/src/kernelrecord.cpp index 6fbb44fe..78ce1f5d 100644 --- a/src/kernelrecord.cpp +++ b/src/kernelrecord.cpp @@ -15,11 +15,6 @@ bool KernelRecord::showTransaction(const CWalletTx &wtx) } } - if(!wtx.IsConfirmed()) - { - return false; - } - return true; } @@ -56,7 +51,7 @@ vector KernelRecord::decomposeOutput(const CWallet *wallet, const addrStr = mapValue["to"]; } - parts.push_back(KernelRecord(hash, nTime, addrStr, txOut.nValue, wtx.IsSpent(nOut), coinAge)); + parts.push_back(KernelRecord(hash, nTime, addrStr, txOut.nValue, nOut, wtx.IsSpent(nOut), coinAge)); } } } diff --git a/src/kernelrecord.h b/src/kernelrecord.h index d54e5510..98721c83 100644 --- a/src/kernelrecord.h +++ b/src/kernelrecord.h @@ -21,9 +21,9 @@ class KernelRecord KernelRecord(uint256 hash, int64 nTime, const std::string &address, - int64 nValue, bool spent, int64 coinAge): + int64 nValue, int idx, bool spent, int64 coinAge): hash(hash), nTime(nTime), address(address), nValue(nValue), - idx(0), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0) + idx(idx), spent(spent), coinAge(coinAge), prevMinutes(0), prevDifficulty(0), prevProbability(0) { } diff --git a/src/qt/mintingtablemodel.cpp b/src/qt/mintingtablemodel.cpp index 5da17b27..5df15a72 100644 --- a/src/qt/mintingtablemodel.cpp +++ b/src/qt/mintingtablemodel.cpp @@ -133,16 +133,16 @@ class MintingTablePriv KernelRecord::decomposeOutput(wallet, mi->second); if(!toInsert.empty()) /* only if something to insert */ { - parent->beginInsertRows(QModelIndex(), lowerIndex, lowerIndex+toInsert.size()-1); int insert_idx = lowerIndex; BOOST_FOREACH(const KernelRecord &rec, toInsert) { if(!rec.spent) { + parent->beginInsertRows(QModelIndex(), insert_idx, insert_idx); cachedWallet.insert(insert_idx, rec); insert_idx += 1; + parent->endInsertRows(); } } - parent->endInsertRows(); } } else if(!inWallet && inModel) @@ -156,21 +156,24 @@ class MintingTablePriv { // Updated -- remove spent coins from table std::vector toCheck = KernelRecord::decomposeOutput(wallet, mi->second); - BOOST_FOREACH(const KernelRecord &rec, toCheck) + if(!toCheck.empty()) { - if(rec.spent) + BOOST_FOREACH(const KernelRecord &rec, toCheck) { - for(int i = 0; i < cachedWallet.size(); i++) + if(rec.spent) { - KernelRecord cachedRec = cachedWallet.at(i); - if((rec.hash == cachedRec.hash) - && (rec.nTime == cachedRec.nTime) - && (rec.nValue == cachedRec.nValue)) + for(int i = lowerIndex; i < upperIndex; i++) { - parent->beginRemoveRows(QModelIndex(), i, i); - cachedWallet.removeAt(i); - parent->endRemoveRows(); - break; + KernelRecord cachedRec = cachedWallet.at(i); + if((rec.address == cachedRec.address) + && (rec.nValue == cachedRec.nValue) + && (rec.idx == cachedRec.idx)) + { + parent->beginRemoveRows(QModelIndex(), i, i); + cachedWallet.removeAt(i); + parent->endRemoveRows(); + break; + } } } } @@ -246,16 +249,6 @@ void MintingTableModel::update() BOOST_FOREACH(uint256 hash, wallet->vMintingWalletUpdated) { updated.append(hash); - - // Also check the inputs to remove spent outputs from the table if necessary - CWalletTx wtx; - if(wallet->GetTransaction(hash, wtx)) - { - BOOST_FOREACH(const CTxIn& txin, wtx.vin) - { - updated.append(txin.prevout.hash); - } - } } wallet->vMintingWalletUpdated.clear(); }