Skip to content

Commit

Permalink
Add -splitthreshold option
Browse files Browse the repository at this point in the history
  • Loading branch information
CryptoManiac committed Feb 22, 2016
1 parent f728b0b commit 944c9f3
Showing 1 changed file with 20 additions and 7 deletions.
27 changes: 20 additions & 7 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1938,7 +1938,7 @@ bool CWallet::CreateCoinStake(uint256 &hashTx, uint32_t nOut, uint32_t nGenerati
if (setCoins.empty())
return false;

bool fMaxTimeWeight = false;
bool fDontSplitCoins = false;
if (GetWeight((int64_t)wtx.nTime, (int64_t)nGenerationTime) == nStakeMaxAge)
{
// Only one output for old kernel inputs
Expand Down Expand Up @@ -1981,16 +1981,29 @@ bool CWallet::CreateCoinStake(uint256 &hashTx, uint32_t nOut, uint32_t nGenerati
vwtxPrev.push_back(pcoin->first);
}

fMaxTimeWeight = true;
fDontSplitCoins = true;
}
else
{
// Split stake input if maximum weight isn't reached yet
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));
int64_t nSplitThreshold = GetArg("-splitthreshold", nCombineThreshold);

if (fDebug && GetBoolArg("-printcoinstake"))
printf("CreateCoinStake : maximum time weight isn't reached, splitting coinstake\n");
printf("CreateCoinStake : nSplitThreshold=%" PRId64 "\n", nSplitThreshold);

if (nCredit > nSplitThreshold)
{
// Split stake input if credit is lower than combine threshold and maximum weight isn't reached yet
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));

if (fDebug && GetBoolArg("-printcoinstake"))
printf("CreateCoinStake : splitting coinstake\n");
}
else
{
txNew.vout.push_back(CTxOut(0, scriptPubKeyOut));
fDontSplitCoins = true;
}
}

// Calculate coin age reward
Expand All @@ -2004,7 +2017,7 @@ bool CWallet::CreateCoinStake(uint256 &hashTx, uint32_t nOut, uint32_t nGenerati
while (true)
{
// Set output amount
if (fMaxTimeWeight)
if (fDontSplitCoins)
txNew.vout[1].nValue = nCredit - nMinFee;
else
{
Expand Down

0 comments on commit 944c9f3

Please sign in to comment.