test
This commit is contained in:
@@ -31,6 +31,7 @@ int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *n
|
||||
int32_t NOTARIZED_HEIGHT,Num_nutxos;
|
||||
uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID;
|
||||
pthread_mutex_t komodo_mutex;
|
||||
char USERPASS[1024]; uint16_t BITCOIND_PORT = 7771;
|
||||
|
||||
#include "komodo_bitcoind.h"
|
||||
#include "komodo_interest.h"
|
||||
|
||||
@@ -88,17 +88,17 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
|
||||
return(chunk.memory);
|
||||
}
|
||||
|
||||
char *komodo_issuemethod(char *method,char *params,char *userpass)
|
||||
char *komodo_issuemethod(char *method,char *params)
|
||||
{
|
||||
static void *cHandle;
|
||||
static void *cHandle; extern char USERPASS[]; extern uint16_t BITCOIND_PORT;
|
||||
char url[512],*retstr=0,postdata[8192];
|
||||
if ( strlen(params) < sizeof(postdata)-128 )
|
||||
{
|
||||
if ( params == 0 )
|
||||
params = (char *)"[]";
|
||||
sprintf(url,(char *)"http://127.0.0.1:7771");
|
||||
sprintf(url,(char *)"http://127.0.0.1:%u",port);
|
||||
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
|
||||
retstr = curl_post(&cHandle,url,userpass,postdata,0,0,0,0);
|
||||
retstr = curl_post(&cHandle,url,USERPASS,postdata,0,0,0,0);
|
||||
}
|
||||
return(retstr);
|
||||
}
|
||||
|
||||
@@ -907,11 +907,40 @@ int32_t komodo_opreturnscript(uint8_t *script,uint8_t type,uint8_t *opret,int32_
|
||||
return(opretlen + offset);
|
||||
}
|
||||
|
||||
long _stripwhite(char *buf,int accept)
|
||||
{
|
||||
int32_t i,j,c;
|
||||
if ( buf == 0 || buf[0] == 0 )
|
||||
return(0);
|
||||
for (i=j=0; buf[i]!=0; i++)
|
||||
{
|
||||
buf[j] = c = buf[i];
|
||||
if ( c == accept || (c != ' ' && c != '\n' && c != '\r' && c != '\t' && c != '\b') )
|
||||
j++;
|
||||
}
|
||||
buf[j] = 0;
|
||||
return(j);
|
||||
}
|
||||
|
||||
char *parse_conf_line(char *line,char *field)
|
||||
{
|
||||
line += strlen(field);
|
||||
for (; *line!='='&&*line!=0; line++)
|
||||
break;
|
||||
if ( *line == 0 )
|
||||
return(0);
|
||||
if ( *line == '=' )
|
||||
line++;
|
||||
_stripwhite(line,0);
|
||||
return(clonestr(line));
|
||||
}
|
||||
|
||||
void komodo_configfile(char *symbol,uint16_t port)
|
||||
{
|
||||
FILE *fp; char fname[512],buf[128];
|
||||
FILE *fp; char fname[512],buf[128],line[4096],*rpcuser,*rpcpassword,*rpcport,*retstr;
|
||||
srand((uint32_t)time(NULL));
|
||||
sprintf(buf,"%s.conf",symbol);
|
||||
BITCOIND_PORT = port;
|
||||
#ifdef WIN32
|
||||
sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf);
|
||||
#else
|
||||
@@ -926,4 +955,42 @@ void komodo_configfile(char *symbol,uint16_t port)
|
||||
printf("Created (%s)\n",fname);
|
||||
}
|
||||
}
|
||||
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,"rpcuser"),strstr(line,"rpcpassword"));
|
||||
if ( (str= strstr(line,"rpcuser")) != 0 )
|
||||
rpcuser = parse_conf_line(str,"rpcuser");
|
||||
else if ( (str= strstr(line,"rpcpassword")) != 0 )
|
||||
rpcpassword = parse_conf_line(str,"rpcpassword");
|
||||
else if ( (str= strstr(line,"rpcport")) != 0 )
|
||||
rpcport = parse_conf_line(str,"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);
|
||||
}
|
||||
if ( rpcuser != 0 )
|
||||
free(rpcuser);
|
||||
if ( rpcpassword != 0 )
|
||||
free(rpcpassword);
|
||||
fclose(fp);
|
||||
}
|
||||
if ( (retstr= komodo_issuemethod("getinfo",0)) != 0 )
|
||||
{
|
||||
printf("GETINFO.%s (%s)\n",symbol,retstr);
|
||||
free(retstr);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user