diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 285c747cc..27611ab3b 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -92,6 +92,8 @@ bool AppInit(int argc, char* argv[]) try { + void komodo_args(); + komodo_args(); if (!boost::filesystem::is_directory(GetDataDir(false))) { fprintf(stderr, "Error: Specified data directory \"%s\" does not exist.\n", mapArgs["-datadir"].c_str()); @@ -114,7 +116,15 @@ bool AppInit(int argc, char* argv[]) if ( strlen(NOTARY_PUBKEY.c_str()) == 66 ) USE_EXTERNAL_PUBKEY = 1; fprintf(stderr,"IS_KOMODO_NOTARY %d %s\n",IS_KOMODO_NOTARY,NOTARY_PUBKEY.c_str()); - + char *dirname; + while ( (dirname= (char *)GetDataDir(false).string().c_str()) == 0 || dirname[0] == 0 ) + { + fprintf(stderr,"waiting for datadir\n"); + sleep(3); + } + fprintf(stderr,"Got datadir.(%s)\n",dirname); + komodo_configfile(ASSETCHAINS_SYMBOL,ASSETCHAINS_PORT + 1); + // Command-line RPC bool fCommandLine = false; for (int i = 1; i < argc; i++) diff --git a/src/komodo.h b/src/komodo.h index b348f70e0..e642f02f4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -28,7 +28,15 @@ void komodo_init(); int32_t komodo_notarizeddata(int32_t nHeight,uint256 *notarized_hashp,uint256 *notarized_desttxidp); char *komodo_issuemethod(char *method,char *params,uint16_t port); -int32_t ASSETCHAINS_SHORTFLAG,NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000; +int32_t ASSETCHAINS_SHORTFLAG; +char ASSETCHAINS_SYMBOL[16]; +uint16_t ASSETCHAINS_PORT = 8777; +uint32_t ASSETCHAIN_INIT = 0; +uint32_t ASSETCHAINS_MAGIC = 2387029918; +uint32_t ASSETCHAINS_TIMESTAMP = 1475772963; +uint64_t ASSETCHAINS_SUPPLY = 1000000; + +int32_t NOTARIZED_HEIGHT,Num_nutxos,KMDHEIGHT = 43000; uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; pthread_mutex_t komodo_mutex; uint32_t KOMODO_INITDONE; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 36c5a166c..1331b57c4 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1086,89 +1086,6 @@ void OS_randombytes(unsigned char *x,long xlen) } } -void komodo_userpass(char *username,char *password,FILE *fp) -{ - char *rpcuser,*rpcpassword,*str,line[8192]; - rpcuser = rpcpassword = 0; - username[0] = password[0] = 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"); - } - if ( rpcuser != 0 && rpcpassword != 0 ) - { - strcpy(username,rpcuser); - strcpy(password,rpcpassword); - } - //printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port); - if ( rpcuser != 0 ) - free(rpcuser); - if ( rpcpassword != 0 ) - free(rpcpassword); -} - -void komodo_configfile(char *symbol,uint16_t port) -{ - static char myusername[512],mypassword[8192]; - FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i; - r = (uint32_t)time(NULL); - r2 = OS_milliseconds(); - memcpy(buf,&r,sizeof(r)); - memcpy(&buf[sizeof(r)],&r2,sizeof(r2)); - memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol)); - crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol))); - OS_randombytes(buf2,sizeof(buf2)); - for (i=0; iinitflag == 0 ) @@ -1282,3 +1199,114 @@ void iguana_initQ(queue_t *Q,char *name) if ( (item= queue_dequeue(Q)) != 0 ) free(item); } + +void komodo_userpass(char *username,char *password,FILE *fp) +{ + char *rpcuser,*rpcpassword,*str,line[8192]; + rpcuser = rpcpassword = 0; + username[0] = password[0] = 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"); + } + if ( rpcuser != 0 && rpcpassword != 0 ) + { + strcpy(username,rpcuser); + strcpy(password,rpcpassword); + } + //printf("rpcuser.(%s) rpcpassword.(%s) KMDUSERPASS.(%s) %u\n",rpcuser,rpcpassword,KMDUSERPASS,port); + if ( rpcuser != 0 ) + free(rpcuser); + if ( rpcpassword != 0 ) + free(rpcpassword); +} + +void komodo_configfile(char *symbol,uint16_t port) +{ + static char myusername[512],mypassword[8192]; + FILE *fp; uint8_t buf2[512]; char fname[512],buf[128],username[512],password[8192]; uint32_t crc,r,r2,i; + r = (uint32_t)time(NULL); + r2 = OS_milliseconds(); + memcpy(buf,&r,sizeof(r)); + memcpy(&buf[sizeof(r)],&r2,sizeof(r2)); + memcpy(&buf[sizeof(r)+sizeof(r2)],symbol,strlen(symbol)); + crc = calc_crc32(0,(uint8_t *)buf,(int32_t)(sizeof(r)+sizeof(r2)+strlen(symbol))); + OS_randombytes(buf2,sizeof(buf2)); + for (i=0; i