message: Add CheckStake function
diff: @@ -652,3 +652,37 @@ void IncrementExtraNonce(CBlock* pblock, const CBlockIndex* pindexPrev, unsigned
  pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
  pblock->hashMerkleRoot = BlockMerkleRoot(*pblock);
  }
  +
  +bool CheckStake(const std::shared_ptr<const CBlock> pblock, CWallet& wallet)
  +{
  + uint256 proofHash, hashTarget;
  + uint256 hashBlock = pblock->GetHash();
  +
  + if(!pblock->IsProofOfStake())
  + return error("CheckStake() : %s is not a proof-of-stake block", hashBlock.GetHex());
  +
  + // verify hash target and signature of coinstake tx
  + CValidationState state;
  + if (!CheckProofOfStake(mapBlockIndex[pblock->hashPrevBlock], state, *pblock->vtx[1], pblock->nBits, proofHash, hashTarget))
  + return error("CheckStake() : proof-of-stake checking failed");
  +
  + //// debug print
  + 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
  + {
  + LOCK(cs_main);
  + if (pblock->hashPrevBlock != chainActive.Tip()->GetBlockHash())
  + return error("CheckStake() : generated block is stale");
  +
  + // Process this block the same as if we had received it from another node
  + CValidationState state;
  + bool fNewBlock = false;
  + if (!ProcessNewBlock(Params(), pblock, true, &fNewBlock))
  + return error("CheckStake() : ProcessBlock, block not accepted");
  + }
  +
  + return true;
  +}
  