From ccf895cfcf489db5d0a5aa8605c4a5f6d2ac743e Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 21 Nov 2016 10:32:13 -0300 Subject: [PATCH] test --- src/komodo_bitcoind.h | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index b57421a5d..619f7e556 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -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); }