@@ -1983,6 +1983,9 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache, const isminefilter& filter
1983
1983
if (filter == ISMINE_SPENDABLE) {
1984
1984
cache = &nAvailableCreditCached;
1985
1985
cache_used = &fAvailableCreditCached ;
1986
+ } else if (filter == ISMINE_WATCH_ONLY) {
1987
+ cache = &nAvailableWatchCreditCached;
1988
+ cache_used = &fAvailableWatchCreditCached ;
1986
1989
}
1987
1990
1988
1991
if (fUseCache && cache_used && *cache_used) {
@@ -2025,31 +2028,7 @@ CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool fUseCache) const
2025
2028
2026
2029
CAmount CWalletTx::GetAvailableWatchOnlyCredit (const bool fUseCache ) const
2027
2030
{
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);
2053
2032
}
2054
2033
2055
2034
CAmount CWalletTx::GetChange () const
0 commit comments