This commit is contained in:
jl777
2016-11-21 12:18:20 -03:00
parent 7a6cee3fde
commit e9f49d50a5

View File

@@ -348,7 +348,7 @@ char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
uint256 komodo_getblockhash(int32_t height)
{
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result;
uint256 hash; char params[128],*hexstr,*jsonstr; cJSON *result; uint8_t revbuf[32];
memset(&hash,0,sizeof(hash));
sprintf(params,"[%d]",height);
if ( (jsonstr= komodo_issuemethod(KMDUSERPASS,(char *)"getblockhash",params,7771)) != 0 )
@@ -358,7 +358,11 @@ uint256 komodo_getblockhash(int32_t height)
if ( (hexstr= jstr(result,(char *)"result")) != 0 )
{
if ( is_hexstr(hexstr,0) == 64 )
decode_hex((uint8_t *)&hash,32,hexstr);
{
decode_hex(revbuf,32,hexstr);
for (i=0; i<32; i++)
((uint8_t *)&hash)[i] = revbuf[31-i];
}
}
free_json(result);
}