X-Git-Url: https://git.novaco.in/?a=blobdiff_plain;f=src%2Fwallet.cpp;h=85262f7ee1014ad16799a146dab778d792195355;hb=63071de429b3e0552ddffee72b0c993a7c4ea6a4;hp=ca331361a1f8ea88e8550d50e4ad1ff0380fd7fd;hpb=d8f8063eda45b8dec864b28bb98839a2dd3a8170;p=novacoin.git diff --git a/src/wallet.cpp b/src/wallet.cpp index ca33136..85262f7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -16,7 +16,6 @@ using namespace std; extern int nStakeMaxAge; - ////////////////////////////////////////////////////////////////////////////// // // mapWallet @@ -354,7 +353,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 @@ -378,6 +377,24 @@ 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(); + NotifyTransactionChanged(this, hash, CT_UPDATED); + } + } + } + } } @@ -500,7 +517,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);