diff options
| author | Wladimir J. van der Laan <[email protected]> | 2014-10-13 13:56:54 +0200 |
|---|---|---|
| committer | Wladimir J. van der Laan <[email protected]> | 2014-10-13 13:57:07 +0200 |
| commit | d7e195048342afae9168377cebfc22ab000728a5 (patch) | |
| tree | ee5b07604ef073ef35d8aa13598fb7d6a4877bc4 /src/wallet.h | |
| parent | Merge pull request #5073 (diff) | |
| parent | [Wallet] Watch-only fixes (diff) | |
| download | discoin-d7e195048342afae9168377cebfc22ab000728a5.tar.xz discoin-d7e195048342afae9168377cebfc22ab000728a5.zip | |
Merge pull request #4937
ccca27a [Wallet] Watch-only fixes (Cozz Lovan)
Diffstat (limited to 'src/wallet.h')
| -rw-r--r-- | src/wallet.h | 34 |
1 files changed, 27 insertions, 7 deletions
diff --git a/src/wallet.h b/src/wallet.h index 58e285b7e..fa8a94dfc 100644 --- a/src/wallet.h +++ b/src/wallet.h @@ -230,6 +230,7 @@ public: // Adds a watch-only address to the store, and saves it to disk. bool AddWatchOnly(const CScript &dest); + bool RemoveWatchOnly(const CScript &dest); // Adds a watch-only address to the store, without saving it to disk (used by LoadWallet) bool LoadWatchOnly(const CScript &dest); @@ -709,18 +710,37 @@ public: return debit; } - CAmount GetCredit(bool fUseCache=true) const + CAmount GetCredit(const isminefilter& filter) const { // Must wait until coinbase is safely deep enough in the chain before valuing it if (IsCoinBase() && GetBlocksToMaturity() > 0) return 0; - // GetBalance can assume transactions in mapWallet won't change - if (fUseCache && fCreditCached) - return nCreditCached; - nCreditCached = pwallet->GetCredit(*this, ISMINE_ALL); - fCreditCached = true; - return nCreditCached; + int64_t credit = 0; + if (filter & ISMINE_SPENDABLE) + { + // GetBalance can assume transactions in mapWallet won't change + if (fCreditCached) + credit += nCreditCached; + else + { + nCreditCached = pwallet->GetCredit(*this, ISMINE_SPENDABLE); + fCreditCached = true; + credit += nCreditCached; + } + } + if (filter & ISMINE_WATCH_ONLY) + { + if (fWatchCreditCached) + credit += nWatchCreditCached; + else + { + nWatchCreditCached = pwallet->GetCredit(*this, ISMINE_WATCH_ONLY); + fWatchCreditCached = true; + credit += nWatchCreditCached; + } + } + return credit; } CAmount GetImmatureCredit(bool fUseCache=true) const |