message: Add method for check of the block signature
diff: @@ -3219,6 +3219,51 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
  return true;
  }
  +bool CheckBlockSignature(const CBlock& block)
  +{
  + if (block.IsProofOfWork())
  + return block.vchBlockSig.empty();
  +
  + if (block.vchBlockSig.empty())
  + return false;
  +
  + vector<valtype> vSolutions;
  + txnouttype whichType;
  +
  + const CTxOut& txout = block.vtx[1].vout[1];
  +
  + if (!Solver(txout.scriptPubKey, whichType, vSolutions))
  + return false;
  +
  + if (whichType == TX_PUBKEY)
  + {
  + valtype& vchPubKey = vSolutions[0];
  + return CPubKey(vchPubKey).Verify(block.GetHash(), block.vchBlockSig);
  + }
  + else
  + {
  + // Block signing key also can be encoded in the nonspendable output
  + // This allows to not pollute UTXO set with useless outputs e.g. in case of multisig staking
  +
  + const CScript& script = txout.scriptPubKey;
  + CScript::const_iterator pc = script.begin();
  + opcodetype opcode;
  + valtype vchPushValue;
  +
  + if (!script.GetOp(pc, opcode, vchPushValue))
  + return false;
  + if (opcode != OP_RETURN)
  + return false;
  + if (!script.GetOp(pc, opcode, vchPushValue))
  + return false;
  + if (!IsCompressedOrUncompressedPubKey(vchPushValue))
  + return false;
  + return CPubKey(vchPushValue).Verify(block.GetHash(), block.vchBlockSig);
  + }
  +
  + return false;
  +}
  +
  bool CheckBlockHeader(const CBlockHeader& block, CValidationState& state, const Consensus::Params& consensusParams, bool fCheckPOW)
  {
  // Check proof of work matches claimed amount
  