Skip to content

Commit

Permalink
Added rules for processing coinstake transactions
Browse files Browse the repository at this point in the history
  • Loading branch information
Bitcoinx committed Jan 30, 2018
1 parent 0964bf0 commit 69fe626
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 12 deletions.
4 changes: 2 additions & 2 deletions src/qt/transactionrecord.cpp
Expand Up @@ -35,7 +35,7 @@ QList<TransactionRecord> TransactionRecord::decomposeTransaction(const CWallet *
uint256 hash = wtx.GetHash();
std::map<std::string, std::string> mapValue = wtx.mapValue;

if (nNet > 0 || wtx.IsCoinBase())
if (nNet > 0 || wtx.IsCoinBase() || wtx.IsCoinStake())
{
//
// Credit
Expand All @@ -49,7 +49,7 @@ QList<TransactionRecord> 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))
{
Expand Down
20 changes: 10 additions & 10 deletions src/wallet/wallet.cpp
Expand Up @@ -1500,7 +1500,7 @@ int CWalletTx::GetRequestCount() const
int nRequests = -1;
{
LOCK(pwallet->cs_wallet);
if (IsCoinBase())
if (IsCoinBase() || IsCoinStake())
{
// Generated block
if (!hashUnset())
Expand Down Expand Up @@ -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));
}
}
Expand All @@ -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. */
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand All @@ -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)
Expand All @@ -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;
Expand All @@ -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)
Expand Down Expand Up @@ -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);
}
Expand Down Expand Up @@ -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());
}
Expand Down

0 comments on commit 69fe626

Please sign in to comment.