This commit is contained in:
jl777
2019-01-28 22:38:06 -11:00
parent 8860036027
commit 534c5ee516

View File

@@ -5326,21 +5326,22 @@ UniValue channelsaddress(const UniValue& params, bool fHelp)
UniValue cclibaddress(const UniValue& params, bool fHelp)
{
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey;
struct CCcontract_info *cp,C; std::vector<unsigned char> pubkey; uint8_t evalcode = EVAL_FIRSTUSER;
if ( fHelp || params.size() > 2 )
throw runtime_error("cclibaddress [evalcode] [pubkey]\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");
cp = CCinit(&C,EVAL_FIRSTUSER);
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);
if ( params.size() == 2 )
pubkey = ParseHex(params[1].get_str().c_str());
}
cp = CCinit(&C,evalcode);
if ( cp == 0 )
throw runtime_error("error creating *cp\n");
return(CCaddress(cp,(char *)"CClib",pubkey));
}