diff options
author | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-17 14:45:49 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@gmail.com> | 2017-04-17 14:46:04 +0200 |
commit | 2584925077f9658b3953ad931b74779006e59807 (patch) | |
tree | 63b71527f3fb125e0b7fe98e73ccb524a508059f /src/wallet | |
parent | a077a90da88f12d9f10c8b85840bdb847a98b0a0 (diff) | |
parent | 9fececb2cbabc52cc375b84bf840fac018cc8121 (diff) |
Merge #10178: Remove CValidationInterface::UpdatedTransaction
9fececb Remove CValidationInterface::UpdatedTransaction (Matt Corallo)
d89f8ad Make DisconnectBlock and ConnectBlock static in validation.cpp (Matt Corallo)
Tree-SHA512: 146597b538c09c1e8071f4f88ffeba0645c6816f86030b142174bd298cc18ae09a400e6ca8de04d091e37b635f99f4c05982c09e6729691eb8ca6b8439ab97ca
Diffstat (limited to 'src/wallet')
-rw-r--r-- | src/wallet/wallet.cpp | 38 | ||||
-rw-r--r-- | src/wallet/wallet.h | 6 |
2 files changed, 31 insertions, 13 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index c9ca8f653d..e9e18603b3 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1155,6 +1155,33 @@ void CWallet::BlockConnected(const std::shared_ptr<const CBlock>& pblock, const for (size_t i = 0; i < pblock->vtx.size(); i++) { SyncTransaction(pblock->vtx[i], pindex, i); } + + // The GUI expects a NotifyTransactionChanged when a coinbase tx + // which is in our wallet moves from in-the-best-block to + // 2-confirmations (as it only displays them at that time). + // We do that here. + if (hashPrevBestCoinbase.IsNull()) { + // Immediately after restart we have no idea what the coinbase + // transaction from the previous block is. + // For correctness we scan over the entire wallet, looking for + // the previous block's coinbase, just in case it is ours, so + // that we can notify the UI that it should now be displayed. + if (pindex->pprev) { + for (const std::pair<uint256, CWalletTx>& p : mapWallet) { + if (p.second.IsCoinBase() && p.second.hashBlock == pindex->pprev->GetBlockHash()) { + NotifyTransactionChanged(this, p.first, CT_UPDATED); + break; + } + } + } + } else { + std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashPrevBestCoinbase); + if (mi != mapWallet.end()) { + NotifyTransactionChanged(this, hashPrevBestCoinbase, CT_UPDATED); + } + } + + hashPrevBestCoinbase = pblock->vtx[0]->GetHash(); } void CWallet::BlockDisconnected(const std::shared_ptr<const CBlock>& pblock) { @@ -3383,17 +3410,6 @@ void CWallet::GetAllReserveKeys(std::set<CKeyID>& setAddress) const } } -void CWallet::UpdatedTransaction(const uint256 &hashTx) -{ - { - LOCK(cs_wallet); - // Only notify UI if this transaction is in this wallet - std::map<uint256, CWalletTx>::const_iterator mi = mapWallet.find(hashTx); - if (mi != mapWallet.end()) - NotifyTransactionChanged(this, hashTx, CT_UPDATED); - } -} - void CWallet::GetScriptForMining(std::shared_ptr<CReserveScript> &script) { std::shared_ptr<CReserveKey> rKey = std::make_shared<CReserveKey>(this); diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index cc1a6b7183..2eb6bd9504 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -713,6 +713,10 @@ private: */ bool AddWatchOnly(const CScript& dest) override; + // Used to NotifyTransactionChanged of the previous block's coinbase when + // the next block comes in + uint256 hashPrevBestCoinbase; + public: /* * Main wallet lock. @@ -978,8 +982,6 @@ public: bool DelAddressBook(const CTxDestination& address); - void UpdatedTransaction(const uint256 &hashTx) override; - void Inventory(const uint256 &hash) override { { |