Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

force min amount to stake #6

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/chainparams.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ class CMainParams : public CChainParams
nMaturity = 10;
nMasternodeCountDrift = 20;
nMaxMoneyOut = 21000000 * COIN;
nStakeInputMinimal = 20 * COIN;

/** Height or Time Based Activations **/
nLastPOWBlock = 200;
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ class CChainParams
CAmount MaxMoneyOut() const { return nMaxMoneyOut; }
/** The masternode count that we will allow the see-saw reward payments to be off by */
int MasternodeCountDrift() const { return nMasternodeCountDrift; }
CAmount StakeInputMinimal() const { return nStakeInputMinimal; }
/** Make miner stop after a block is found. In RPC, don't return until nGenProcLimit blocks are generated */
bool MineBlocksOnDemand() const { return fMineBlocksOnDemand; }
/** In the future use NetworkIDString() for RPC fields */
Expand Down Expand Up @@ -138,6 +139,7 @@ class CChainParams
int nPoolMaxTransactions;
std::string strSporkKey;
std::string strMasternodePoolDummyAddress;
CAmount nStakeInputMinimal;
int64_t nStartMasternodePayments;
int64_t nBudget_Fee_Confirmations;
std::string strTreasuryAddress;
Expand Down
5 changes: 5 additions & 0 deletions src/kernel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,19 @@ bool fTestNet = false; //Params().NetworkID() == CBaseChainParams::TESTNET;
// Set to 3-hour for production network and 20-minute for test network
unsigned int nModifierInterval;
int nStakeTargetSpacing = 60;
extern unsigned int nStakeMinAge;
unsigned int getIntervalVersion(bool fTestNet)
{
if (fTestNet)
return MODIFIER_INTERVAL_TESTNET;
else
else {
if (chainActive.Height() > LIMIT_POS_FORK_HEIGHT)
return nStakeMinAge / 60;
return MODIFIER_INTERVAL;
}

}
// Hard checkpoints of stake modifiers to ensure they are deterministic
static std::map<int, unsigned int> mapStakeModifierCheckpoints =
boost::assign::map_list_of(0, 0xfd11f4e7u);
Expand Down
22 changes: 21 additions & 1 deletion src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3126,7 +3126,23 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
for (unsigned int i = 2; i < block.vtx.size(); i++)
if (block.vtx[i].IsCoinStake())
return state.DoS(100, error("CheckBlock() : more than one coinstake"));
}
//check for minimal stake input after fork
CBlockIndex* pindex = NULL;
CTransaction txPrev;
uint256 hashBlockPrev = block.hashPrevBlock;
BlockMap::iterator it = mapBlockIndex.find(hashBlockPrev);
if (it != mapBlockIndex.end())
pindex = it->second;
else
return state.DoS(100, error("CheckBlock() : stake failed to find block index"));
if (pindex->nHeight > LIMIT_POS_FORK_HEIGHT) {
if (!GetTransaction(block.vtx[1].vin[0].prevout.hash, txPrev, hashBlockPrev, true))
return state.DoS(100, error("CheckBlock() : stake failed to find vin transaction"));
if (txPrev.vout[block.vtx[1].vin[0].prevout.n].nValue < Params().StakeInputMinimal())
return state.DoS(100, error("CheckBlock() : stake input below minimum value"));
}
}


// ----------- swiftTX transaction scanning -----------
if (IsSporkActive(SPORK_3_SWIFTTX_BLOCK_FILTERING)) {
Expand Down Expand Up @@ -5361,6 +5377,10 @@ bool static ProcessMessage(CNode* pfrom, string strCommand, CDataStream& vRecv,
// it was the one which was commented out
int ActiveProtocol()
{
if(chainActive.Height() >= LIMIT_POS_FORK_HEIGHT)
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT2;
else

if (IsSporkActive(SPORK_19_PROTOCOL_ENFORCEMENT_5))
return MIN_PEER_PROTO_VERSION_AFTER_ENFORCEMENT_5;

Expand Down
2 changes: 1 addition & 1 deletion src/version.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
/**
* network protocol versioning
*/

//define LIMIT_POS_FORK_HEIGHT 750000 //todo we will define later
//! Current Protocol Version
static const int PROTOCOL_VERSION = 70930;

Expand Down
7 changes: 6 additions & 1 deletion src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1404,7 +1404,12 @@ bool CWallet::SelectStakeCoins(std::set<std::pair<const CWalletTx*, unsigned int
//make sure not to outrun target amount
if (nAmountSelected + out.tx->vout[out.i].nValue > nTargetAmount)
continue;


//check for minimal stake input after fork
if (chainActive.Height() > LIMIT_POS_FORK_HEIGHT) {
if (out.tx->vout[out.i].nValue < Params().StakeInputMinimal())
continue;
}
//check for min age
if (GetAdjustedTime() - out.tx->GetTxTime() < nStakeMinAge)
continue;
Expand Down