added oracle data type validation
This commit is contained in:
@@ -5733,6 +5733,24 @@ UniValue oraclescreate(const UniValue& params, bool fHelp)
|
||||
ERR_RESULT("oracles format must be <= 4096 characters");
|
||||
return(result);
|
||||
}
|
||||
// list of oracle valid formats from oracles.cpp -> oracle_format
|
||||
const UniValue valid_formats[13] = {"s","S","d","D","c","C","t","T","i","I","l","L","h"};
|
||||
const UniValue header_type = "Ihh";
|
||||
// checking if oracle data type is valid
|
||||
bool is_valid_format = false;
|
||||
for ( int i = 0; i < 13; ++i ) {
|
||||
if ( valid_formats[i].get_str() == format ) {
|
||||
is_valid_format = true;
|
||||
}
|
||||
}
|
||||
// additional check for special Ihh data type
|
||||
if ( format == header_type.get_str() ) {
|
||||
is_valid_format = true;
|
||||
}
|
||||
if ( !is_valid_format ) {
|
||||
ERR_RESULT("oracles format not valid");
|
||||
return(result);
|
||||
}
|
||||
hex = OracleCreate(0,name,description,format);
|
||||
if ( hex.size() > 0 )
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user