@@ -594,7 +594,7 @@ void CWallet::SyncMetaData(std::pair<TxSpends::iterator, TxSpends::iterator> ran
594594 * Outpoint is spent if any non-conflicted transaction
595595 * spends it:
596596 */
597- bool CWallet::IsSpent (interfaces::Chain::Lock& locked_chain, const uint256& hash, unsigned int n) const
597+ bool CWallet::IsSpent (interfaces::Chain::Lock& locked_chain, const uint256& hash, unsigned int n, const int min_depth ) const
598598{
599599 const COutPoint outpoint (hash, n);
600600 std::pair<TxSpends::const_iterator, TxSpends::const_iterator> range;
@@ -606,6 +606,7 @@ bool CWallet::IsSpent(interfaces::Chain::Lock& locked_chain, const uint256& hash
606606 std::map<uint256, CWalletTx>::const_iterator mit = mapWallet.find (wtxid);
607607 if (mit != mapWallet.end ()) {
608608 int depth = mit->second .GetDepthInMainChain (locked_chain);
609+ if (depth < min_depth) continue ;
609610 if (depth > 0 || (depth == 0 && !mit->second .isAbandoned ()))
610611 return true ; // Spent
611612 }
@@ -1861,7 +1862,7 @@ CAmount CWalletTx::GetImmatureCredit(interfaces::Chain::Lock& locked_chain, bool
18611862 return 0 ;
18621863}
18631864
1864- CAmount CWalletTx::GetAvailableCredit (interfaces::Chain::Lock& locked_chain, bool fUseCache , const isminefilter& filter) const
1865+ CAmount CWalletTx::GetAvailableCredit (interfaces::Chain::Lock& locked_chain, bool fUseCache , const isminefilter& filter, const int min_depth ) const
18651866{
18661867 if (pwallet == nullptr )
18671868 return 0 ;
@@ -1889,7 +1890,7 @@ CAmount CWalletTx::GetAvailableCredit(interfaces::Chain::Lock& locked_chain, boo
18891890 uint256 hashTx = GetHash ();
18901891 for (unsigned int i = 0 ; i < tx->vout .size (); i++)
18911892 {
1892- if (!pwallet->IsSpent (locked_chain, hashTx, i))
1893+ if (!pwallet->IsSpent (locked_chain, hashTx, i, min_depth ))
18931894 {
18941895 const CTxOut &txout = tx->vout [i];
18951896 nCredit += pwallet->GetCredit (txout, filter);
@@ -2054,7 +2055,7 @@ CAmount CWallet::GetBalance(const isminefilter& filter, const int min_depth, con
20542055
20552056 if (pcoin->GetDepthInMainChain (*locked_chain) < min_depth) continue ;
20562057
2057- nTotal += pcoin->GetAvailableCredit (*locked_chain, true , filter);
2058+ nTotal += pcoin->GetAvailableCredit (*locked_chain, true , filter, min_depth );
20582059 }
20592060 }
20602061
0 commit comments