Merge pull request #1567 from dimxy/cclib-rpc-json-parse-fix

support for passing json param as object in cclib rpc
This commit is contained in:
jl777
2019-06-16 19:59:11 -11:00
committed by GitHub

View File

@@ -5564,6 +5564,8 @@ UniValue cclibinfo(const UniValue& params, bool fHelp)
UniValue cclib(const UniValue& params, bool fHelp)
{
struct CCcontract_info *cp,C; char *method,*jsonstr=0; uint8_t evalcode = EVAL_FIRSTUSER;
std::string vobjJsonSerialized;
if ( fHelp || params.size() > 3 )
throw runtime_error("cclib method [evalcode] [JSON params]\n");
if ( ASSETCHAINS_CCLIB.size() == 0 )
@@ -5583,7 +5585,12 @@ UniValue cclib(const UniValue& params, bool fHelp)
}
if ( params.size() == 3 )
{
jsonstr = (char *)params[2].get_str().c_str();
if (params[2].getType() == UniValue::VOBJ) {
vobjJsonSerialized = params[2].write(0, 0);
jsonstr = (char *)vobjJsonSerialized.c_str();
}
else // VSTR assumed
jsonstr = (char *)params[2].get_str().c_str();
//fprintf(stderr,"params.(%s %s %s)\n",params[0].get_str().c_str(),params[1].get_str().c_str(),jsonstr);
}
}