99#include < coinjoin/common.h>
1010#include < coinjoin/options.h>
1111#include < evo/dmn_types.h>
12+ #include < wallet/receive.h>
1213#include < wallet/wallet.h>
1314#include < wallet/transaction.h>
1415
@@ -155,9 +156,9 @@ std::vector<CompactTallyItem> CWallet::SelectCoinsGroupedByAddresses(bool fSkipD
155156
156157 const CWalletTx& wtx = (*it).second ;
157158
158- if (wtx.IsCoinBase () && wtx. GetBlocksToMaturity ( ) > 0 ) continue ;
159- if (fSkipUnconfirmed && !wtx. IsTrusted ( )) continue ;
160- if (wtx. GetDepthInMainChain ( ) < 0 ) continue ;
159+ if (wtx.IsCoinBase () && GetTxBlocksToMaturity (wtx ) > 0 ) continue ;
160+ if (fSkipUnconfirmed && !CachedTxIsTrusted (* this , wtx )) continue ;
161+ if (GetTxDepthInMainChain (wtx ) < 0 ) continue ;
161162
162163 for (unsigned int i = 0 ; i < wtx.tx ->vout .size (); i++) {
163164 CTxDestination txdest;
@@ -247,7 +248,7 @@ int CWallet::CountInputsWithAmount(CAmount nInputAmount) const
247248 const auto it = mapWallet.find (outpoint.hash );
248249 if (it == mapWallet.end ()) continue ;
249250 if (it->second .tx ->vout [outpoint.n ].nValue != nInputAmount) continue ;
250- if (it->second . GetDepthInMainChain ( ) < 0 ) continue ;
251+ if (GetTxDepthInMainChain ( it->second ) < 0 ) continue ;
251252
252253 nTotal++;
253254 }
@@ -317,7 +318,7 @@ int CWallet::GetRealOutpointCoinJoinRounds(const COutPoint& outpoint, int nRound
317318 }
318319
319320 // make sure we spent all of it with 0 fee, reset to 0 rounds otherwise
320- if (wtx-> GetDebit ( ISMINE_SPENDABLE) != wtx-> GetCredit ( ISMINE_SPENDABLE)) {
321+ if (CachedTxGetDebit (* this , *wtx, ISMINE_SPENDABLE) != CachedTxGetCredit (* this , *wtx, ISMINE_SPENDABLE)) {
321322 *nRoundsRef = 0 ;
322323 WalletCJLogPrint (this , " %s UPDATED %-70s %3d\n " , __func__, outpoint.ToStringShort (), *nRoundsRef);
323324 return *nRoundsRef;
@@ -327,7 +328,7 @@ int CWallet::GetRealOutpointCoinJoinRounds(const COutPoint& outpoint, int nRound
327328 bool fDenomFound = false ;
328329 // only denoms here so let's look up
329330 for (const auto & txinNext : wtx->tx ->vin ) {
330- if (IsMine ( txinNext)) {
331+ if (InputIsMine (* this , txinNext)) {
331332 int n = GetRealOutpointCoinJoinRounds (txinNext.prevout , nRounds + 1 );
332333 // denom found, find the shortest chain or initially assign nShortest with the first found value
333334 if (n >= 0 && (n < nShortest || nShortest == -10 )) {
@@ -481,7 +482,7 @@ CAmount CWallet::GetNormalizedAnonymizedBalance() const
481482
482483 CAmount nValue = it->second .tx ->vout [outpoint.n ].nValue ;
483484 if (!CoinJoin::IsDenominatedAmount (nValue)) continue ;
484- if (it->second . GetDepthInMainChain ( ) < 0 ) continue ;
485+ if (GetTxDepthInMainChain ( it->second ) < 0 ) continue ;
485486
486487 int nRounds = GetCappedOutpointCoinJoinRounds (outpoint);
487488 nTotal += nValue * nRounds / CCoinJoinClientOptions::GetRounds ();
@@ -495,7 +496,7 @@ CAmount CachedTxGetAnonymizedCredit(const CWallet& wallet, const CWalletTx& wtx,
495496 AssertLockHeld (wallet.cs_wallet );
496497
497498 // Exclude coinbase and conflicted txes
498- if (wtx.IsCoinBase () || wtx. GetDepthInMainChain ( ) < 0 )
499+ if (wtx.IsCoinBase () || wallet. GetTxBlocksToMaturity (wtx ) < 0 )
499500 return 0 ;
500501
501502 CAmount nCredit = 0 ;
@@ -512,7 +513,7 @@ CAmount CachedTxGetAnonymizedCredit(const CWallet& wallet, const CWalletTx& wtx,
512513 if (wallet.IsSpent (hashTx, i) || !CoinJoin::IsDenominatedAmount (txout.nValue )) continue ;
513514
514515 if (wallet.IsFullyMixed (outpoint)) {
515- nCredit += wallet. GetCredit ( txout, ISMINE_SPENDABLE);
516+ nCredit += OutputGetCredit (wallet, txout, ISMINE_SPENDABLE);
516517 if (!MoneyRange (nCredit))
517518 throw std::runtime_error (std::string (__func__) + " : value out of range" );
518519 }
@@ -528,13 +529,13 @@ CoinJoinCredits CachedTxGetAvailableCoinJoinCredits(const CWallet& wallet, const
528529 AssertLockHeld (wallet.cs_wallet );
529530
530531 // Must wait until coinbase is safely deep enough in the chain before valuing it
531- if (wtx.IsCoinBase () && wtx. GetBlocksToMaturity ( ) > 0 )
532+ if (wtx.IsCoinBase () && wallet. GetTxBlocksToMaturity (wtx ) > 0 )
532533 return ret;
533534
534- int nDepth = wtx. GetDepthInMainChain ( );
535+ int nDepth = wallet. GetTxBlocksToMaturity (wtx );
535536 if (nDepth < 0 ) return ret;
536537
537- ret.is_unconfirmed = wtx. IsTrusted ( ) && nDepth == 0 ;
538+ ret.is_unconfirmed = CachedTxIsTrusted (wallet, wtx ) && nDepth == 0 ;
538539
539540 if (wtx.m_amounts [CWalletTx::ANON_CREDIT].m_cached [ISMINE_SPENDABLE]) {
540541 if (ret.is_unconfirmed && wtx.m_amounts [CWalletTx::DENOM_UCREDIT].m_cached [ISMINE_SPENDABLE]) {
@@ -550,7 +551,7 @@ CoinJoinCredits CachedTxGetAvailableCoinJoinCredits(const CWallet& wallet, const
550551 const COutPoint outpoint = COutPoint (hashTx, i);
551552
552553 if (wallet.IsSpent (hashTx, i) || !CoinJoin::IsDenominatedAmount (txout.nValue )) continue ;
553- const CAmount credit = wallet. GetCredit ( txout, ISMINE_SPENDABLE);
554+ const CAmount credit = OutputGetCredit (wallet, txout, ISMINE_SPENDABLE);
554555
555556 if (wallet.IsFullyMixed (outpoint)) {
556557 ret.m_anonymized += credit;
0 commit comments