From 46ff7513444427c6ba685a617f2599f1d88917a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 25 Oct 2016 18:09:30 -0300 Subject: [PATCH] test --- src/komodo_bitcoind.h | 2 +- src/komodo_utils.h | 79 ++++++++++++++++++++++++------------------- 2 files changed, 45 insertions(+), 36 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index febca0c23..4793ec968 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -102,7 +102,7 @@ char *komodo_issuemethod(char *method,char *params) } return(retstr); } -//curl --url "http://127.0.0.1:14555" --user "user782512472:pass1476445872" --data "{\"method\":\"getinfo\",\"params\":[]}" +//curl --url "http://127.0.0.1:13033" --user "user1557335368:pass111720054" --data "{\"method\":\"getinfo\",\"params\":[]}" uint32_t komodo_txtime(uint256 hash) { diff --git a/src/komodo_utils.h b/src/komodo_utils.h index ccbf56583..b7e05eb86 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -976,41 +976,50 @@ void komodo_configfile(char *symbol,uint16_t port) } else { - rpcuser = rpcpassword = rpcport = 0; - while ( fgets(line,sizeof(line),fp) != 0 ) - { - if ( line[0] == '#' ) - continue; - //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); - if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) - rpcuser = parse_conf_line(str,(char *)"rpcuser"); - else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) - rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); - else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) - rpcport = parse_conf_line(str,(char *)"rpcport"); - } - if ( rpcuser != 0 && rpcpassword != 0 ) - { - sprintf(USERPASS,"%s:%s",rpcuser,rpcpassword); - } - if ( rpcport != 0 ) - { - if ( port != atoi(rpcport) ) - printf("port.%u mismatch (%s)\n",port,rpcport); - //if ( serverport[0] == 0 ) - // sprintf(serverport,"127.0.0.1:%s",rpcport); - free(rpcport); - } - printf("rpcuser.(%s) rpcpassword.(%s) port.(%s) USERPASS.(%s) port.%u vs %u\n",rpcuser,rpcpassword,rpcport,USERPASS,atoi(rpcport!=0?rpcport:0),port); - if ( rpcuser != 0 ) - free(rpcuser); - if ( rpcpassword != 0 ) - free(rpcpassword); fclose(fp); + strcpy(fname,GetDataDir(false).string().c_str()); +#ifdef WIN32 + while ( fname[strlen(fname)-1] != '\\' ) + fname[strlen(fname)-1] = 0; + strcat(fname,".komodo/komodo.conf"); +#else + while ( fname[strlen(fname)-1] != '/' ) + fname[strlen(fname)-1] = 0; + strcat(fname,".komodo/komodo.conf"); +#endif + if ( (fp= fopen(fname,"rb")) != 0 ) + { + rpcuser = rpcpassword = rpcport = 0; + while ( fgets(line,sizeof(line),fp) != 0 ) + { + if ( line[0] == '#' ) + continue; + //printf("line.(%s) %p %p\n",line,strstr(line,(char *)"rpcuser"),strstr(line,(char *)"rpcpassword")); + if ( (str= strstr(line,(char *)"rpcuser")) != 0 ) + rpcuser = parse_conf_line(str,(char *)"rpcuser"); + else if ( (str= strstr(line,(char *)"rpcpassword")) != 0 ) + rpcpassword = parse_conf_line(str,(char *)"rpcpassword"); + else if ( (str= strstr(line,(char *)"rpcport")) != 0 ) + rpcport = parse_conf_line(str,(char *)"rpcport"); + } + if ( rpcuser != 0 && rpcpassword != 0 ) + { + sprintf(USERPASS,"%s:%s",rpcuser,rpcpassword); + } + if ( rpcport != 0 ) + { + if ( port != atoi(rpcport) ) + printf("port.%u mismatch (%s)\n",port,rpcport); + //if ( serverport[0] == 0 ) + // sprintf(serverport,"127.0.0.1:%s",rpcport); + free(rpcport); + } + printf("rpcuser.(%s) rpcpassword.(%s) port.(%s) USERPASS.(%s) port.%u vs %u\n",rpcuser,rpcpassword,rpcport,USERPASS,atoi(rpcport!=0?rpcport:0),port); + if ( rpcuser != 0 ) + free(rpcuser); + if ( rpcpassword != 0 ) + free(rpcpassword); + fclose(fp); + } else printf("couldnt open.(%s)\n",fname); } - /*if ( (retstr= komodo_issuemethod((char *)"getinfo",0)) != 0 ) - { - printf("GETINFO.%s (%s) USERPASS.%s\n",symbol,retstr,USERPASS); - free(retstr); - }*/ }