message: wallet: CreateCoinStake guard chainActive access + few warnings fixed.
diff: @@ -2739,7 +2739,7 @@ bool CWallet::CreateCoinStake(
  // Mark coin stake transaction
  txNew.vin.clear();
  txNew.vout.clear();
  - txNew.vout.push_back(CTxOut(0, CScript()));
  + txNew.vout.emplace_back(CTxOut(0, CScript()));
  // update staker status (hash)
  pStakerStatus->SetLastTip(pindexPrev);
  @@ -2758,7 +2758,7 @@ bool CWallet::CreateCoinStake(
  stakeInput.SetPrevout((CTransaction) *out.tx, out.i);
  //new block came in, move on
  - if (chainActive.Height() != pindexPrev->nHeight) return false;
  + if (WITH_LOCK(cs_main, return chainActive.Height()) != pindexPrev->nHeight) return false;
  // Make sure the wallet is unlocked and shutdown hasn't been requested
  if (IsLocked() || ShutdownRequested()) return false;
  @@ -2784,10 +2784,8 @@ bool CWallet::CreateCoinStake(
  LogPrintf("CreateCoinStake : kernel found\n");
  nCredit += stakeInput.GetValue();
  - // Calculate reward
  - CAmount nReward;
  - nReward = GetBlockValue(chainActive.Height() + 1);
  - nCredit += nReward;
  + // Add block reward to the credit
  + nCredit += GetBlockValue(pindexPrev->nHeight + 1);
  // Create the output transaction(s)
  std::vector<CTxOut> vout;
  @@ -2820,7 +2818,7 @@ bool CWallet::CreateCoinStake(
  // Masternode payment
  FillBlockPayee(txNew, pindexPrev, true);
  - uint256 hashTxOut = txNew.GetHash();
  + const uint256& hashTxOut = txNew.GetHash();
  CTxIn in;
  if (!stakeInput.CreateTxIn(this, in, hashTxOut)) {
  LogPrintf("%s : failed to create TxIn\n", __func__);
  @@ -2840,7 +2838,7 @@ bool CWallet::CreateCoinStake(
  // Sign for PIV
  int nIn = 0;
  if (!txNew.vin[0].scriptSig.IsZerocoinSpend()) {
  - for (CTxIn txIn : txNew.vin) {
  + for (const CTxIn& txIn : txNew.vin) {
  const CWalletTx *wtx = GetWalletTx(txIn.prevout.hash);
  if (!SignSignature(*this, *wtx, txNew, nIn++, SIGHASH_ALL, true))
  return error("CreateCoinStake : failed to sign coinstake");
  