This commit is contained in:
jl777
2016-11-21 10:32:13 -03:00
parent cfb7d1c275
commit ccf895cfcf

View File

@@ -348,13 +348,20 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
uint256 komodo_getblockhash(int32_t height)
{
uint256 hash; char params[128],*hexstr;
uint256 hash; char params[128],*hexstr,*jsonstr;
memset(&hash,0,sizeof(hash));
sprintf(params,"[%d]",height);
if ( (hexstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 )
if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 )
{
if ( is_hexstr(hexstr,0) == 64 )
decode_hex((uint8_t *)&hash,32,hexstr);
if ( (result= cJSON_Parse(jsonstr)) != 0 )
{
if ( (hexstr= jstr(result,"result")) != 0 )
{
if ( is_hexstr(hexstr,0) == 64 )
decode_hex((uint8_t *)&hash,32,hexstr);
}
free_json(result);
}
printf("KMD hash.%d (%s)\n",height,hexstr);
free(hexstr);
}