Skip to content

Commit 4de0827

Browse files
Merge pull request #442 from aguycalled/fix-pindexbestheader
Use chainActive.Tip() instead of pindexBestHeader
2 parents afa2e8b + 34534ac commit 4de0827

File tree

8 files changed

+21
-21
lines changed

8 files changed

+21
-21
lines changed

src/main.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1186,7 +1186,7 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
11861186
nValueOut += txout.nValue;
11871187
if (!MoneyRange(nValueOut))
11881188
return state.DoS(100, false, REJECT_INVALID, "bad-txns-txouttotal-toolarge");
1189-
if(txout.scriptPubKey.IsColdStaking() && !IsColdStakingEnabled(pindexBestHeader, Params().GetConsensus()))
1189+
if(txout.scriptPubKey.IsColdStaking() && !IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus()))
11901190
return state.DoS(100, false, REJECT_INVALID, "cold-staking-not-enabled");
11911191
}
11921192

@@ -1245,11 +1245,11 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C
12451245
if (!CheckTransaction(tx, state))
12461246
return false; // state filled in by CheckTransaction
12471247

1248-
if (IsCommunityFundEnabled(pindexBestHeader, Params().GetConsensus()) && tx.nVersion < CTransaction::TXDZEEL_VERSION_V2)
1248+
if (IsCommunityFundEnabled(chainActive.Tip(), Params().GetConsensus()) && tx.nVersion < CTransaction::TXDZEEL_VERSION_V2)
12491249
return state.DoS(100, false, REJECT_INVALID, "old-version");
12501250

1251-
if (IsCommunityFundEnabled(pindexBestHeader, Params().GetConsensus())) {
1252-
bool fReducedQuorum = IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus());
1251+
if (IsCommunityFundEnabled(chainActive.Tip(), Params().GetConsensus())) {
1252+
bool fReducedQuorum = IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus());
12531253
int nMaxVersionProposal = fReducedQuorum ? Params().GetConsensus().nProposalMaxVersion : 2;
12541254
int nMaxVersionPaymentRequest = fReducedQuorum ? Params().GetConsensus().nPaymentRequestMaxVersion : 2;
12551255

@@ -2375,7 +2375,7 @@ bool DisconnectBlock(const CBlock& block, CValidationState& state, const CBlockI
23752375
uint256 hash = tx.GetHash();
23762376

23772377
if(IsCommunityFundEnabled(pindex->pprev, Params().GetConsensus())) {
2378-
bool fReducedQuorum = IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus());
2378+
bool fReducedQuorum = IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus());
23792379
int nMaxVersionProposal = fReducedQuorum ? Params().GetConsensus().nProposalMaxVersion : 2;
23802380
int nMaxVersionPaymentRequest = fReducedQuorum ? Params().GetConsensus().nPaymentRequestMaxVersion : 2;
23812381

@@ -3140,7 +3140,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin
31403140
}
31413141

31423142
if(IsCommunityFundEnabled(pindex->pprev, Params().GetConsensus())) {
3143-
bool fReducedQuorum = IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus());
3143+
bool fReducedQuorum = IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus());
31443144
int nMaxVersionProposal = fReducedQuorum ? Params().GetConsensus().nProposalMaxVersion : 2;
31453145
int nMaxVersionPaymentRequest = fReducedQuorum ? Params().GetConsensus().nPaymentRequestMaxVersion : 2;
31463146

@@ -5052,8 +5052,8 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn
50525052
if (!IsFinalTx(tx, nHeight, nLockTimeCutoff)) {
50535053
return state.DoS(10, false, REJECT_INVALID, "bad-txns-nonfinal", false, "non-final transaction");
50545054
}
5055-
if(IsCommunityFundEnabled(pindexBestHeader, Params().GetConsensus())) {
5056-
bool fReducedQuorum = IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus());
5055+
if(IsCommunityFundEnabled(chainActive.Tip(), Params().GetConsensus())) {
5056+
bool fReducedQuorum = IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus());
50575057
int nMaxVersionProposal = fReducedQuorum ? Params().GetConsensus().nProposalMaxVersion : 2;
50585058
int nMaxVersionPaymentRequest = fReducedQuorum ? Params().GetConsensus().nPaymentRequestMaxVersion : 2;
50595059

src/qt/communityfundcreatepaymentrequestdialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ void CommunityFundCreatePaymentRequestDialog::click_pushButtonSubmitPaymentReque
218218
strDZeel.push_back(Pair("s",Signature));
219219
strDZeel.push_back(Pair("r",sRandom));
220220
strDZeel.push_back(Pair("i",id));
221-
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus()) ? CFund::CPaymentRequest::CURRENT_VERSION : 2));
221+
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus()) ? CFund::CPaymentRequest::CURRENT_VERSION : 2));
222222

223223
wtx.strDZeel = strDZeel.write();
224224
wtx.nCustomVersion = CTransaction::PAYMENT_REQUEST_VERSION;

src/qt/communityfundcreateproposaldialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,7 @@ void CommunityFundCreateProposalDialog::click_pushButtonCreateProposal()
130130
strDZeel.push_back(Pair("a",Address));
131131
strDZeel.push_back(Pair("d",nDeadline));
132132
strDZeel.push_back(Pair("s",sDesc));
133-
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus()) ? CFund::CProposal::CURRENT_VERSION : 2));
133+
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus()) ? CFund::CProposal::CURRENT_VERSION : 2));
134134

135135
wtx.strDZeel = strDZeel.write();
136136
wtx.nCustomVersion = CTransaction::PROPOSAL_VERSION;

src/qt/getaddresstoreceive.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ void getAddressToReceive::getNewAddress()
7777

7878
void getAddressToReceive::getColdStakingAddress()
7979
{
80-
if (!IsCommunityFundEnabled(pindexBestHeader,Params().GetConsensus()))
80+
if (!IsCommunityFundEnabled(chainActive.Tip(),Params().GetConsensus()))
8181
QMessageBox::warning(this, tr("Action not available"),
8282
"<qt>Cold Staking is not active yet.</qt>");
8383
else {

src/rpc/blockchain.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1028,7 +1028,7 @@ UniValue cfundstats(const UniValue& params, bool fHelp)
10281028
vp.push_back(Pair("current", chainActive.Tip()->nHeight));
10291029
UniValue consensus(UniValue::VOBJ);
10301030
consensus.push_back(Pair("blocksPerVotingCycle",Params().GetConsensus().nBlocksPerVotingCycle));
1031-
if (!IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus())){
1031+
if (!IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus())){
10321032
consensus.push_back(Pair("minSumVotesPerVotingCycle",Params().GetConsensus().nBlocksPerVotingCycle * Params().GetConsensus().nMinimumQuorum));
10331033
} else {
10341034
consensus.push_back(Pair("minSumVotesPerVotingCycle",Params().GetConsensus().nBlocksPerVotingCycle * Params().GetConsensus().nMinimumQuorumFirstHalf));

src/rpc/rawtransaction.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -541,7 +541,7 @@ UniValue createrawtransaction(const UniValue& params, bool fHelp)
541541
rawTx.strDZeel = params[2].get_str();
542542
}
543543

544-
rawTx.nVersion = IsCommunityFundEnabled(pindexBestHeader,Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
544+
rawTx.nVersion = IsCommunityFundEnabled(chainActive.Tip(),Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
545545

546546
int nout = -1;
547547

src/wallet/rpcwallet.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ UniValue getcoldstakingaddress(const UniValue& params, bool fHelp)
173173

174174
);
175175

176-
if (!IsColdStakingEnabled(pindexBestHeader,Params().GetConsensus()))
176+
if (!IsColdStakingEnabled(chainActive.Tip(),Params().GetConsensus()))
177177
throw runtime_error(
178178
"Cold Staking is not active yet.");
179179

@@ -592,7 +592,7 @@ UniValue createproposal(const UniValue& params, bool fHelp)
592592
strDZeel.push_back(Pair("a",Address));
593593
strDZeel.push_back(Pair("d",nDeadline));
594594
strDZeel.push_back(Pair("s",sDesc));
595-
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus()) ? CFund::CProposal::CURRENT_VERSION : 2));
595+
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus()) ? CFund::CProposal::CURRENT_VERSION : 2));
596596

597597
wtx.strDZeel = strDZeel.write();
598598
wtx.nCustomVersion = CTransaction::PROPOSAL_VERSION;
@@ -705,7 +705,7 @@ UniValue createpaymentrequest(const UniValue& params, bool fHelp)
705705
strDZeel.push_back(Pair("s",Signature));
706706
strDZeel.push_back(Pair("r",sRandom));
707707
strDZeel.push_back(Pair("i",id));
708-
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(pindexBestHeader, Params().GetConsensus()) ? CFund::CPaymentRequest::CURRENT_VERSION : 2));
708+
strDZeel.push_back(Pair("v",IsReducedCFundQuorumEnabled(chainActive.Tip(), Params().GetConsensus()) ? CFund::CPaymentRequest::CURRENT_VERSION : 2));
709709

710710
wtx.strDZeel = strDZeel.write();
711711
wtx.nCustomVersion = CTransaction::PAYMENT_REQUEST_VERSION;

src/wallet/wallet.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -268,7 +268,7 @@ void CWallet::AvailableCoinsForStaking(vector<COutput>& vCoins, unsigned int nSp
268268
((IsMine(pcoin->vout[i]) & (ISMINE_SPENDABLE)) != ISMINE_NO &&
269269
!pcoin->vout[i].scriptPubKey.IsColdStaking()) ||
270270
((IsMine(pcoin->vout[i]) & (ISMINE_STAKABLE)) != ISMINE_NO &&
271-
IsColdStakingEnabled(pindexBestHeader, Params().GetConsensus()))));
271+
IsColdStakingEnabled(chainActive.Tip(), Params().GetConsensus()))));
272272
}
273273
}
274274
}
@@ -352,7 +352,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
352352
{
353353
static int nMaxStakeSearchInterval = 60;
354354
bool fKernelFound = false;
355-
for (unsigned int n=0; n<min(nSearchInterval,(int64_t)nMaxStakeSearchInterval) && !fKernelFound && pindexPrev == pindexBestHeader; n++)
355+
for (unsigned int n=0; n<min(nSearchInterval,(int64_t)nMaxStakeSearchInterval) && !fKernelFound && pindexPrev == chainActive.Tip(); n++)
356356
{
357357
boost::this_thread::interruption_point();
358358
// Search backward in time from the given txNew timestamp
@@ -475,7 +475,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
475475
if (!TransactionGetCoinAge(ptxNew, nCoinAge))
476476
return error("CreateCoinStake : failed to calculate coin age");
477477

478-
nReward = GetProofOfStakeReward(pindexPrev->nHeight + 1, nCoinAge, nFees, pindexBestHeader);
478+
nReward = GetProofOfStakeReward(pindexPrev->nHeight + 1, nCoinAge, nFees, chainActive.Tip());
479479
if (nReward <= 0)
480480
return false;
481481

@@ -619,7 +619,7 @@ bool CWallet::CreateCoinStake(const CKeyStore& keystore, unsigned int nBits, int
619619
}
620620
}
621621

622-
txNew.nVersion = IsCommunityFundEnabled(pindexBestHeader,Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
622+
txNew.nVersion = IsCommunityFundEnabled(chainActive.Tip(),Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
623623

624624
// Sign
625625
int nIn = 0;
@@ -2816,7 +2816,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend, CWalletTx& wt
28162816

28172817
CMutableTransaction txNew;
28182818

2819-
txNew.nVersion = IsCommunityFundEnabled(pindexBestHeader,Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
2819+
txNew.nVersion = IsCommunityFundEnabled(chainActive.Tip(),Params().GetConsensus()) ? CTransaction::TXDZEEL_VERSION_V2 : CTransaction::TXDZEEL_VERSION;
28202820

28212821
if(wtxNew.nCustomVersion > 0) txNew.nVersion = wtxNew.nCustomVersion;
28222822

0 commit comments

Comments
 (0)