2019-06-11 13:46:07 +02:00
|
|
|
// Copyright (c) 2014-2019 The Dash Core developers
|
2017-06-26 15:56:29 +02:00
|
|
|
// Distributed under the MIT/X11 software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef GOVERNANCE_VALIDATORS_H
|
|
|
|
#define GOVERNANCE_VALIDATORS_H
|
|
|
|
|
|
|
|
#include <string>
|
|
|
|
|
|
|
|
#include <univalue.h>
|
|
|
|
|
2018-02-27 14:39:48 +01:00
|
|
|
class CProposalValidator
|
|
|
|
{
|
|
|
|
private:
|
2018-09-28 09:56:17 +02:00
|
|
|
UniValue objJSON;
|
|
|
|
bool fJSONValid;
|
2019-02-26 11:44:43 +01:00
|
|
|
bool fAllowLegacyFormat;
|
2018-09-28 09:56:17 +02:00
|
|
|
std::string strErrorMessages;
|
2018-02-27 14:39:48 +01:00
|
|
|
|
2017-06-26 15:56:29 +02:00
|
|
|
public:
|
2019-02-26 11:44:43 +01:00
|
|
|
CProposalValidator(const std::string& strDataHexIn = std::string(), bool fAllowLegacyFormat = true);
|
2017-06-26 15:56:29 +02:00
|
|
|
|
2018-03-21 12:09:13 +01:00
|
|
|
bool Validate(bool fCheckExpiration = true);
|
2017-06-26 15:56:29 +02:00
|
|
|
|
|
|
|
const std::string& GetErrorMessages()
|
|
|
|
{
|
|
|
|
return strErrorMessages;
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
2018-02-27 14:39:48 +01:00
|
|
|
void ParseStrHexData(const std::string& strHexData);
|
|
|
|
void ParseJSONData(const std::string& strJSONData);
|
2017-06-26 15:56:29 +02:00
|
|
|
|
2018-02-27 14:39:48 +01:00
|
|
|
bool GetDataValue(const std::string& strKey, std::string& strValueRet);
|
|
|
|
bool GetDataValue(const std::string& strKey, int64_t& nValueRet);
|
|
|
|
bool GetDataValue(const std::string& strKey, double& dValueRet);
|
2017-06-26 15:56:29 +02:00
|
|
|
|
2018-02-27 14:39:48 +01:00
|
|
|
bool ValidateName();
|
2018-03-21 12:09:13 +01:00
|
|
|
bool ValidateStartEndEpoch(bool fCheckExpiration = true);
|
2018-02-27 14:39:48 +01:00
|
|
|
bool ValidatePaymentAmount();
|
|
|
|
bool ValidatePaymentAddress();
|
|
|
|
bool ValidateURL();
|
2017-06-26 15:56:29 +02:00
|
|
|
|
2018-02-27 14:39:48 +01:00
|
|
|
bool CheckURL(const std::string& strURLIn);
|
2017-06-26 15:56:29 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|