@@ -2247,14 +2247,14 @@ void CWallet::GetAvailableP2CSCoins(std::vector<COutput>& vCoins) const {
22472247/* *
22482248 * Test if the transaction is spendable.
22492249 */
2250- bool CheckTXAvailability (const CWalletTx* pcoin, bool fOnlyConfirmed , int & nDepth, const CBlockIndex*& pindexRet )
2250+ bool CheckTXAvailability (const CWalletTx* pcoin, bool fOnlyConfirmed , int & nDepth)
22512251{
22522252 AssertLockHeld (cs_main);
22532253 if (!CheckFinalTx (pcoin->tx )) return false ;
22542254 if (fOnlyConfirmed && !pcoin->IsTrusted ()) return false ;
22552255 if (pcoin->GetBlocksToMaturity () > 0 ) return false ;
22562256
2257- nDepth = pcoin->GetDepthInMainChain (pindexRet );
2257+ nDepth = pcoin->GetDepthInMainChain ();
22582258
22592259 // We should not consider coins which aren't at least in our mempool
22602260 // It's possible for these to be conflicted via ancestors which we may never be able to detect
@@ -2263,12 +2263,6 @@ bool CheckTXAvailability(const CWalletTx* pcoin, bool fOnlyConfirmed, int& nDept
22632263 return true ;
22642264}
22652265
2266- bool CheckTXAvailability (const CWalletTx* pcoin, bool fOnlyConfirmed , int & nDepth)
2267- {
2268- const CBlockIndex* pindexRet = nullptr ;
2269- return CheckTXAvailability (pcoin, fOnlyConfirmed , nDepth, pindexRet);
2270- }
2271-
22722266bool CWallet::GetMasternodeVinAndKeys (CTxIn& txinRet, CPubKey& pubKeyRet, CKey& keyRet, std::string strTxHash, std::string strOutputIndex, std::string& strError)
22732267{
22742268 // wait for reindex and/or import to finish
@@ -2547,13 +2541,13 @@ bool CWallet::StakeableCoins(std::vector<CStakeableOutput>* pCoins)
25472541
25482542 // Check if the tx is selectable
25492543 int nDepth;
2550- const CBlockIndex* pindex = nullptr ;
2551- if (!CheckTXAvailability (pcoin, true , nDepth, pindex))
2544+ if (!CheckTXAvailability (pcoin, true , nDepth))
25522545 continue ;
25532546
25542547 // Check min depth requirement for stake inputs
25552548 if (nDepth < Params ().GetConsensus ().nStakeMinDepth ) continue ;
25562549
2550+ const CBlockIndex* pindex = nullptr ;
25572551 for (unsigned int index = 0 ; index < pcoin->tx ->vout .size (); index++) {
25582552
25592553 auto res = CheckOutputAvailability (
@@ -2571,6 +2565,7 @@ bool CWallet::StakeableCoins(std::vector<CStakeableOutput>* pCoins)
25712565
25722566 // found valid coin
25732567 if (!pCoins) return true ;
2568+ if (!pindex) pindex = mapBlockIndex.at (pcoin->m_confirm .hashBlock );
25742569 pCoins->emplace_back (CStakeableOutput (pcoin, (int ) index, nDepth, res.spendable , res.solvable , pindex));
25752570 }
25762571 }
@@ -4301,12 +4296,6 @@ void CWalletTx::SetConf(Status status, const uint256& blockHash, int posInBlock)
43014296}
43024297
43034298int CWalletTx::GetDepthInMainChain () const
4304- {
4305- const CBlockIndex* pindexRet = nullptr ;
4306- return GetDepthInMainChain (pindexRet);
4307- }
4308-
4309- int CWalletTx::GetDepthInMainChain (const CBlockIndex*& pindexRet) const
43104299{
43114300 if (isUnconfirmed () || isAbandoned ()) return 0 ;
43124301 AssertLockHeld (cs_main);
@@ -4321,7 +4310,6 @@ int CWalletTx::GetDepthInMainChain(const CBlockIndex*& pindexRet) const
43214310 if (!pindex || !chainActive.Contains (pindex)) {
43224311 nResult = 0 ;
43234312 } else {
4324- pindexRet = pindex;
43254313 nResult = (isConflicted () ? (-1 ) : 1 ) * (chainActive.Height () - pindex->nHeight + 1 );
43264314 }
43274315 }
0 commit comments