From 4dfc2cfa6d3c1ed774cccaa75f45715a5b5be617 Mon Sep 17 00:00:00 2001 From: Tranz5 Date: Mon, 26 May 2014 08:51:05 -0400 Subject: [PATCH] Changed WalletUpdateSpent added fBlock bool --- src/wallet.cpp | 20 ++++++++++++++++++-- src/wallet.h | 2 +- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/wallet.cpp b/src/wallet.cpp index 21e1191..3842bbc 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -348,7 +348,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list& acentries, return txOrdered; } -void CWallet::WalletUpdateSpent(const CTransaction &tx) +void CWallet::WalletUpdateSpent(const CTransaction &tx, bool fBlock) { // Anytime a signature is successfully verified, it's proof the outpoint is spent. // Update the wallet spent flag if it doesn't know due to wallet.dat being @@ -373,6 +373,22 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx) } } } + + if (fBlock) + { + uint256 hash = tx.GetHash(); + map::iterator mi = mapWallet.find(hash); + CWalletTx& wtx = (*mi).second; + + BOOST_FOREACH(const CTxOut& txout, tx.vout) + { + if (IsMine(txout)) + { + wtx.MarkUnspent(&txout - &tx.vout[0]); + wtx.WriteToDisk(); + } + } + } } void CWallet::MarkDirty() @@ -494,7 +510,7 @@ bool CWallet::AddToWallet(const CWalletTx& wtxIn) } #endif // since AddToWallet is called directly for self-originating transactions, check for consumption of own coins - WalletUpdateSpent(wtx); + WalletUpdateSpent(wtx, (wtxIn.hashBlock != 0)); // Notify UI of new or updated transaction NotifyTransactionChanged(this, hash, fInsertedNew ? CT_NEW : CT_UPDATED); diff --git a/src/wallet.h b/src/wallet.h index 0f111d6..b11f7f8 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -175,7 +175,7 @@ class CWallet : public CCryptoKeyStore bool AddToWallet(const CWalletTx& wtxIn); bool AddToWalletIfInvolvingMe(const CTransaction& tx, const CBlock* pblock, bool fUpdate = false, bool fFindBlock = false); bool EraseFromWallet(uint256 hash); - void WalletUpdateSpent(const CTransaction& prevout); + void WalletUpdateSpent(const CTransaction& prevout, bool fBlock = false); int ScanForWalletTransactions(CBlockIndex* pindexStart, bool fUpdate = false); int ScanForWalletTransaction(const uint256& hashTx); void ReacceptWalletTransactions();