Skip to content

Commit

Permalink
Fix blockversion calc + adjust overmint issue
Browse files Browse the repository at this point in the history
  • Loading branch information
Liquid369 committed Dec 3, 2020
1 parent b7fb8e8 commit 117ca6c
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,7 @@ class CMainParams : public CChainParams
nRejectOldSporkKey = 1569538800; //!> Fully reject old spork key after Thursday, September 26, 2019 11:00:00 PM GMT
nBlockStakeModifierlV2 = 261028;
nBlockTimeProtocolV2 = 575000;
nStartBIP65 = 200;
nStartBIP65 = 261027;

// New P2P messages signatures
nBlockEnforceNewMessageSignatures = nBlockStakeModifierlV2 + 10;
Expand Down
1 change: 1 addition & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,7 @@ class CChainParams
int Block_Enforce_Invalid() const { return nBlockEnforceInvalidUTXO; }
int Zerocoin_Block_V2_Start() const { return nBlockZerocoinV2; }
int NewSigsActive(const int nHeight) const { return nHeight >= nBlockEnforceNewMessageSignatures; }
int Block_V6_StartHeight() const { return nBlockStakeModifierlV2; }
bool IsStakeModifierV2(const int nHeight) const { return nHeight >= nBlockStakeModifierlV2; }
int Block_V7_StartHeight() const { return nBlockV7StartHeight; }

Expand Down
8 changes: 4 additions & 4 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1970,9 +1970,9 @@ int64_t GetBlockValue(int nHeight)
nSubsidy = 10.8 * COIN;
} else if (nHeight <= 238621 && nHeight > Params().LAST_POW_BLOCK()) { //Start PoS
nSubsidy = 10.8 * COIN;
} else if (nHeight <= 788221 && nHeight >= 238622) {
} else if (nHeight <= 788621 && nHeight >= 238622) {
nSubsidy = 9 * COIN;
} else if (nHeight <= 1289222 && nHeight >= 788222) {
} else if (nHeight <= 1289222 && nHeight >= 788622) {
nSubsidy = 5.4 * COIN;
} else {
nSubsidy = 5.4 * COIN;
Expand Down Expand Up @@ -4582,8 +4582,8 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta
if((block.nVersion < 3 && nHeight >= 1) ||
(block.nVersion < 4 && nHeight >= Params().Zerocoin_StartTime()) ||
(block.nVersion < 5 && nHeight >= Params().BIP65_Start()) ||
(block.nVersion < 6 && nHeight >= Params().IsStakeModifierV2(nHeight)) ||
(block.nVersion < 7 && nHeight >= Params().IsTimeProtocolV2(nHeight)))
(block.nVersion < 6 && nHeight >= Params().Block_V6_StartHeight()) ||
(block.nVersion < 7 && nHeight >= Params().Block_V7_StartHeight()))
{
std::string stringErr = strprintf("rejected block version %d at height %d", block.nVersion, nHeight);
return state.Invalid(error("%s : %s", __func__, stringErr), REJECT_OBSOLETE, stringErr);
Expand Down
2 changes: 1 addition & 1 deletion src/masternode-budget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,7 +553,7 @@ void CBudgetManager::FillBlockPayee(CMutableTransaction& txNew, CAmount nFees, b
++it;
}

CAmount blockValue = GetBlockValue(pindexPrev->nHeight);
CAmount blockValue = GetBlockValue(pindexPrev->nHeight + 1);

if (fProofOfStake) {
if (nHighestCount > 0) {
Expand Down
4 changes: 2 additions & 2 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
if (txNew.vout.size() > 1) {
pblock->payee = txNew.vout[1].scriptPubKey;
} else {
CAmount blockValue = nFees + GetBlockValue(pindexPrev->nHeight);
CAmount blockValue = nFees + GetBlockValue(pindexPrev->nHeight + 1);
txNew.vout[0].nValue = blockValue;
txNew.vin[0].scriptSig = CScript() << nHeight << OP_0;
}
Expand All @@ -474,7 +474,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn, CWallet* pwallet,
if (!fProofOfStake) {
pblock->vtx[0] = txNew;
pblocktemplate->vTxFees[0] = -nFees;
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight);
pblock->vtx[0].vout[0].nValue = GetBlockValue(pindexPrev->nHeight + 1);
pblock->vtx[0].vin[0].scriptSig = CScript() << nHeight << OP_0;
}

Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3601,7 +3601,7 @@ bool CWallet::CreateCoinStake(

// Calculate reward
CAmount nReward;
nReward = GetBlockValue(chainActive.Height());
nReward = GetBlockValue(pindexPrev->nHeight + 1);
nCredit += nReward;

// Create the output transaction(s)
Expand Down

0 comments on commit 117ca6c

Please sign in to comment.