@@ -1983,6 +1983,9 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter
19831983 if (filter == ISMINE_SPENDABLE) {
19841984 cache = &nAvailableCreditCached;
19851985 cache_used = &fAvailableCreditCached ;
1986+ } else if (filter == ISMINE_WATCH_ONLY) {
1987+ cache = &nAvailableWatchCreditCached;
1988+ cache_used = &fAvailableWatchCreditCached ;
19861989 }
19871990
19881991 if (fUseCache && cache_used && *cache_used) {
@@ -2025,31 +2028,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool fUseCache) const
20252028
20262029CAmount CWalletTx::GetAvailableWatchOnlyCredit (const bool fUseCache ) const
20272030{
2028- if (pwallet == nullptr )
2029- return 0 ;
2030-
2031- // Must wait until coinbase is safely deep enough in the chain before valuing it
2032- if (IsCoinBase () && GetBlocksToMaturity () > 0 )
2033- return 0 ;
2034-
2035- if (fUseCache && fAvailableWatchCreditCached )
2036- return nAvailableWatchCreditCached;
2037-
2038- CAmount nCredit = 0 ;
2039- for (unsigned int i = 0 ; i < tx->vout .size (); i++)
2040- {
2041- if (!pwallet->IsSpent (GetHash (), i))
2042- {
2043- const CTxOut &txout = tx->vout [i];
2044- nCredit += pwallet->GetCredit (txout, ISMINE_WATCH_ONLY);
2045- if (!MoneyRange (nCredit))
2046- throw std::runtime_error (std::string (__func__) + " : value out of range" );
2047- }
2048- }
2049-
2050- nAvailableWatchCreditCached = nCredit;
2051- fAvailableWatchCreditCached = true ;
2052- return nCredit;
2031+ return GetAvailableCredit (fUseCache , ISMINE_WATCH_ONLY);
20532032}
20542033
20552034CAmount CWalletTx::GetChange () const
0 commit comments