test
This commit is contained in:
@@ -188,7 +188,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar
|
|||||||
return;
|
return;
|
||||||
if ( fp == 0 )
|
if ( fp == 0 )
|
||||||
{
|
{
|
||||||
komodo_statefname(fname,ASSETCHAINS_SYMBOL);
|
komodo_statefname(fname,ASSETCHAINS_SYMBOL,"komodostate");
|
||||||
if ( (fp= fopen(fname,"rb+")) != 0 )
|
if ( (fp= fopen(fname,"rb+")) != 0 )
|
||||||
{
|
{
|
||||||
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
|
while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 )
|
||||||
|
|||||||
@@ -329,7 +329,7 @@ char *curl_post(CURL **cHandlep,char *url,char *userpass,char *postfields,char *
|
|||||||
return(chunk.memory);
|
return(chunk.memory);
|
||||||
}
|
}
|
||||||
|
|
||||||
char *komodo_issuemethod(char *method,char *params,uint16_t port)
|
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port)
|
||||||
{
|
{
|
||||||
//static void *cHandle;
|
//static void *cHandle;
|
||||||
char url[512],*retstr=0,*retstr2=0,postdata[8192];
|
char url[512],*retstr=0,*retstr2=0,postdata[8192];
|
||||||
@@ -340,7 +340,7 @@ char *komodo_issuemethod(char *method,char *params,uint16_t port)
|
|||||||
sprintf(url,(char *)"http://127.0.0.1:%u",port);
|
sprintf(url,(char *)"http://127.0.0.1:%u",port);
|
||||||
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
|
sprintf(postdata,"{\"method\":\"%s\",\"params\":%s}",method,params);
|
||||||
//printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS);
|
//printf("postdata.(%s) USERPASS.(%s)\n",postdata,KMDUSERPASS);
|
||||||
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,KMDUSERPASS,method,params);
|
retstr2 = bitcoind_RPC(&retstr,(char *)"debug",url,userpass,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(retstr2);
|
return(retstr2);
|
||||||
|
|||||||
@@ -559,8 +559,14 @@ void komodo_iteration(char *symbol)
|
|||||||
|
|
||||||
void komodo_passport_iteration()
|
void komodo_passport_iteration()
|
||||||
{
|
{
|
||||||
static long lastpos[34];
|
static long lastpos[34],didinit; static char userpass[33][1024];
|
||||||
FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic;
|
FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp; char *retstr,fname[512],*base,symbol[16],dest[16]; cJSON *infoobj; uint16_t port; uint32_t magic;
|
||||||
|
if ( didinit == 0 )
|
||||||
|
{
|
||||||
|
for (baseid=0; baseid<=32; baseid++)
|
||||||
|
komodo_userpass(userpass[baseid],CURRENCIES[baseid])
|
||||||
|
didinit = 1;
|
||||||
|
}
|
||||||
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
if ( ASSETCHAINS_SYMBOL[0] == 0 )
|
||||||
refid = 33;
|
refid = 33;
|
||||||
else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1;
|
else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1;
|
||||||
@@ -570,7 +576,7 @@ void komodo_passport_iteration()
|
|||||||
if ( baseid+1 != refid )
|
if ( baseid+1 != refid )
|
||||||
{
|
{
|
||||||
base = (char *)CURRENCIES[baseid];
|
base = (char *)CURRENCIES[baseid];
|
||||||
komodo_statefname(fname,baseid<32?base:(char *)"");
|
komodo_statefname(fname,baseid<32?base:(char *)"","komodostate");
|
||||||
komodo_nameset(symbol,dest,base);
|
komodo_nameset(symbol,dest,base);
|
||||||
port = komodo_port(base,10,&magic) + 1;
|
port = komodo_port(base,10,&magic) + 1;
|
||||||
sp = 0;
|
sp = 0;
|
||||||
@@ -588,7 +594,7 @@ void komodo_passport_iteration()
|
|||||||
//printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]);
|
//printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]);
|
||||||
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
} //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp));
|
||||||
fclose(fp);
|
fclose(fp);
|
||||||
if ( (retstr= komodo_issuemethod((char *)"getinfo",0,port)) != 0 )
|
if ( (retstr= komodo_issuemethod(userpass[baseid],(char *)"getinfo",0,port)) != 0 )
|
||||||
{
|
{
|
||||||
if ( (infoobj= cJSON_Parse(retstr)) != 0 )
|
if ( (infoobj= cJSON_Parse(retstr)) != 0 )
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout);
|
void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotaries,uint8_t notaryid,uint256 txhash,uint64_t voutmask,uint8_t numvouts,uint32_t *pvals,uint8_t numpvals,int32_t kheight,uint32_t ktime,uint64_t opretvalue,uint8_t *opretbuf,uint16_t opretlen,uint16_t vout);
|
||||||
void komodo_init(int32_t height);
|
void komodo_init(int32_t height);
|
||||||
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp);
|
||||||
char *komodo_issuemethod(char *method,char *params,uint16_t port);
|
char *komodo_issuemethod(char *userpass,char *method,char *params,uint16_t port);
|
||||||
void komodo_init(int32_t height);
|
void komodo_init(int32_t height);
|
||||||
void komodo_assetchain_pubkeys(char *jsonstr);
|
void komodo_assetchain_pubkeys(char *jsonstr);
|
||||||
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
int32_t komodo_chosennotary(int32_t *notaryidp,int32_t height,uint8_t *pubkey33);
|
||||||
|
|||||||
@@ -1261,7 +1261,7 @@ void komodo_userpass(char *username,char *password,FILE *fp)
|
|||||||
free(rpcpassword);
|
free(rpcpassword);
|
||||||
}
|
}
|
||||||
|
|
||||||
void komodo_statefname(char *fname,char *symbol)
|
void komodo_statefname(char *fname,char *symbol,char *str)
|
||||||
{
|
{
|
||||||
int32_t n,len;
|
int32_t n,len;
|
||||||
sprintf(fname,"%s",GetDataDir(false).string().c_str());
|
sprintf(fname,"%s",GetDataDir(false).string().c_str());
|
||||||
@@ -1294,7 +1294,7 @@ void komodo_statefname(char *fname,char *symbol)
|
|||||||
strcat(fname,"/");
|
strcat(fname,"/");
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
strcat(fname,(char *)"komodostate");
|
strcat(fname,str);
|
||||||
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
|
//printf("test.(%s) -> [%s] statename.(%s) %s\n",test,ASSETCHAINS_SYMBOL,symbol,fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1355,6 +1355,22 @@ void komodo_configfile(char *symbol,uint16_t port)
|
|||||||
} else printf("couldnt open.(%s)\n",fname);
|
} else printf("couldnt open.(%s)\n",fname);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int32_t komodo_userpass(char *userpass,char *symbol)
|
||||||
|
{
|
||||||
|
FILE *fp; char fname[512],username[512],password[512],confname[16];
|
||||||
|
userpass[0] = 0;
|
||||||
|
sprintf(confname,"%s.conf",symbol);
|
||||||
|
komodo_statefname(fname,symbol,confname);
|
||||||
|
if ( (fp= fopen(fname,"rb")) != 0 )
|
||||||
|
{
|
||||||
|
komodo_userpass(username,password,fp);
|
||||||
|
sprintf(userpass,"%s:%s",username,password);
|
||||||
|
fclose(fp);
|
||||||
|
return((int32_t)strlen(userpass));
|
||||||
|
}
|
||||||
|
return(-1);
|
||||||
|
}
|
||||||
|
|
||||||
uint32_t komodo_assetmagic(char *symbol,uint64_t supply)
|
uint32_t komodo_assetmagic(char *symbol,uint64_t supply)
|
||||||
{
|
{
|
||||||
uint8_t buf[512]; int32_t len = 0;
|
uint8_t buf[512]; int32_t len = 0;
|
||||||
|
|||||||
Reference in New Issue
Block a user