Add [evalcode] to cclib roc

This commit is contained in:
jl777
2019-01-28 22:43:52 -11:00
parent 534c5ee516
commit 42a362165f
2 changed files with 21 additions and 6 deletions

View File

@@ -281,6 +281,7 @@ int32_t CClib_initcp(struct CCcontract_info *cp,uint8_t evalcode)
sprintf(&cp->CChexstr[i*2],"%02x",pub33[i]);
cp->CChexstr[i*2] = 0;
GetCCaddress(cp,cp->unspendableCCaddr,pk);
return(0);
}
}
return(-1);

View File

@@ -5347,25 +5347,39 @@ UniValue cclibaddress(const UniValue& params, bool fHelp)
UniValue cclibinfo(const UniValue& params, bool fHelp)
{
struct CCcontract_info *cp,C;
cp = CCinit(&C,EVAL_FIRSTUSER);
struct CCcontract_info *cp,C; uint8_t evalcode = EVAL_FIRSTUSER;
if ( fHelp || params.size() > 0 )
throw runtime_error("cclibinfo\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
if ( params.size() >= 1 )
{
evalcode = atoi(params[0].get_str().c_str());
if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER )
throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n");
}
cp = CCinit(&C,evalcode);
return(CClib_info(cp));
}
UniValue cclib(const UniValue& params, bool fHelp)
{
struct CCcontract_info *cp,C; char *method; cJSON *jsonparams;
struct CCcontract_info *cp,C; char *method; cJSON *jsonparams=0; uint8_t evalcode;
cp = CCinit(&C,EVAL_FIRSTUSER);
if ( fHelp || params.size() > 2 )
throw runtime_error("cclib method [JSON params]\n");
if ( fHelp || params.size() > 3 )
throw runtime_error("cclib method [evalcode] [JSON params]\n");
if ( ensure_CCrequirements() < 0 )
throw runtime_error("to use CC contracts, you need to launch daemon with valid -pubkey= for an address in your wallet\n");
method = (char *)params[0].get_str().c_str();
jsonparams = cJSON_Parse(params[1].get_str().c_str());
if ( params.size() >= 1 )
{
evalcode = atoi(params[1].get_str().c_str());
if ( evalcode < EVAL_FIRSTUSER || evalcode > EVAL_LASTUSER )
throw runtime_error("evalcode not between EVAL_FIRSTUSER and EVAL_LASTUSER\n");
if ( params.size() == 2 )
jsonparams = cJSON_Parse(params[2].get_str().c_str());
}
cp = CCinit(&C,evalcode);
return(CClib(cp,method,jsonparams));
}