From 738ddb54c59efb9185b2a5fa2b3c6bfab51466a0 Mon Sep 17 00:00:00 2001 From: alex Date: Sun, 26 Jan 2014 02:58:17 +0400 Subject: [PATCH] Set of several minor fixes: * Fix winsock.h warnings while building for Windows; * Add MarkUnspent for confirmed wallet transactions. --- src/crypter.cpp | 4 ++-- src/netbase.cpp | 2 +- src/qt/qtipcserver.cpp | 2 +- src/rpcnet.cpp | 2 +- src/version.h | 2 +- src/wallet.cpp | 21 +++++++++++++++++++-- src/wallet.h | 2 +- 7 files changed, 26 insertions(+), 9 deletions(-) diff --git a/src/crypter.cpp b/src/crypter.cpp index 3a7f997..1f0e9df 100644 --- a/src/crypter.cpp +++ b/src/crypter.cpp @@ -6,11 +6,11 @@ #include #include #include + +#include "crypter.h" #ifdef WIN32 #include #endif - -#include "crypter.h" #include "scrypt.h" bool CCrypter::SetKeyFromPassphrase(const SecureString& strKeyData, const std::vector& chSalt, const unsigned int nRounds, const unsigned int nDerivationMethod) diff --git a/src/netbase.cpp b/src/netbase.cpp index 95d6493..7f1d69a 100644 --- a/src/netbase.cpp +++ b/src/netbase.cpp @@ -3,8 +3,8 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "netbase.h" #include "util.h" +#include "netbase.h" #include "sync.h" #ifndef WIN32 diff --git a/src/qt/qtipcserver.cpp b/src/qt/qtipcserver.cpp index bb49dac..06c1502 100644 --- a/src/qt/qtipcserver.cpp +++ b/src/qt/qtipcserver.cpp @@ -3,7 +3,7 @@ // file COPYING or http://www.opensource.org/licenses/mit-license.php. #include -#if defined(WIN32) && BOOST_VERSION == 104900 +#if defined(WIN32) #define BOOST_INTERPROCESS_HAS_WINDOWS_KERNEL_BOOTTIME #define BOOST_INTERPROCESS_HAS_KERNEL_BOOTTIME #endif diff --git a/src/rpcnet.cpp b/src/rpcnet.cpp index 04ea310..bd622a4 100644 --- a/src/rpcnet.cpp +++ b/src/rpcnet.cpp @@ -2,8 +2,8 @@ // Distributed under the MIT/X11 software license, see the accompanying // file COPYING or http://www.opensource.org/licenses/mit-license.php. -#include "net.h" #include "bitcoinrpc.h" +#include "net.h" #include "alert.h" #include "wallet.h" #include "db.h" diff --git a/src/version.h b/src/version.h index e53f179..6a519db 100644 --- a/src/version.h +++ b/src/version.h @@ -52,6 +52,6 @@ static const int MEMPOOL_GD_VERSION = 60002; #define DISPLAY_VERSION_MAJOR 0 #define DISPLAY_VERSION_MINOR 4 #define DISPLAY_VERSION_REVISION 4 -#define DISPLAY_VERSION_BUILD 6 +#define DISPLAY_VERSION_BUILD 7 #endif diff --git a/src/wallet.cpp b/src/wallet.cpp index 4fadcf7..97db80c 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -353,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 @@ -377,6 +377,23 @@ 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); + } + } + } } } @@ -499,7 +516,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 bacfd89..db035e5 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -173,7 +173,7 @@ public: bool AddToWallet(const CWalletTx& wtxIn); bool AddToWalletIfInvolvingMe(const uint256 &hash, 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); void ReacceptWalletTransactions(); void ResendWalletTransactions(); -- 1.7.1