Skip to content

Commit

Permalink
Changed WalletUpdateSpent added fBlock bool
Browse files Browse the repository at this point in the history
  • Loading branch information
Tranz5 committed May 26, 2014
1 parent 508d8eb commit 4dfc2cf
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 3 deletions.
20 changes: 18 additions & 2 deletions src/wallet.cpp
Expand Up @@ -348,7 +348,7 @@ CWallet::TxItems CWallet::OrderedTxItems(std::list<CAccountingEntry>& 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
Expand All @@ -373,6 +373,22 @@ void CWallet::WalletUpdateSpent(const CTransaction &tx)
}
}
}

if (fBlock)
{
uint256 hash = tx.GetHash();
map<uint256, CWalletTx>::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()
Expand Down Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/wallet.h
Expand Up @@ -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();
Expand Down

0 comments on commit 4dfc2cf

Please sign in to comment.