mirror of
https://github.com/dashpay/dash.git
synced 2024-12-29 13:59:06 +01:00
fcd3b4fd49
* add flag to allow legacy proposal format * add proposal validator ctor flag for legacy format * add test for legacy proposal format disabled
48 lines
1.2 KiB
C++
48 lines
1.2 KiB
C++
// Copyright (c) 2014-2018 The Dash Core developers
|
|
// 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>
|
|
|
|
class CProposalValidator
|
|
{
|
|
private:
|
|
UniValue objJSON;
|
|
bool fJSONValid;
|
|
bool fAllowLegacyFormat;
|
|
std::string strErrorMessages;
|
|
|
|
public:
|
|
CProposalValidator(const std::string& strDataHexIn = std::string(), bool fAllowLegacyFormat = true);
|
|
|
|
bool Validate(bool fCheckExpiration = true);
|
|
|
|
const std::string& GetErrorMessages()
|
|
{
|
|
return strErrorMessages;
|
|
}
|
|
|
|
private:
|
|
void ParseStrHexData(const std::string& strHexData);
|
|
void ParseJSONData(const std::string& strJSONData);
|
|
|
|
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);
|
|
|
|
bool ValidateName();
|
|
bool ValidateStartEndEpoch(bool fCheckExpiration = true);
|
|
bool ValidatePaymentAmount();
|
|
bool ValidatePaymentAddress();
|
|
bool ValidateURL();
|
|
|
|
bool CheckURL(const std::string& strURLIn);
|
|
};
|
|
|
|
#endif
|