Skip to content

Commit

Permalink
Merge pull request bitcoin#3 from dooglus/defaultcoin
Browse files Browse the repository at this point in the history
Defaultcoin
  • Loading branch information
l0rdicon committed Oct 19, 2018
2 parents 758b5f5 + 717cef3 commit d309f80
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 4 deletions.
8 changes: 5 additions & 3 deletions src/miner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,8 @@ std::unique_ptr<CBlockTemplate> BlockAssembler::CreateNewBlock(const CScript& sc
// transaction (which in most cases can be a no-op).
fIncludeWitness = IsWitnessEnabled(pindexPrev, chainparams.GetConsensus());

addPackageTxs();

nLastBlockTx = nBlockTx;
nLastBlockSize = nBlockSize;
nLastBlockWeight = nBlockWeight;
Expand Down Expand Up @@ -812,9 +814,9 @@ bool CheckStake(const std::shared_ptr<const CBlock> pblock, CWallet& wallet)
}

//// debug print
LogPrint("miner", "CheckStake() : new proof-of-stake block found \n hash: %s \nproofhash: %s \ntarget: %s\n", hashBlock.GetHex(), proofHash.GetHex(), hashTarget.GetHex());
LogPrint("miner", "%s\n", pblock->ToString());
LogPrint("miner", "out %s\n", FormatMoney(pblock->vtx[1]->GetValueOut()));
LogPrintf("CheckStake() : new proof-of-stake block found \n hash: %s \nproofhash: %s \ntarget: %s\n", hashBlock.GetHex(), proofHash.GetHex(), hashTarget.GetHex());
LogPrintf("%s\n", pblock->ToString());
LogPrintf("out %s\n", FormatMoney(pblock->vtx[1]->GetValueOut()));

// Found a solution
{
Expand Down
5 changes: 5 additions & 0 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3180,13 +3180,15 @@ bool SignBlock(std::shared_ptr<CBlock> pblock, CWallet& wallet, const CAmount& n
//unsigned int nStartTime = txCoinStake.nTime;

uint32_t nTimeBlock = nTime;
unsigned int nStartTime = GetAdjustedTime();

if(chainActive.Tip()->nHeight + 1 > Params().GetConsensus().nProtocolV2Height)
txCoinStake.nTime &= ~STAKE_TIMESTAMP_MASK;

int64_t nSearchTime = txCoinStake.nTime;
if (nSearchTime > nLastCoinStakeSearchTime)
{
LogPrintf("starting stake\n");
int64_t nSearchInterval = chainActive.Tip()->nHeight + 1 > Params().GetConsensus().nProtocolV2Height ? 1 : nSearchTime - nLastCoinStakeSearchTime;
if (wallet.CreateCoinStake(wallet, pblock->nBits, nSearchInterval, nTotalFees, nTimeBlock, txCoinStake, key))
{
Expand Down Expand Up @@ -3228,9 +3230,12 @@ bool SignBlock(std::shared_ptr<CBlock> pblock, CWallet& wallet, const CAmount& n
//LogPrint("xp", "SignBlock blockAfter %s\n", pblock->ToString());
//LogPrint("xp", "SignBlock xploited 1 %s %s %s\n", key.Sign(pblock->GetHash(), pblock->vchBlockSig), EnsureLowS(pblock->vchBlockSig), CheckHeaderPoS(*pblock, Params().GetConsensus()));
// append a signature to our block and ensure that is LowS
LogPrintf("successful stake took %lds\n", GetAdjustedTime() - nStartTime);
return key.Sign(pblock->GetHash(), pblock->vchBlockSig) &&
EnsureLowS(pblock->vchBlockSig) &&
CheckHeaderPoS(*pblock, Params().GetConsensus());
} else {
LogPrintf("found stake, but cannot use it\n");
}
}
nLastCoinStakeSearchInterval = nSearchTime - nLastCoinStakeSearchTime;
Expand Down
2 changes: 1 addition & 1 deletion src/wallet/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4559,7 +4559,7 @@ int CMerkleTx::GetDepthInMainChain(const CBlockIndex* &pindexRet) const

int CMerkleTx::GetBlocksToMaturity() const
{
if (!IsCoinBase())
if (!(IsCoinBase() || IsCoinStake()))
return 0;
return max(0, (Params().GetConsensus().nCoinbaseMaturity+1) - GetDepthInMainChain());
}
Expand Down

0 comments on commit d309f80

Please sign in to comment.