@@ -1973,24 +1973,20 @@ void CWallet::AvailableCoins(
19731973 const uint256& wtxid = it->first ;
19741974 const CWalletTx* pcoin = &(*it).second ;
19751975
1976- if (!CheckFinalTx (*pcoin))
1977- continue ;
1978-
1979- if (fOnlyConfirmed && !pcoin->IsTrusted ())
1980- continue ;
1981-
1982- if ((pcoin->IsCoinBase () || pcoin->IsCoinStake ()) && pcoin->GetBlocksToMaturity () > 0 )
1983- continue ;
1976+ if (!CheckFinalTx (*pcoin)) continue ;
1977+ if (fOnlyConfirmed && !pcoin->IsTrusted ()) continue ;
1978+ if (pcoin->GetBlocksToMaturity () > 0 ) continue ;
19841979
19851980 int nDepth = pcoin->GetDepthInMainChain (false );
19861981 // do not use IX for inputs that have less then 6 blockchain confirmations
1987- if (fUseIX && nDepth < 6 )
1988- continue ;
1982+ if (fUseIX && nDepth < 6 ) continue ;
19891983
19901984 // We should not consider coins which aren't at least in our mempool
19911985 // It's possible for these to be conflicted via ancestors which we may never be able to detect
1992- if (nDepth == 0 && !pcoin->InMempool ())
1993- continue ;
1986+ if (nDepth == 0 && !pcoin->InMempool ()) continue ;
1987+
1988+ // Check min depth requirement for stake inputs
1989+ if (nCoinType == STAKABLE_COINS && nDepth <= Params ().COINSTAKE_MIN_DEPTH ()) continue ;
19941990
19951991 for (unsigned int i = 0 ; i < pcoin->vout .size (); i++) {
19961992 bool found = false ;
@@ -2009,29 +2005,17 @@ void CWallet::AvailableCoins(
20092005 }
20102006 if (!found) continue ;
20112007
2012- if (nCoinType == STAKABLE_COINS) {
2013- if (pcoin->vout [i].IsZerocoinMint ())
2014- continue ;
2015- }
2008+ if (nCoinType == STAKABLE_COINS && pcoin->vout [i].IsZerocoinMint ()) continue ;
2009+ if (IsSpent (wtxid, i)) continue ;
20162010
20172011 isminetype mine = IsMine (pcoin->vout [i]);
2018- if (IsSpent (wtxid, i))
2019- continue ;
2020- if (mine == ISMINE_NO)
2021- continue ;
2022-
2023- if ((mine == ISMINE_MULTISIG || mine == ISMINE_SPENDABLE) && nWatchonlyConfig == 2 )
2024- continue ;
2025-
2026- if (mine == ISMINE_WATCH_ONLY && nWatchonlyConfig == 1 )
2027- continue ;
2028-
2029- if (IsLockedCoin ((*it).first , i) && nCoinType != ONLY_10000)
2030- continue ;
2031- if (pcoin->vout [i].nValue <= 0 && !fIncludeZeroValue )
2032- continue ;
2033- if (fCoinsSelected && !coinControl->fAllowOtherInputs && !coinControl->IsSelected ((*it).first , i))
2034- continue ;
2012+ if ( (mine == ISMINE_NO) ||
2013+ ((mine == ISMINE_MULTISIG || mine == ISMINE_SPENDABLE) && nWatchonlyConfig == 2 ) ||
2014+ (mine == ISMINE_WATCH_ONLY && nWatchonlyConfig == 1 ) ||
2015+ (IsLockedCoin ((*it).first , i) && nCoinType != ONLY_10000) ||
2016+ (pcoin->vout [i].nValue <= 0 && !fIncludeZeroValue ) ||
2017+ (fCoinsSelected && !coinControl->fAllowOtherInputs && !coinControl->IsSelected ((*it).first , i))
2018+ ) continue ;
20352019
20362020 // --Skip P2CS outputs
20372021 // skip cold coins
@@ -2193,16 +2177,8 @@ bool CWallet::MintableCoins()
21932177 const bool fIncludeCold = sporkManager.IsSporkActive (SPORK_17_COLDSTAKING_ENFORCEMENT) && GetBoolArg (" -coldstaking" , true );
21942178 AvailableCoins (vCoins, true , NULL , false , STAKABLE_COINS, false , 1 , fIncludeCold , false );
21952179
2196- if (vCoins.size () > 0 ) {
2197- // check that we have at least one utxo eligible for staking (min age/depth)
2198- const int64_t time = GetAdjustedTime ();
2199- const int chainHeight = chainActive.Height ();
2200- for (const COutput& out : vCoins) {
2201- CBlockIndex* utxoBlock = mapBlockIndex.at (out.tx ->hashBlock );
2202- if (Params ().HasStakeMinAgeOrDepth (chainHeight, time, utxoBlock->nHeight , utxoBlock->nTime ))
2203- return true ;
2204- }
2205- }
2180+ // check that we have at least one utxo eligible for staking.
2181+ return (vCoins.size () > 0 );
22062182 }
22072183
22082184 return false ;
0 commit comments