From 69fe626c9c101c1dc0673782d3c181aab6994927 Mon Sep 17 00:00:00 2001 From: Bitcoinx Date: Tue, 30 Jan 2018 18:13:39 +0300 Subject: [PATCH] Added rules for processing coinstake transactions --- src/qt/transactionrecord.cpp | 4 ++-- src/wallet/wallet.cpp | 20 ++++++++++---------- 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/src/qt/transactionrecord.cpp b/src/qt/transactionrecord.cpp index 4ad81b0ed..acccebc54 100644 --- a/src/qt/transactionrecord.cpp +++ b/src/qt/transactionrecord.cpp @@ -35,7 +35,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * uint256 hash = wtx.GetHash(); std::map mapValue = wtx.mapValue; - if (nNet > 0 || wtx.IsCoinBase()) + if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake()) { // // Credit @@ -49,7 +49,7 @@ QList TransactionRecord::decomposeTransaction(const CWallet * TransactionRecord sub(hash, nTime); CTxDestination address; sub.idx = i; // vout index - sub.credit = txout.nValue; + sub.credit = wtx.IsCoinStake() ? 0 : txout.nValue; sub.involvesWatchAddress = mine & ISMINE_WATCH_ONLY; if (ExtractDestination(txout.scriptPubKey, address) && IsMine(*wallet, address)) { diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 792078abe..412f11fc2 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -1500,7 +1500,7 @@ int CWalletTx::GetRequestCount() const int nRequests = -1; { LOCK(pwallet->cs_wallet); - if (IsCoinBase()) + if (IsCoinBase() || IsCoinStake()) { // Generated block if (!hashUnset()) @@ -1687,7 +1687,7 @@ void CWallet::ReacceptWalletTransactions() int nDepth = wtx.GetDepthInMainChain(); - if (!wtx.IsCoinBase() && (nDepth == 0 && !wtx.isAbandoned())) { + if (!wtx.IsCoinBase() && !wtx.IsCoinStake() && (nDepth == 0 && !wtx.isAbandoned())) { mapSorted.insert(std::make_pair(wtx.nOrderPos, &wtx)); } } @@ -1706,7 +1706,7 @@ void CWallet::ReacceptWalletTransactions() bool CWalletTx::RelayWalletTransaction(CConnman* connman) { assert(pwallet->GetBroadcastTransactions()); - if (!IsCoinBase() && !isAbandoned() && GetDepthInMainChain() == 0) + if (!IsCoinBase() && !IsCoinStake() && !isAbandoned() && GetDepthInMainChain() == 0) { CValidationState state; /* GetDepthInMainChain already catches known conflicts. */ @@ -1771,7 +1771,7 @@ CAmount CWalletTx::GetDebit(const isminefilter& filter) const CAmount CWalletTx::GetCredit(const isminefilter& filter) const { // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; CAmount credit = 0; @@ -1803,7 +1803,7 @@ CAmount CWalletTx::GetCredit(const isminefilter& filter) const CAmount CWalletTx::GetImmatureCredit(bool fUseCache) const { - if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain()) { if (fUseCache && fImmatureCreditCached) return nImmatureCreditCached; @@ -1821,7 +1821,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAvailableCreditCached) @@ -1847,7 +1847,7 @@ CAmount CWalletTx::GetAvailableCredit(bool fUseCache) const CAmount CWalletTx::GetImmatureWatchOnlyCredit(const bool& fUseCache) const { - if (IsCoinBase() && GetBlocksToMaturity() > 0 && IsInMainChain()) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0 && IsInMainChain()) { if (fUseCache && fImmatureWatchCreditCached) return nImmatureWatchCreditCached; @@ -1865,7 +1865,7 @@ CAmount CWalletTx::GetAvailableWatchOnlyCredit(const bool& fUseCache) const return 0; // Must wait until coinbase is safely deep enough in the chain before valuing it - if (IsCoinBase() && GetBlocksToMaturity() > 0) + if ((IsCoinBase() || IsCoinStake()) && GetBlocksToMaturity() > 0) return 0; if (fUseCache && fAvailableWatchCreditCached) @@ -3260,7 +3260,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, uint32_t nBits, uint32_ if (pcoin.first->tx->vout[pcoin.second].nValue >= GetStakeCombineThreshold()) continue; - tx.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); + tx.vin.push_back(CTxIn(pcoin.first->GetHash(), pcoin.second)); nCredit += pcoin.first->tx->vout[pcoin.second].nValue; vwtxPrev.push_back(pcoin.first); } @@ -4610,7 +4610,7 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const int CMerkleTx::GetBlocksToMaturity() const { - if (!IsCoinBase()) + if (!IsCoinBase() && !IsCoinStake()) return 0; return std::max(0, (COINBASE_MATURITY+1) - GetDepthInMainChain()); }