Bitcoin Forum

Alternate cryptocurrencies => Altcoin Discussion => Topic started by: bumbacoin on October 09, 2016, 05:38:56 AM



Title: how to limit wallet from only staking certain age coins
Post by: bumbacoin on October 09, 2016, 05:38:56 AM
this is specifically related to CUBE but I can see uses beyond this particular coin, i wasnt sure where to put such a question (oops i meant to put this in development and technical discussion ).


currently CUBE can return negative stakes if coinage of staked coins is less than a certain value, just wondering how to build a client that would only try to stake inputs of a certain age.

it occurs to me that the simplest way would be modify the minimum stake age, the question is what format should the code be in to make this happen.

here is the code giving the negative stake
https://github.com/iGotSpots/DigiCube/blob/master/src/main.cpp#L995
Code:
 	if (nHeight > 1020000) {
nSubsidy = nVariableStakeRate * nCoinAge * 33 / (365 * 33 + 8);
nSquish = nSubsidy / 1000000;
if (nSquish > nMaxReward) {
nSubsidy = nMaxReward * COIN;
}
if (nCoinAge < nHeight * 2) {
nSubsidy = (nCoinAge - (nCoinAge * 1.25)) * COIN;
}
}


and STAKE_MIN_AGE is declared
https://github.com/iGotSpots/DigiCube/blob/master/src/main.h#L46
Code:
static const int STAKE_MIN_AGE = 60 * 60 * 24;


seemingly then if you were to set the min age as, (60*60*24)+(nHeight*2) this would prevent the wallet from attempting to stake coins less than required age for positive stakes??

seems this is the line to change
https://github.com/iGotSpots/DigiCube/blob/master/src/main.cpp#L37
Code:
unsigned int nStakeMinAge = STAKE_MIN_AGE;

to

Code:
int nStakeMinAge(int nStakeMinAge, int64 nCoinAge)
{
     nPositiveStakeAge = nStakeMinAge + (nHeight * 2);
     return nPositiveStakeAge;
}

??


note, by changing this particular variable seems the least intrusive way to do it.
also reducing the load of staking inputs.


Title: Re: how to limit wallet from only staking certain age coins
Post by: bumbacoin on October 09, 2016, 05:55:35 AM
it's plausible that it'd be best to create another variable for the stake miner to use, while the subsidy creation would use original.

i'm unsure whether changing the min_stake_age as above would invalidate -ve stakes from other miners.


..

so instead changing this
https://github.com/iGotSpots/DigiCube/blob/ced6fd7627fce29b08d2f1d00564e977e2cc0f9c/src/kernel.cpp#L318

Code:
    if (nTimeBlockFrom + nStakeMinAge > nTimeTx) // Min age requirement
        return error("CheckStakeKernelHash() : min age violation");

then only the miner would reject any stakes that are too young,



Title: Re: how to limit wallet from only staking certain age coins
Post by: iGotSpots on October 09, 2016, 07:05:01 AM
You are better off making more local rules with wallet files


Title: Re: how to limit wallet from only staking certain age coins
Post by: bumbacoin on October 10, 2016, 11:29:59 AM
You are better off making more local rules with wallet files

seems that modding the miner would be far simpler than changing wallet rules.
i canna see anything that would lend itself to easy modification.