X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fwallet.cpp;h=a78a76b0c16aeea8bc670811c4a17ed8325bf2ff;hb=a51b421f76da8bfb88dedd159789eec0063d3087;hp=08d269d30e939f5220b10245b803a473c31579db;hpb=3172f77ecb720d462a2fa6b5e78f8460ce2c9cfe;p=novacoin.git diff --git a/src/wallet.cpp b/src/wallet.cpp index 08d269d..a78a76b 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -393,6 +393,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock) wtx.MarkSpent(txin.prevout.n); wtx.WriteToDisk(); NotifyTransactionChanged(this, txin.prevout.hash, CT_UPDATED); + vMintingWalletUpdated.push_back(txin.prevout.hash); } } } @@ -410,6 +411,7 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock) wtx.MarkUnspent(&txout - &tx.vout[0]); wtx.WriteToDisk(); NotifyTransactionChanged(this, hash, CT_UPDATED); + vMintingWalletUpdated.push_back(hash); } } } @@ -540,7 +542,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) // Notify UI of new or updated transaction NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); - + vMintingWalletUpdated.push_back(hash); // notify an external script when a wallet transaction comes in or is updated std::string strCmd = GetArg("-walletnotify", ""); @@ -1679,7 +1681,7 @@ bool CWallet::GetStakeWeight(const CKeyStore& keystore, uint64& nMinWeight, uint } if (fDebug) - printf("Get stake weight: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size()); + printf("Get stake weight: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size()); fCoinsDataActual = true; } @@ -1912,7 +1914,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int } if (fDebug) - printf("Stake miner: %zu meta items loaded for %zu coins\n", mapMeta.size(), setCoins.size()); + printf("Stake miner: %d meta items loaded for %d coins\n", mapMeta.size(), setCoins.size()); fCoinsDataActual = true; } @@ -2116,6 +2118,7 @@ bool CWallet::CommitTransaction(CWalletTx& wtxNew, CReserveKey& reservekey) coin.MarkSpent(txin.prevout.n); coin.WriteToDisk(); NotifyTransactionChanged(this, coin.GetHash(), CT_UPDATED); + vMintingWalletUpdated.push_back(coin.GetHash()); } if (fFileBacked) @@ -2778,3 +2781,21 @@ void CWallet::GetKeyBirthTimes(std::map &mapKeyBirth) const { for (std::map::const_iterator it = mapKeyFirstBlock.begin(); it != mapKeyFirstBlock.end(); it++) mapKeyBirth[it->first] = it->second->nTime - 7200; // block times can be 2h off } + +void CWallet::ClearOrphans() +{ + list orphans; + + LOCK(cs_wallet); + for(map::const_iterator it = mapWallet.begin(); it != mapWallet.end(); ++it) + { + const CWalletTx *wtx = &(*it).second; + if((wtx->IsCoinBase() || wtx->IsCoinStake()) && !wtx->IsInMainChain()) + { + orphans.push_back(wtx->GetHash()); + } + } + + for(list::const_iterator it = orphans.begin(); it != orphans.end(); ++it) + EraseFromWallet(*it); +} \ No newline at end of file