diff --git a/.gitignore b/.gitignore index d7f6bfab7..2e7656246 100755 --- a/.gitignore +++ b/.gitignore @@ -37,3 +37,33 @@ iguana/confs/BTC_hdrs.txt deprecated/.DS_Store .DS_Store + +*.pbxproj + +iguana/tmp/.tmpmarker + +iguana/SVM/rawfeatures/.tmpmarker + +iguana/DB/.tmpmarker + +iguana/DB/TRANSACTIONS/.tmpmarker + +iguana/DB/purgeable/.tmpmarker + +iguana/DB/purgeable/BTCD/.tmpmarker + +iguana/DB/purgeable/BTC/.tmpmarker + +iguana/DB/ECB/.tmpmarker + +iguana/genesis/.tmpmarker + +iguana/help/.tmpmarker + +iguana/SVM/.tmpmarker + +iguana/SVM/models/.tmpmarker + +SuperNET.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/xcschememanagement.plist + +SuperNET.xcodeproj/xcuserdata/mac.xcuserdatad/xcschemes/SuperNET.xcscheme diff --git a/basilisk/basilisk.c b/basilisk/basilisk.c index b300439b3..6edaa45ae 100755 --- a/basilisk/basilisk.c +++ b/basilisk/basilisk.c @@ -265,6 +265,7 @@ int32_t basilisk_sendcmd(struct supernet_info *myinfo,char *destipaddr,char *typ } if ( s == n && valid == 1 && (destipaddr == 0 || strcmp(addr->ipaddr,destipaddr) == 0) ) { + val = 0; //fprintf(stderr,">>> (%s).%u ",addr->ipaddr,coin->chain->portp2p); //printf("n.%d/fanout.%d i.%d l.%d [%s].tag%u send %s [%x] datalen.%d addr->supernet.%u basilisk.%u to (%s).%d destip.%s\n",n,fanout,i,l,cmd,*(uint32_t *)data,type,*(int32_t *)&data[datalen-4],datalen,addr->supernet,addr->basilisk,addr->ipaddr,addr->A.port,destipaddr!=0?destipaddr:"broadcast"); if ( encryptflag != 0 && bits256_nonz(addr->pubkey) != 0 ) @@ -462,7 +463,7 @@ char *basilisk_standardservice(char *CMD,struct supernet_info *myinfo,void *_add } ptr->finished = OS_milliseconds() + 10000; } - if ( 0 && strcmp("MSG",CMD) == 0 ) + if ( (0) && strcmp("MSG",CMD) == 0 ) printf("%s.(%s) -> (%s)\n",CMD,jprint(valsobj,0),retstr!=0?retstr:""); return(retstr); } @@ -793,10 +794,10 @@ int32_t basilisk_p2pQ_process(struct supernet_info *myinfo,int32_t maxiters) else { len += iguana_rwnum(0,ptr->data,sizeof(basilisktag),&basilisktag); - if ( 0 && myinfo->IAMLP == 0 ) + if ( (0) && myinfo->IAMLP == 0 ) printf("RELAYID.%d ->received.%d basilisk_p2p.(%s) from %s tag.%u\n",myinfo->NOTARY.RELAYID,ptr->datalen,ptr->type,senderip,basilisktag); basilisk_msgprocess(myinfo,ptr->addr,ptr->ipbits,ptr->type,basilisktag,&ptr->data[len],ptr->datalen - len); - if ( 0 && myinfo->IAMLP == 0 ) + if ( (0) && myinfo->IAMLP == 0 ) printf("processed.%s from %s\n",ptr->type,senderip); } free(ptr); diff --git a/basilisk/basilisk_DEX.c b/basilisk/basilisk_DEX.c index a126f20df..607d32099 100755 --- a/basilisk/basilisk_DEX.c +++ b/basilisk/basilisk_DEX.c @@ -681,7 +681,7 @@ HASH_ARRAY_STRING(InstantDEX,request,hash,vals,hexstr) } else printf("error creating request\n"); if ( datalen > 0 ) { - uint32_t msgid,crc,crcs[2],numiters = 0; uint8_t buf[4096]; + uint32_t msgid,crc=0,crcs[2],numiters = 0; uint8_t buf[4096]; memset(hash.bytes,0,sizeof(hash)); msgid = (uint32_t)time(NULL); DEX_channel = 'D' + ((uint32_t)'E' << 8) + ((uint32_t)'X' << 16); diff --git a/basilisk/basilisk_MSG.c b/basilisk/basilisk_MSG.c index b7625b147..e80e37f73 100755 --- a/basilisk/basilisk_MSG.c +++ b/basilisk/basilisk_MSG.c @@ -538,7 +538,7 @@ uint32_t basilisk_crcrecv(struct supernet_info *myinfo,int32_t width,uint8_t *ve uint32_t basilisk_crcsend(struct supernet_info *myinfo,int32_t width,uint8_t *verifybuf,int32_t maxlen,bits256 srchash,bits256 desthash,uint32_t channel,uint32_t msgbits,uint8_t *data,int32_t datalen,uint32_t crcs[2]) { - uint32_t crc; int32_t recvlen; + uint32_t crc; int32_t recvlen=0; if ( crcs != 0 ) { crc = calc_crc32(0,data,datalen); diff --git a/basilisk/basilisk_ping.c b/basilisk/basilisk_ping.c index f5e6c30c7..7533cd2cd 100755 --- a/basilisk/basilisk_ping.c +++ b/basilisk/basilisk_ping.c @@ -107,7 +107,7 @@ int32_t basilisk_ping_genvirts(struct supernet_info *myinfo,uint8_t *data,int32_ int32_t basilisk_ping_processMSG(struct supernet_info *myinfo,uint32_t senderipbits,uint8_t *data,int32_t datalen) { - int32_t i,msglen,len=0; uint8_t num,keylen,*message,*key; uint32_t duration; + int32_t i,msglen=0,len=0; uint8_t num,keylen,*message,*key; uint32_t duration; if ( (num= data[len++]) > 0 ) { //printf("processMSG num.%d datalen.%d\n",num,datalen); diff --git a/basilisk/basilisk_swap.c b/basilisk/basilisk_swap.c index 62ca30150..5b15e6420 100755 --- a/basilisk/basilisk_swap.c +++ b/basilisk/basilisk_swap.c @@ -555,6 +555,7 @@ int32_t basilisk_bobpayment_reclaim(struct supernet_info *myinfo,struct basilisk int32_t basilisk_verify_bobpaid(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) { uint8_t userdata[512]; int32_t i,retval,len = 0; bits256 revAm; struct basilisk_swap *swap = ptr; + memset(revAm.bytes,0,sizeof(revAm)); if ( basilisk_rawtx_spendscript(myinfo,swap,swap->bobcoin->blocks.hwmchain.height,&swap->bobpayment,0,data,datalen,0) == 0 ) { for (i=0; i<32; i++) @@ -838,6 +839,7 @@ int32_t basilisk_bobscripts_set(struct supernet_info *myinfo,struct basilisk_swa int32_t basilisk_verify_privi(struct supernet_info *myinfo,void *ptr,uint8_t *data,int32_t datalen) { int32_t j,wrongfirstbyte,len = 0; bits256 privkey,pubi; char str[65],str2[65]; uint8_t secret160[20],pubkey33[33]; uint64_t txid; struct basilisk_swap *swap = ptr; + memset(privkey.bytes,0,sizeof(privkey)); if ( datalen == sizeof(bits256) ) { for (j=0; j<32; j++) @@ -902,6 +904,7 @@ uint32_t basilisk_swapsend(struct supernet_info *myinfo,struct basilisk_swap *sw int32_t basilisk_priviextract(struct supernet_info *myinfo,struct iguana_info *coin,char *name,bits256 *destp,uint8_t secret160[20],bits256 srctxid,int32_t srcvout) { bits256 txid,privkey; char str[65]; int32_t i,vini,scriptlen; uint8_t rmd160[20],scriptsig[IGUANA_MAXSCRIPTSIZE]; + memset(privkey.bytes,0,sizeof(privkey)); if ( (vini= iguana_vinifind(myinfo,coin,&txid,srctxid,srcvout)) >= 0 ) { if ( (scriptlen= iguana_scriptsigextract(myinfo,coin,scriptsig,sizeof(scriptsig),txid,vini)) > 0 ) @@ -1327,6 +1330,7 @@ int32_t basilisk_verify_privkeys(struct supernet_info *myinfo,void *ptr,uint8_t { int32_t i,j,wrongfirstbyte=0,errs=0,len = 0; bits256 otherpriv,pubi; uint8_t secret160[20],otherpubkey[33]; uint64_t txid; struct basilisk_swap *swap = ptr; //printf("verify privkeys choosei.%d otherchoosei.%d datalen.%d vs %d\n",swap->choosei,swap->otherchoosei,datalen,(int32_t)sizeof(swap->privkeys)+20+32); + memset(otherpriv.bytes,0,sizeof(otherpriv)); if ( swap->I.cutverified == 0 && swap->I.otherchoosei >= 0 && datalen == sizeof(swap->privkeys)+20+2*32 ) { for (i=errs=0; iprivkeys)/sizeof(*swap->privkeys); i++) diff --git a/basilisk/basilisk_tradebot.c b/basilisk/basilisk_tradebot.c index 5a8e9d3fb..c182df5b4 100755 --- a/basilisk/basilisk_tradebot.c +++ b/basilisk/basilisk_tradebot.c @@ -374,6 +374,7 @@ double basilisk_process_results(struct supernet_info *myinfo,struct basilisk_req { cJSON *array,*item; uint8_t *hexdata,*allocptr,hexspace[32768]; char *hexstr; int32_t i,hexlen,n,m,nonz; struct basilisk_request tmpR,R,refR,list[BASILISK_MAXRELAYS]; double metric=0.; memset(&refR,0,sizeof(refR)); + memset(&R,0,sizeof(R)); //printf("process.(%s)\n",jprint(retjson,0)); if ( (array= jarray(&n,retjson,"messages")) != 0 ) { diff --git a/basilisk/tradebots_SVM.h b/basilisk/tradebots_SVM.h index 44165de51..a7a0b7d3b 100755 --- a/basilisk/tradebots_SVM.h +++ b/basilisk/tradebots_SVM.h @@ -332,7 +332,7 @@ static inline double validate_ocas_model(register struct ocas_vars *vars,registe { register svmtype *features; register double y,pred,perc,answer=0.,feature; - register int i,j,pos,neg,good,bad,oldcuts,training_errors,weekind,nonz,posA,negA; + register int i,j,pos,neg,good,bad,oldcuts,training_errors,weekind,nonz=0,posA,negA; for (i=pos=neg=good=bad=oldcuts=training_errors=posA=negA=0; inumfeatures) > MAX_OCAS_FEATURES ) { diff --git a/basilisk/tradebots_liquidity.c b/basilisk/tradebots_liquidity.c index 2618e6ef7..1bf50a4b5 100755 --- a/basilisk/tradebots_liquidity.c +++ b/basilisk/tradebots_liquidity.c @@ -309,8 +309,8 @@ int32_t tradebots_calcpreds(float *RTpreds,struct tradebot_arbpair *pair,double void tradebots_calcanswers(struct tradebot_arbpair *pair) { double highbid,lowask,futurebid,futureask,ave,vol,bidaves[TRADEBOTS_NUMDECAYS],askaves[TRADEBOTS_NUMDECAYS],bidslopes[TRADEBOTS_NUMDECAYS],askslopes[TRADEBOTS_NUMDECAYS]; - float rawfeatures[sizeof(pair->rawfeatures)/sizeof(*pair->rawfeatures)],futuremin,futuremax,minval,maxval,*hblas = 0; - uint32_t timestamp,firsttime = 0; long fpos,savepos; int32_t flag,i,iter,j,ind,maxi; + float rawfeatures[sizeof(pair->rawfeatures)/sizeof(*pair->rawfeatures)],futuremin=0,futuremax=0,minval=0,maxval=0,*hblas = 0; + uint32_t timestamp,firsttime = 0; long fpos,savepos; int32_t flag,i,iter,j,ind,maxi=0; OCAS_PLUS_INF = _OCAS_PLUS_INF; OCAS_NEG_INF = -_OCAS_PLUS_INF; if ( pair->fp != 0 ) { @@ -1143,7 +1143,7 @@ double tradebot_liquidity_active(struct supernet_info *myinfo,double *refpricep, void tradebots_processprices(struct supernet_info *myinfo,struct exchange_info *exchange,char *base,char *rel,struct exchange_quote *bidasks,int32_t numbids,int32_t numasks) { - double price,profitmargin,volume; struct tradebot_arbpair *pair; + double price,profitmargin=0.,volume; struct tradebot_arbpair *pair; if ( strcmp(rel,"NXT") == 0 && strcmp(base,"BTC") != 0 && (base= NXT_assetnamefind(base)) == 0 ) { //printf("reject %s %s/%s\n",exchange,base,rel); diff --git a/crypto777/OS_portable.c b/crypto777/OS_portable.c index 7f614b816..3b9c4d271 100755 --- a/crypto777/OS_portable.c +++ b/crypto777/OS_portable.c @@ -48,7 +48,7 @@ void OS_portable_randombytes(unsigned char *x,long xlen) sleep(1); continue; } - if ( 0 ) + if ( (0) ) { int32_t j; for (j=0; j datenum + number of seconds { - struct tm tm,*ptr; int32_t datenum; uint32_t checktime; char buf[64]; struct tai t; struct taitime ct; + struct tai t; struct taitime ct; if ( 1 ) { *tp = t = utc2tai((uint32_t)timestamp); @@ -560,8 +560,9 @@ int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // g *secondsp = (ct.hour*3600 + ct.minute*60 + ct.second); return(calc_datenum(ct.date.year,ct.date.month,ct.date.day)); } - else + /*else { + struct tm tm,*ptr; int32_t datenum; uint32_t checktime; char buf[64]; if ( (ptr= gmtime(×tamp)) != 0 ) tm = *ptr;; strftime(buf,sizeof(buf), "%Y-%m-%dT%H:%M:%SZ",&tm); //printf("%s\n",buf); @@ -572,7 +573,7 @@ int32_t OS_conv_unixtime(struct tai *tp,int32_t *secondsp,time_t timestamp) // g return(-1); } return(datenum); - } + }*/ } int32_t conv_date(int32_t *secondsp,char *date) diff --git a/crypto777/SaM.c b/crypto777/SaM.c index bfc97df59..e82802cea 100755 --- a/crypto777/SaM.c +++ b/crypto777/SaM.c @@ -285,7 +285,7 @@ int32_t SaM_test() memset(histo,0,sizeof(histo)); for (i=0; i<5; i++) { - if ( 0 && (i % 100) == 99 ) + if ( (0) && (i % 100) == 99 ) { for (j=0; j<32; j++) seed.bytes[j] = rand() >> 8; @@ -340,6 +340,7 @@ bits384 SaM_encrypt(uint8_t *dest,uint8_t *src,int32_t len,bits384 password,uint { bits384 xorpad; int32_t i; struct SaM_info XORpad; SaM_Initialize(&XORpad), SaM_Absorb(&XORpad,password.bytes,sizeof(password),(void *)×tamp,sizeof(timestamp)); + memset(xorpad.bytes,0,sizeof(xorpad)); while ( len >= 0 ) { SaM_emit(&XORpad); diff --git a/crypto777/bitcoind_RPC.c b/crypto777/bitcoind_RPC.c index 71a1b437c..0c30e8a27 100755 --- a/crypto777/bitcoind_RPC.c +++ b/crypto777/bitcoind_RPC.c @@ -138,7 +138,7 @@ char *bitcoind_RPC(char **retstrp,char *debugstr,char *url,char *userpass,char * else specialcase = 0; if ( url[0] == 0 ) strcpy(url,"http://127.0.0.1:7776"); - if ( specialcase != 0 && 0 ) + if ( specialcase != 0 && (0) ) printf("<<<<<<<<<<< bitcoind_RPC: debug.(%s) url.(%s) command.(%s) params.(%s)\n",debugstr,url,command,params); try_again: if ( retstrp != 0 ) @@ -235,7 +235,7 @@ try_again: } else { - if ( 0 && specialcase != 0 ) + if ( (0) && specialcase != 0 ) fprintf(stderr,"<<<<<<<<<<< bitcoind_RPC: BTCD.(%s) -> (%s)\n",params,s.ptr); count2++; elapsedsum2 += (OS_milliseconds() - starttime); @@ -244,9 +244,9 @@ try_again: return(s.ptr); } } - printf("bitcoind_RPC: impossible case\n"); - free(s.ptr); - return(0); + //printf("bitcoind_RPC: impossible case\n"); + //free(s.ptr); + //return(0); } /************************************************************************ diff --git a/crypto777/iguana_OS.c b/crypto777/iguana_OS.c index cbc4e0c87..8bd55e0d1 100755 --- a/crypto777/iguana_OS.c +++ b/crypto777/iguana_OS.c @@ -594,7 +594,7 @@ void OS_remove_directory(char *dirname) void OS_ensure_directory(char *dirname) { FILE *fp; int32_t retval; char fname[512]; - if ( 0 && OS_removefile(dirname,0) < 0 ) + if ( (0) && OS_removefile(dirname,0) < 0 ) { sprintf(fname,"tmp/%d",rand()); OS_renamefile(dirname,fname); diff --git a/crypto777/iguana_utils.c b/crypto777/iguana_utils.c index cc058efd1..a0fe60be5 100755 --- a/crypto777/iguana_utils.c +++ b/crypto777/iguana_utils.c @@ -182,7 +182,7 @@ void calc_OP_HASH160(char hexstr[41],uint8_t rmd160[20],char *pubkey) } decode_hex(buf,len,pubkey); calc_rmd160_sha256(rmd160,buf,len); - if ( 0 ) + if ( (0) ) { int i; for (i=0; i<20; i++) @@ -436,9 +436,9 @@ char *clonestr(char *str) if ( str == 0 || str[0] == 0 ) { printf("warning cloning nullstr.%p\n",str); -#ifdef __APPLE__ - while ( 1 ) sleep(1); -#endif +//#ifdef __APPLE__ +// while ( 1 ) sleep(1); +//#endif str = (char *)""; } clone = (char *)malloc(strlen(str)+16); diff --git a/crypto777/inet.c b/crypto777/inet.c index 837d9d2e0..0809b96c6 100755 --- a/crypto777/inet.c +++ b/crypto777/inet.c @@ -373,7 +373,7 @@ uint64_t _calc_ipbits(char *ip_port) port = parse_ipaddr(ipaddr,ip_port); memset(&addr,0,sizeof(addr)); portable_pton(ip_port[0] == '[' ? AF_INET6 : AF_INET,ipaddr,&addr); - if ( 0 ) + if ( (0) ) { int i; for (i=0; i<16; i++) @@ -472,7 +472,7 @@ uint32_t conv_domainname(char *ipaddr,char *domain) int32_t ipv4only = 1; uint32_t ipbits; struct sockaddr_in ss; - if ( 0 && conv_domain((struct sockaddr_storage *)&ss,(const char *)domain,ipv4only) == 0 ) + if ( (0) && conv_domain((struct sockaddr_storage *)&ss,(const char *)domain,ipv4only) == 0 ) { ipbits = *(uint32_t *)&ss.sin_addr; expand_ipbits(ipaddr,ipbits); diff --git a/crypto777/ramcoder.c b/crypto777/ramcoder.c index 86760289f..ea1076736 100755 --- a/crypto777/ramcoder.c +++ b/crypto777/ramcoder.c @@ -437,7 +437,7 @@ int32_t ramcoder_compress(uint8_t *bits,int32_t maxlen,uint8_t *data,int32_t dat if ( ramcoder_encoder(0,1,data,datalen,hp,0,&seed) < 0 ) return(-1); numbits = hp->bitoffset; - if ( 0 ) + if ( (0) ) { void *malloc(size_t); void free(void *); int32_t i,checklen; uint8_t *checkbuf; diff --git a/datachain/datachain.c b/datachain/datachain.c index 9922e3f78..4ce46416d 100755 --- a/datachain/datachain.c +++ b/datachain/datachain.c @@ -320,16 +320,19 @@ void datachain_update_spend(struct supernet_info *myinfo,int32_t ordered,struct int64_t datachain_update(struct supernet_info *myinfo,int32_t ordered,struct iguana_info *coin,uint32_t timestamp,struct iguana_bundle *bp,uint8_t rmd160[20],int64_t crypto777_payment,uint8_t type,int32_t height,uint64_t hdrsi_unspentind,int64_t value,uint32_t fileid,uint64_t scriptpos,int32_t scriptlen,bits256 txid,int32_t vout) { - return(0); - if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 ) + if ( (0) ) { - crypto777_payment += value; - //printf("datachain_update crypto777 %.8f += %.8f\n",dstr(crypto777_payment),dstr(value)); + if ( memcmp(rmd160,CRYPTO777_RMD160,20) == 0 ) + { + crypto777_payment += value; + //printf("datachain_update crypto777 %.8f += %.8f\n",dstr(crypto777_payment),dstr(value)); + } + else if ( crypto777_payment != 0 && (type == IGUANA_SCRIPT_OPRETURN || type == IGUANA_SCRIPT_3of3 || type == IGUANA_SCRIPT_2of2 || type == IGUANA_SCRIPT_1of1) ) + { + //printf("datachain_update opreturn\n"); + iguana_opreturn(myinfo,ordered,coin,timestamp,bp,crypto777_payment,height,hdrsi_unspentind,value,fileid,scriptpos,scriptlen); + } else datachain_update_spend(myinfo,ordered,coin,timestamp,bp,height,txid,vout,rmd160,value); + return(crypto777_payment); } - else if ( crypto777_payment != 0 && (type == IGUANA_SCRIPT_OPRETURN || type == IGUANA_SCRIPT_3of3 || type == IGUANA_SCRIPT_2of2 || type == IGUANA_SCRIPT_1of1) ) - { - //printf("datachain_update opreturn\n"); - iguana_opreturn(myinfo,ordered,coin,timestamp,bp,crypto777_payment,height,hdrsi_unspentind,value,fileid,scriptpos,scriptlen); - } else datachain_update_spend(myinfo,ordered,coin,timestamp,bp,height,txid,vout,rmd160,value); - return(crypto777_payment); + return(0); } diff --git a/gecko/gecko.c b/gecko/gecko.c index 8de1611bf..774139d3e 100755 --- a/gecko/gecko.c +++ b/gecko/gecko.c @@ -52,7 +52,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc //iguana_update_balances(virt); //iguana_realtime_update(myinfo,virt); } - if ( 0 && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) + if ( (0) && hwmhdrsi <= longesthdrsi )//&& virt->blocks.hwmchain.height < virt->longestchain-1 ) { if ( time(NULL) > virt->hdrstime+3 ) { @@ -62,7 +62,7 @@ void gecko_iteration(struct supernet_info *myinfo,struct iguana_info *btcd,struc virt->hdrstime = (uint32_t)time(NULL); } } - if ( 0 && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) + if ( (0) && btcd->FULLNODE != 0 )//&& virt->blocks.hwmchain.height >= virt->longestchain-virt->chain->bundlesize ) { bitcoin_address(mineraddr,virt->chain->pubtype,myinfo->persistent_pubkey33,33); //fprintf(stderr,"mine.%s %s\n",virt->symbol,mineraddr); diff --git a/gecko/gecko_headers.c b/gecko/gecko_headers.c index e916b622d..8a013f38c 100755 --- a/gecko/gecko_headers.c +++ b/gecko/gecko_headers.c @@ -53,7 +53,7 @@ void gecko_blockhashupdate(struct iguana_info *virt,bits256 hash2,int32_t height char *gecko_headersarrived(struct supernet_info *myinfo,struct iguana_info *virt,char *remoteaddr,uint8_t *data,int32_t datalen,bits256 firsthash2) { - bits256 hash2,prevhash2; struct iguana_block *block; int32_t height,firstheight,i,len=0,n,num; struct iguana_msgzblock zmsgB; char str[65],str2[65]; + bits256 hash2,prevhash2; struct iguana_block *block; int32_t height=0,firstheight,i,len=0,n,num; struct iguana_msgzblock zmsgB; char str[65],str2[65]; num = (int32_t)(datalen / 84); printf("headers.%s arrived.%d from %s\n",virt->symbol,num,bits256_str(str,firsthash2)); if ( (block= iguana_blockfind("geckohdrs",virt,firsthash2)) != 0 && (firstheight= block->height) >= 0 ) diff --git a/gecko/gecko_miner.c b/gecko/gecko_miner.c index 6a7bdee31..4e2628255 100755 --- a/gecko/gecko_miner.c +++ b/gecko/gecko_miner.c @@ -62,7 +62,7 @@ int32_t gecko_blocknonce_verify(struct iguana_info *virt,uint8_t *serialized,int uint32_t gecko_nBits(struct iguana_info *virt,uint32_t *prevtimestampp,struct iguana_block *block,int32_t n) { - uint32_t nBits = GECKO_DEFAULTDIFF,starttime,endtime,est; struct iguana_block *prev=0; int32_t i,diff; bits256 targetval; + uint32_t nBits = GECKO_DEFAULTDIFF,starttime=0,endtime=0,est; struct iguana_block *prev=0; int32_t i,diff; bits256 targetval; *prevtimestampp = 0; if ( virt->chain->estblocktime == 0 ) return(GECKO_EASIESTDIFF); diff --git a/iguana/SuperNET_keys.c b/iguana/SuperNET_keys.c index 13d4c4684..904da0c83 100755 --- a/iguana/SuperNET_keys.c +++ b/iguana/SuperNET_keys.c @@ -220,7 +220,7 @@ int32_t SuperNET_savejsonfile(struct supernet_info *myinfo,char *finalfname,bits int32_t SuperNET_userkeys(char *passphrase,int32_t passsize,char *fname2fa,int32_t fnamesize) { return(0); -#ifndef __PNACL +/*#ifndef __PNACL //if ( (bits256_nonz(*wallethashp) == 0 || bits256_cmp(*wallethashp,GENESIS_PRIVKEY) == 0) && (bits256_nonz(*wallet2privp) == 0 || bits256_cmp(*wallet2privp,GENESIS_PRIVKEY) == 0) ) { sleep(1); @@ -232,7 +232,7 @@ int32_t SuperNET_userkeys(char *passphrase,int32_t passsize,char *fname2fa,int32 return(0); } #endif - return(-1); + return(-1);*/ } cJSON *SuperNET_decryptedjson(char *destfname,char *passphrase,int32_t passsize,bits256 wallethash,char *fname2fa,int32_t fnamesize,bits256 wallet2priv) diff --git a/iguana/cards777.c b/iguana/cards777.c index 023234d97..f74ffc26e 100755 --- a/iguana/cards777.c +++ b/iguana/cards777.c @@ -238,7 +238,7 @@ uint8_t *cards777_encode(struct supernet_info *myinfo,bits256 *encoded,bits256 * init_sharenrs(sharenrs,0,N,N); cards777_calcmofn(myinfo,allshares,myshares,sharenrs,M,xoverz,numcards,N); memcpy(ciphers,shuffled,numcards * N * sizeof(bits256)); - if ( 0 ) + if ( (0) ) { /*{ init_hexbytes_noT(nrs,dp->hand.sharenrs,dp->N); diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index a01f74444..b2b80e566 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -69,6 +69,7 @@ void dpow_entry2utxo(struct dpow_utxoentry *up,struct dpow_block *bp,struct dpow int32_t dpow_datahandler(struct supernet_info *myinfo,struct dpow_info *dp,struct dpow_block *bp,uint8_t nn_senderind,uint32_t channel,uint32_t height,uint8_t *data,int32_t datalen) { int32_t i,src_or_dest,myind = -1; bits256 txid,srchash; struct iguana_info *coin; char str[65],str2[65]; + memset(srchash.bytes,0,sizeof(srchash)); dpow_notaryfind(myinfo,bp,height,&myind,dp->minerkey33); if ( myind < 0 ) { diff --git a/iguana/dpow/dpow_prices.c b/iguana/dpow/dpow_prices.c index eae61f44b..0c3bb23a4 100755 --- a/iguana/dpow/dpow_prices.c +++ b/iguana/dpow/dpow_prices.c @@ -1635,7 +1635,7 @@ void _crypto_update(double cryptovols[2][9][2],struct PAX_data *dp,int32_t selec void PAX_RTupdate(double cryptovols[2][9][2],double RTmetals[4],double *RTprices,struct PAX_data *dp) { char *cryptostrs[9] = { "btc", "nxt", "unity", "eth", "etc", "kmd", "xmr", "bts", "xcp" }; - int32_t iter,i,c,baserel,basenum,relnum; double cnyusd,btcusd,kmdbtc,bid,ask,price,vol,prices[8][2],volumes[8][2]; + int32_t iter,i,c,baserel,basenum,relnum; double cnyusd,btcusd,kmdbtc,bid=0.,ask=0.,price,vol,prices[8][2],volumes[8][2]; char base[16],rel[16]; PAX_update(dp,&btcusd,&kmdbtc); memset(prices,0,sizeof(prices)); diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 7e2064550..194285053 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -429,6 +429,7 @@ void dpow_rawtxsign(struct supernet_info *myinfo,struct dpow_info *dp,struct igu return; for (j=0; jminerkey33[j+1]; + memset(srchash.bytes,0,sizeof(srchash)); m = 0; ep = &bp->notaries[myind]; cp = (src_or_dest != 0) ? &bp->notaries[myind].dest : &bp->notaries[myind].src; @@ -564,6 +565,7 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo bits256 txid,srchash,zero,signedtxid; struct iguana_info *coin; int32_t j,len,numsigs; char *retstr=0,str[65],str2[65]; uint8_t txdata[32768]; uint32_t channel,state; coin = (src_or_dest != 0) ? bp->destcoin : bp->srccoin; memset(zero.bytes,0,sizeof(zero)); + memset(txid.bytes,0,sizeof(txid)); channel = (src_or_dest != 0) ? DPOW_SIGBTCCHANNEL : DPOW_SIGCHANNEL; if ( bestk >= 0 && bp->state != 0xffffffff && coin != 0 ) { diff --git a/iguana/exchanges/bitcoin.c b/iguana/exchanges/bitcoin.c index 5f8c3ec7b..bf37462f0 100755 --- a/iguana/exchanges/bitcoin.c +++ b/iguana/exchanges/bitcoin.c @@ -290,6 +290,7 @@ struct bitcoin_spend *iguana_spendset(struct supernet_info *myinfo,struct iguana ptr = spend->inputs; for (i=0; i=0; mode--) if ( (up= iguana_bestfit(coin,ups,totalunspents,remains,mode)) != 0 ) break; diff --git a/iguana/exchanges/fxcm.c b/iguana/exchanges/fxcm.c index ac39cbbd1..15aede1cd 100755 --- a/iguana/exchanges/fxcm.c +++ b/iguana/exchanges/fxcm.c @@ -99,7 +99,7 @@ int32_t fxcm_setcontracts() { if ( (json= cJSON_Parse(xmlstr)) != 0 ) { - /* + /* 123.763 123.786 123.956 @@ -153,6 +153,7 @@ int32_t fxcm_ensure() char *ALLPAIRS(struct exchange_info *exchange,cJSON *argjson) { int32_t i,c,n; char base[32],rel[32]; cJSON *json,*item,*array = cJSON_CreateArray(); + n = 0; if ( fxcm_ensure() == 0 ) { for (i=0; iipbits); fprintf(fp,"%s\n",ipaddr); - if ( 0 && addr->msgcounts.verack == 0 ) + if ( (0) && addr->msgcounts.verack == 0 ) { printf("iguana_sendblockreq (%s) addrind.%d hasn't verack'ed yet\n",addr->ipaddr,addr->addrind); iguana_send_version(coin,addr,coin->myservices); @@ -274,7 +274,7 @@ void iguana_emitQ(struct iguana_info *coin,struct iguana_bundle *bp) void iguana_bundleQ(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t timelimit) { struct iguana_helper *ptr; struct iguana_bundle *tmp; int32_t i,n = 0; - if ( 0 && bp->queued == 0 && bp->emitfinish <= 1 && iguana_bundleready(myinfo,coin,bp,0) == bp->n ) + if ( (0) && bp->queued == 0 && bp->emitfinish <= 1 && iguana_bundleready(myinfo,coin,bp,0) == bp->n ) printf("bundle.[%d] is ready\n",bp->hdrsi); if ( bp->queued != 0 ) return; @@ -637,7 +637,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co isRT *= (coin->RTheight > 0); if ( coin->peers != 0 ) *numpeersp += coin->peers->numranked; - if ( 0 && (rand() % 10) == 0 ) + if ( (0) && (rand() % 10) == 0 ) printf("%s main.%u vs %u, svs %u %d vs %d\n",coin->symbol,(uint32_t)time(NULL),coin->startutc+10,coin->spendvectorsaved ,coin->blocks.hwmchain.height/coin->chain->bundlesize,(coin->longestchain-coin->minconfirms)/coin->chain->bundlesize); if ( time(NULL) > coin->startutc+60 ) { @@ -682,7 +682,7 @@ int32_t iguana_coin_mainiter(struct supernet_info *myinfo,struct iguana_info *co } if ( (bp= coin->current) != 0 && coin->stucktime != 0 && coin->isRT == 0 && coin->RTheight == 0 && (time(NULL) - coin->stucktime) > coin->MAXSTUCKTIME ) { - if ( 0 ) + if ( (0) ) { printf("%s is stuck too long, restarting due to %d\n",coin->symbol,bp->hdrsi); if ( coin->started != 0 ) diff --git a/iguana/iguana_accept.c b/iguana/iguana_accept.c index 869d0f3bb..e86c74bcf 100755 --- a/iguana/iguana_accept.c +++ b/iguana/iguana_accept.c @@ -369,7 +369,7 @@ int32_t iguana_peerhdrrequest(struct supernet_info *myinfo,struct iguana_info *c } else printf("cant find block at ht.%d\n",height+i); } } - if ( 0 && flag != 0 && strcmp("BTCD",coin->symbol) != 0 ) + if ( (0) && flag != 0 && strcmp("BTCD",coin->symbol) != 0 ) retval = iguana_queue_send(addr,0,serialized,"headers",len); //printf("hdrs request retval.%d len.%d\n",retval,len); } //else printf("couldnt find header\n"); @@ -446,4 +446,4 @@ int32_t iguana_peeraddrrequest(struct iguana_info *coin,struct iguana_peer *addr if ( x == 0 ) return(-1); return(sendlen); -} \ No newline at end of file +} diff --git a/iguana/iguana_bitmap.c b/iguana/iguana_bitmap.c index b690738b5..ec1ce5484 100755 --- a/iguana/iguana_bitmap.c +++ b/iguana/iguana_bitmap.c @@ -401,8 +401,8 @@ void disp_yval(register int32_t color,register float yval,register uint32_t *bit //if ( pixelwt(color) > pixelwt(bitmap[y*rowwidth + x]) ) bitmap[y*rowwidth + x] = pixel_blend(bitmap[y*rowwidth + x],color); return; - if ( is_primary_color(color) != 0 || (is_primary_color(bitmap[y*rowwidth+x]) == 0 && pixelwt(color) > pixelwt(bitmap[y*rowwidth + x])) ) - bitmap[y*rowwidth + x] = color; + //if ( is_primary_color(color) != 0 || (is_primary_color(bitmap[y*rowwidth+x]) == 0 && pixelwt(color) > pixelwt(bitmap[y*rowwidth + x])) ) + // bitmap[y*rowwidth + x] = color; } void disp_yvalsum(register int32_t color,register float yval,register uint32_t *bitmap,register int32_t x,register int32_t rowwidth,register int32_t height) @@ -509,7 +509,7 @@ void output_line(int32_t calclogflag,double ave,float *buf,int32_t n,int32_t col double src[1024],dest[1024]; int32_t i; memset(src,0,sizeof(src)); memset(dest,0,sizeof(dest)); - if ( 1 ) + if ( (1) ) { for (i=0; i<1024; i++) src[1023-i] = dest[1023-i] = buf[i]; @@ -1085,7 +1085,7 @@ void iguana_bitmapbundle(struct iguana_info *coin,uint8_t *rect,int32_t rowwidth struct iguana_bitmap *iguana_bitmapfind(char *name) { - struct iguana_info *coin; int32_t width,height,n,hdrsi,x,y; + struct iguana_info *coin; int32_t width=1,height=1,n,hdrsi,x,y; if ( ((coin= iguana_coinfind(name)) != 0 || (coin= iguana_coinfind("BTCD")) != 0) && coin->screen != 0 ) { strcpy(coin->screen->name,coin->symbol); diff --git a/iguana/iguana_blocks.c b/iguana/iguana_blocks.c index 9d502494f..3c65b069c 100755 --- a/iguana/iguana_blocks.c +++ b/iguana/iguana_blocks.c @@ -411,7 +411,7 @@ double PoW_from_compact(uint32_t nBits,uint8_t unitval) // NOT consensus safe, b nbytes = (nBits >> 24) & 0xFF; nbits = (8 * (nbytes - 3)); PoW = (nBits & 0xFFFFFF); - if ( 0 && nbytes > unitval ) + if ( (0) && nbytes > unitval ) { printf("illegal nBits.%x unitval.%02x\n",nBits,unitval); return(0.); @@ -590,7 +590,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan if ( bits256_nonz(prev->RO.hash2) == 0 || (prev->valid == 0 && iguana_blockvalidate(myinfo,coin,&valid,prev,0) < 0) ) { char str[65]; - if ( 0 && bits256_nonz(prev->RO.hash2) != 0 ) + if ( (0) && bits256_nonz(prev->RO.hash2) != 0 ) printf("(%s) notready v.%d m.%d h.%d\n",bits256_str(str,prev->RO.hash2),prev->valid,prev->mainchain,prev->height); return(0); } else prev->valid = 1; @@ -645,7 +645,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan else str2[0] = 0; if ( coin->blocks.maxblocks > coin->longestchain ) coin->longestchain = coin->blocks.maxblocks; - if ( 0 && (block->height % coin->chain->bundlesize) == 0 ) + if ( (0) && (block->height % coin->chain->bundlesize) == 0 ) { printf("EXTENDMAIN %s %d <- (%s) n.%u max.%u PoW %f numtx.%d valid.%d\n",str,block->height,str2,hwmchain->height+1,coin->blocks.maxblocks,block->PoW,block->RO.txn_count,block->valid); //iguana_walkchain(coin); @@ -724,7 +724,7 @@ struct iguana_block *_iguana_chainlink(struct supernet_info *myinfo,struct iguan iguana_RTnewblock(myinfo,coin,block); block->hdrsi = hdrsi; block->bundlei = bundlei; - if ( 0 && (bp= coin->bundles[hdrsi]) != 0 ) + if ( (0) && (bp= coin->bundles[hdrsi]) != 0 ) { if ( bp->blocks[bundlei] != block || bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) printf("new hwm [%d:%d] mismatched bundle block\n",hdrsi,bundlei); diff --git a/iguana/iguana_bundles.c b/iguana/iguana_bundles.c index d4ad7a81e..e7c53ae73 100755 --- a/iguana/iguana_bundles.c +++ b/iguana/iguana_bundles.c @@ -21,6 +21,7 @@ static uint16_t iguana_primes[] = { 65353, 65357, 65371, 65381, 65393, 65407, 65 struct iguana_bloominds iguana_calcbloom(bits256 hash2) { int32_t i,j,k; struct iguana_bloominds bit; + memset(&bit,0,sizeof(bit)); k = (int32_t)(sizeof(bit)/sizeof(uint16_t)) - 1; j = 15; for (i=0; i [%d:%d]\n",bits256_str(str,newhash2),bp->hdrsi,bundlei); iguana_bloomset(coin,&bp->bloom,0,bit); - if ( 0 ) + if ( (0) ) { int32_t i; if ( iguana_bloomfind(coin,&bp->bloom,0,bit) < 0 ) @@ -245,7 +246,7 @@ int32_t iguana_bundlehash2add(struct iguana_info *coin,struct iguana_block **blo return(-1); } } - if ( 0 && bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) + if ( (0) && bits256_nonz(bp->hashes[bundlei]) != 0 && bits256_cmp(bp->hashes[bundlei],block->RO.hash2) != 0 ) { //char str[65],str2[65]; //printf("B bp.[%d]->hashes[%d] mismatch %s != %s%s\n",bp->hdrsi,bundlei,bits256_str(str,bp->hashes[bundlei]),bits256_str(str2,block->RO.hash2),block->mainchain?".main":""); @@ -461,7 +462,7 @@ char *iguana_bundleaddrs(struct iguana_info *coin,int32_t hdrsi) uint8_t *PKbits; struct iguana_pkhash *P; uint32_t pkind,numpkinds; struct iguana_bundle *bp; struct iguana_ramchain *ramchain; struct iguana_ramchaindata *rdata; cJSON *retjson; char rmdstr[41]; if ( (bp= coin->bundles[hdrsi]) != 0 ) { - if ( 0 && coin->RTramchain_busy != 0 ) + if ( (0) && coin->RTramchain_busy != 0 ) { printf("iguana_bundleaddrs: unexpected access when RTramchain_busy\n"); return(0); @@ -520,7 +521,7 @@ void iguana_bundlepurgefiles(struct iguana_info *coin,struct iguana_bundle *bp) sprintf(fname,"%s/%s/%d/%d",GLOBAL_TMPDIR,coin->symbol,subdir,bp->bundleheight), OS_remove_directory(fname); //printf("purged hdrsi.[%d] subdir.%d lag.%ld\n",bp->hdrsi,subdir,time(NULL) - bp->emitfinish); bp->purgetime = (uint32_t)time(NULL); - if ( 0 ) + if ( (0) ) { for (i=subdir*IGUANA_SUBDIRDIVISOR; i<(subdir+1)*IGUANA_SUBDIRDIVISOR; i++) { @@ -692,14 +693,14 @@ int32_t iguana_bundleissuemissing(struct supernet_info *myinfo,struct iguana_inf queue_enqueue("missing",&coin->priorityQ,&req->DL); bp->issued[i] = 1; n++; - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("%s issuemissing.[%d:%d]\n",bits256_str(str,hash2),bp->hdrsi,i); } //else printf("[z%d] ",i); } //else printf("%d ",now - (bp->issued[i]+lag)); } if ( firsti >= 0 )//&& bp == coin->current ) { - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("%s [%d] first missing.%d of %d\n",bits256_str(str,hash2),bp->hdrsi,firsti,nonz); iguana_bundleblock(coin,&hash2,bp,firsti); if ( bits256_nonz(hash2) != 0 ) @@ -773,7 +774,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin int32_t i,ready,valid; char fname[1024]; struct iguana_block *block; int32_t sum[0x100],counts[0x100]; struct iguana_blockRO *B; struct iguana_bundle *nextbp; void *ptr; long filesize; struct iguana_ramchain R; bits256 prevhash2; memset(sum,0,sizeof(sum)); memset(counts,0,sizeof(counts)); - if ( 0 && bp->queued == 0 ) + if ( (0) && bp->queued == 0 ) { for (i=ready=0; in; i++) if ( (block= bp->blocks[i]) == 0 ) @@ -825,7 +826,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin char str[65]; if ( requiredflag != 0 ) printf(">>>>>>> block contents error at ht.%d [%d:%d]\n",bp->bundleheight+i,bp->hdrsi,i); - if ( 0 && bits256_nonz(block->RO.hash2) != 0 ) + if ( (0) && bits256_nonz(block->RO.hash2) != 0 ) printf("patch.%d and reissue prev.%s %d\n",bp->bundleheight+i,bits256_str(str,block->RO.prev_block),i); iguana_blockunmark(coin,block,bp,i,1); } @@ -845,11 +846,11 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin } fclose(fp); } - else if ( 0 ) + else if ( (0) ) //#endif { iguana_blockunmark(coin,block,bp,i,1); - if ( 0 && requiredflag != 0 ) + if ( (0) && requiredflag != 0 ) printf("not ready altpath.(%d %d %d %d %d) [%d:%d]\n",block->txvalid == 0,block->fpipbits == 0 ,block->fpos < 0,(bp->bundleheight+i > 0 && bits256_nonz(block->RO.prev_block) == 0),iguana_blockvalidate(myinfo,coin,&valid,block,1) < 0,bp->hdrsi,i); } else @@ -877,7 +878,7 @@ int32_t iguana_bundleready(struct supernet_info *myinfo,struct iguana_info *coin int32_t iguana_bundlehdr(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,int32_t starti) { int32_t i,dist,counter=0; char str[65]; - if ( 0 && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) ) + if ( (0) && bp->isRT == 0 && (bp->hdrsi == coin->bundlescount-1 || bp == coin->current) ) printf("hdr ITERATE.%d bundle.%d vs %d: h.%d n.%d r.%d s.%d c.%d finished.%d spec.%p[%d]\n",bp->hdrsi,bp->bundleheight,coin->longestchain-coin->chain->bundlesize,bp->numhashes,bp->n,bp->numrecv,bp->numsaved,bp->numcached,bp->emitfinish,bp->speculative,bp->numspec); dist = 30 + (coin->current != 0 ? bp->hdrsi - coin->current->hdrsi : 0); if ( bp == coin->current ) @@ -976,7 +977,7 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin datasize += block->RO.recvlen; } } - else if ( 0 && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) + else if ( (0) && bits256_nonz(block->RO.hash2) != 0 && bits256_nonz(bp->hashes[bundlei]) != 0 ) { printf("hash mismatch [%d:%d]\n",bp->hdrsi,bundlei); iguana_blockunmark(coin,block,bp,bundlei,1); @@ -996,7 +997,7 @@ int64_t iguana_bundlecalcs(struct supernet_info *myinfo,struct iguana_info *coin } } bp->numcached = numcached; - if ( 0 && bp->numcached != numsaved ) + if ( (0) && bp->numcached != numsaved ) printf("[%d] emit.%u ramchain.%p numcached.%d vs numsaved.%d numhashes.%d\n",bp->hdrsi,bp->emitfinish,bp->ramchain.H.data,bp->numcached,numsaved,numhashes); bp->datasize = datasize; bp->numhashes = numhashes; @@ -1126,7 +1127,7 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin iguana_bundlecalcs(myinfo,coin,bp,lag); if ( coin->blockdepth == 0 && coin->blockdepth == 0 && bp->hdrsi == coin->bundlescount-1 ) iguana_autoextend(myinfo,coin,bp); - if ( 0 && bp->hdrsi == 0 ) + if ( (0) && bp->hdrsi == 0 ) printf("ITER utxo.%u now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",bp->utxofinish,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); bp->nexttime = (uint32_t)time(NULL) + ((bp->hdrsi > starti) ? 0 : -2); if ( bp->hdrsi == coin->bundlescount-1 || (bp->numhashes < bp->n && bp->bundleheight < coin->longestchain-coin->chain->bundlesize) ) @@ -1144,10 +1145,10 @@ int32_t iguana_bundleiters(struct supernet_info *myinfo,struct iguana_info *coin { max = bp->n; counter = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); - if ( 0 && counter > 0 ) + if ( (0) && counter > 0 ) printf("starti.%d range.%d now.%u spec.%-4d bundle.%-4d h.%-4d r.%-4d s.%-4d F.%d T.%d issued.%d mb.%d/%d\n",starti,range,(uint32_t)time(NULL),bp->numspec,bp->bundleheight/coin->chain->bundlesize,bp->numhashes,bp->numrecv,bp->numsaved,bp->emitfinish,timelimit,counter,coin->MAXBUNDLES,coin->bundlescount); } else bp->nexttime++; - if ( 0 && bp->emitfinish <= 1 ) + if ( (0) && bp->emitfinish <= 1 ) iguana_bundleQ(myinfo,coin,bp,1000); else { @@ -1417,7 +1418,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch //sortbuf[m*2] = bp->metric; //sortbuf[m*2 + 1] = i; m++; - if ( 0 && lastpending == 0 ) + if ( (0) && lastpending == 0 ) printf("%d ",bp->numsaved); } } @@ -1552,7 +1553,7 @@ void iguana_bundlestats(struct supernet_info *myinfo,struct iguana_info *coin,ch myallocated(0,0); coin->lastdisp = (uint32_t)time(NULL); } - if ( 0 && (bp= coin->current) != 0 && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n ) + if ( (0) && (bp= coin->current) != 0 && coin->RTheight >= bp->bundleheight && coin->RTheight < bp->bundleheight+bp->n ) { for (i=coin->RTheight-bp->bundleheight; in; i++) { diff --git a/iguana/iguana_chains.c b/iguana/iguana_chains.c index af0b6cb04..87a8ce798 100755 --- a/iguana/iguana_chains.c +++ b/iguana/iguana_chains.c @@ -126,12 +126,12 @@ int32_t blockhash_scrypt(uint8_t *blockhashp,uint8_t *serialized,int32_t len) blockhashfunc iguana_hashalgo(char *hashalgostr) { return(blockhash_sha256); // all coins seem to use this for genesis - if ( hashalgostr == 0 || hashalgostr[0] == 0 || strcmp(hashalgostr,"sha256") == 0 ) + /*if ( hashalgostr == 0 || hashalgostr[0] == 0 || strcmp(hashalgostr,"sha256") == 0 ) return(blockhash_sha256); else if ( strcmp(hashalgostr,"scrypt") == 0 ) return(blockhash_scrypt); else printf("unsupported blockhash algo.(%s)\n",hashalgostr); - return(0); + return(0);*/ } bits256 iguana_calcblockhash(char *symbol,int32_t (*hashalgo)(uint8_t *blockhashp,uint8_t *serialized,int32_t len),uint8_t *serialized,int32_t len) @@ -189,8 +189,8 @@ bits256 iguana_chaingenesis(struct supernet_info *myinfo,char *symbol,uint8_t zc char *parse_conf_line(char *line,char *field) { line += strlen(field); - for (; *line!='='&&*line!=0; line++) - break; + while ( (*line) != '=' && (*line) != 0 ) + line++; if ( *line == 0 ) return(0); if ( *line == '=' ) diff --git a/iguana/iguana_exchanges.c b/iguana/iguana_exchanges.c index 86a5038ff..01de2cfca 100755 --- a/iguana/iguana_exchanges.c +++ b/iguana/iguana_exchanges.c @@ -1129,7 +1129,7 @@ struct exchange_info *exchanges777_info(char *exchangestr,int32_t sleepflag,cJSO sleep(sleepflag); } } - if ( 0 && exchange != 0 ) + if ( (0) && exchange != 0 ) printf("found exchange.(%s) %p %p %p\n",exchange->name,exchange->issue.supports,exchange->issue.price,exchange->issue.allpairs); return(exchange); } diff --git a/iguana/iguana_init.c b/iguana/iguana_init.c index 43cf08875..8abd4e50d 100755 --- a/iguana/iguana_init.c +++ b/iguana/iguana_init.c @@ -269,7 +269,7 @@ int32_t iguana_bundleinitmap(struct supernet_info *myinfo,struct iguana_info *co void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int32_t iter,FILE *fp) { - int32_t j,k,m,c,flag,bundlei,lastheight,missing=0,height = -1; char checkstr[1024],line[1024]; + int32_t j,k,m,c,flag,bundlei,lastheight=0,missing=0,height = -1; char checkstr[1024],line[1024]; struct iguana_peer *addr; struct iguana_bundle *bp; bits256 allhash,hash2,hash1,zero,lastbundle; if ( coin->FULLNODE == 0 && coin->VALIDATENODE == 0 && iter > 0 ) return; @@ -318,7 +318,7 @@ void iguana_parseline(struct supernet_info *myinfo,struct iguana_info *coin,int3 { if ( m < coin->MAXPEERS/2 ) { - if ( 0 && m == 0 && coin->seedipaddr[0] != 0 ) + if ( (0) && m == 0 && coin->seedipaddr[0] != 0 ) { addr = &coin->peers->active[m++]; iguana_initpeer(coin,addr,(uint32_t)calc_ipbits(coin->seedipaddr)); diff --git a/iguana/iguana_interpreter.c b/iguana/iguana_interpreter.c index d98ac46a8..341f92b55 100755 --- a/iguana/iguana_interpreter.c +++ b/iguana/iguana_interpreter.c @@ -734,7 +734,7 @@ int32_t iguana_checksig(struct iguana_info *coin,struct iguana_stackdata pubkeya if ( (retval= (bitcoin_verify(coin->ctx,sig,siglen-1,sigtxid,pubkey,plen) == 0)) == 0 ) { } - if ( 0 ) + if ( (0) ) { int32_t i; char str[65]; for (i=0; iflags & IGUANA_STACKFLAG) != 0 ) { + val = 0; if ( op->opcode == IGUANA_OP_PICK || op->opcode == IGUANA_OP_ROLL ) { if ( interpret != 0 && stacks->stackdepth < (val= iguana_num(args[0])) ) @@ -1505,7 +1506,7 @@ int32_t bitcoin_assembler(struct iguana_info *coin,cJSON *logarray,uint8_t scrip } else if ( (op->flags & IGUANA_MATHFLAG) != 0 ) { - int64_t numA,numB,numC; + int64_t numA=0,numB=0,numC=0; for (i=0; istackitems; i++) { if ( args[i].size != sizeof(int32_t) ) diff --git a/iguana/iguana_json.c b/iguana/iguana_json.c index f5a3191c6..e7febc655 100755 --- a/iguana/iguana_json.c +++ b/iguana/iguana_json.c @@ -200,7 +200,7 @@ cJSON *SuperNET_helpjson() int32_t agentform(FILE *fp,char *form,int32_t max,char *agent,cJSON *methoditem) { - cJSON *item,*fieldsarray; int32_t j,m,width,size = 0; + cJSON *item,*fieldsarray; int32_t j,m,width=1,size = 0; char *methodstr,*typestr,outstr[2048],outstr2[2048],fields[8192],str[2],agent_method[256],*fieldname; form[0] = 0; if ( (methodstr= jstr(methoditem,"method")) == 0 ) @@ -293,7 +293,7 @@ int32_t templates_emit(char *retbuf,int32_t maxsize,char *template,char *agent,c int32_t pretty_form(FILE *fp,char *formheader,char *formfooter,char *fieldtemplate,char *agent,cJSON *methoditem,cJSON *helpitem,char *suffix) { - cJSON *item,*fieldsarray; int32_t j,m,formsize,fieldsize,iter,width,size = 0; + cJSON *item,*fieldsarray; int32_t j,m,formsize,fieldsize,iter,width=1,size = 0; char *methodstr,*typestr,*fieldname,*helpstr,*curlstr,*urlstr,*itemhelp; char outstr[2048],outstr2[2048],str[2],widthstr[16],both[512]; if ( (methodstr= jstr(methoditem,"method")) == 0 ) diff --git a/iguana/iguana_mofn.c b/iguana/iguana_mofn.c index c1866f01f..2756def45 100755 --- a/iguana/iguana_mofn.c +++ b/iguana/iguana_mofn.c @@ -262,7 +262,7 @@ void libgfshare_init(struct supernet_info *myinfo,uint8_t _logs[256],uint8_t _ex for (i=255; i<510; i++) _exps[i] = _exps[i % 255]; _logs[0] = 0; // can't log(0) so just set it neatly to 0 - if ( 0 ) + if ( (0) ) { void test_mofn(struct supernet_info *myinfo); gfshare_test(myinfo,6,11,32); @@ -602,7 +602,7 @@ void test_mofn(struct supernet_info *myinfo) { if ( memcmp(secret.bytes,recover.bytes,sizeof(secret)) != 0 ) printf("FAILED m.%d M.%d N.%d\n",m,M,N); - else if ( 0 ) + else if ( (0) ) { char str[65]; printf("%s PASSED m.%d M.%d N.%d\n",bits256_str(str,recover),m,M,N); @@ -658,6 +658,7 @@ int32_t iguana_schnorr_peersign(void *ctx,uint8_t *allpub33,uint8_t *partialsig6 bits256 iguana_schnorr_noncepair(void *ctx,bits256 *pubkey,uint8_t odd_even,bits256 msg256,bits256 privkey,int32_t maxj) { bits256 privnonce; int32_t j; uint8_t pubkey33[33]; + memset(privnonce.bytes,0,sizeof(privnonce)); for (j=0; jctx,sig64,msg256,allpub2,33) < 0 ) printf("allpub2 error verifying combined sig k.%d\n",k); - else if ( 0 ) // doesnt replicate with subsets + else if ( (0) ) // doesnt replicate with subsets { if ( bitcoin_pubkey_combine(myinfo->ctx,allpub,0,pubkeys,n,0,0) == 0 ) { diff --git a/iguana/iguana_msg.c b/iguana/iguana_msg.c index 3c5ba3b38..8ad05f5d9 100755 --- a/iguana/iguana_msg.c +++ b/iguana/iguana_msg.c @@ -449,7 +449,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu expand_ipbits(ipaddr,ipbits); if ( port != 0 ) sprintf(ipport,"%s:%d",ipaddr,port); - if ( 0 ) + if ( (0) ) { int32_t i; printf("{{"); @@ -459,7 +459,7 @@ void iguana_gotaddr(struct iguana_info *coin,struct iguana_peer *addr,struct igu } if ( strcmp(coin->symbol,"BTC") != 0 || (rand() % 10) == 0 ) iguana_possible_peer(coin,ipport); - if ( 0 && strcmp("TAZ",coin->symbol) == 0 ) + if ( (0) && strcmp("TAZ",coin->symbol) == 0 ) printf("iguana_gotaddr: %s from %s\n",ipaddr,addr->ipaddr); } @@ -713,7 +713,7 @@ int32_t iguana_rwtx(struct supernet_info *myinfo,uint8_t zcash,int32_t rwflag,st memcpy(joinsplitsig,&serialized[len],64), len += 64; } } - if ( 0 ) + if ( (0) ) { *txidp = bits256_doublesha256(txidstr,txstart,len); char str[65]; @@ -955,7 +955,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s } if ( addr != 0 ) { - if ( 0 && addr->msgcounts.verack == 0 ) + if ( (0) && addr->msgcounts.verack == 0 ) printf("iguana_msgparser verack.%d from (%s) parse.(%s) len.%d\n",addr->msgcounts.verack,addr->ipaddr,H->command,recvlen); //iguana_peerblockrequest(coin,addr->blockspace,IGUANA_MAXPACKETSIZE,addr,iguana_blockhash(coin,100),0); addr->lastcontact = (uint32_t)time(NULL); @@ -1010,7 +1010,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s else { intvectors = 'I', addr->msgcounts.inv++; - if ( 0 && strcmp(H->command,"inv2") == 0 ) + if ( (0) && strcmp(H->command,"inv2") == 0 ) printf("GOT INV2.%d\n",recvlen); len = iguana_intvectors(coin,addr,1,data,recvlen); // indirectly issues getdata } @@ -1056,7 +1056,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s } len += iguana_rwvarint32(0,&data[len],&tmp); char str[65],str2[65]; - if ( 0 && coin->chain->auxpow != 0 ) + if ( (0) && coin->chain->auxpow != 0 ) printf("%d %d of %d: %s %s v.%08x numtx.%d cmp.%d\n",len,i,n,bits256_str(str,hash2),bits256_str(str2,zmsg.zH.prev_block),zmsg.zH.version,tmp,bits256_cmp(prevhash2,zmsg.zH.prev_block)); } else len += iguana_rwblock(myinfo,coin->chain->symbol,coin->chain->zcash,coin->chain->auxpow,coin->chain->hashalgo,0,&hash2,&data[len],(void *)&zmsg,recvlen); @@ -1151,7 +1151,7 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s len = 0; if ( (sendlen= iguana_peeraddrrequest(coin,addr,&addr->blockspace[sizeof(H)],IGUANA_MAXPACKETSIZE)) > 0 ) { - if ( 0 ) + if ( (0) ) { int32_t checklen; uint32_t checkbits; char checkaddr[64]; checklen = iguana_rwvarint(0,&addr->blockspace[sizeof(H)],&x); @@ -1263,4 +1263,4 @@ int32_t iguana_msgparser(struct supernet_info *myinfo,struct iguana_info *coin,s } } return(retval); -} \ No newline at end of file +} diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 956d551be..6fa29d2be 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -38,7 +38,7 @@ void dpow_fifoupdate(struct supernet_info *myinfo,struct dpow_checkpoint *fifo,s memset(newfifo,0,sizeof(newfifo)); for (i=DPOW_FIFOSIZE-1; i>0; i--) { - if ( 0 && bits256_nonz(fifo[i-1].blockhash.hash) != 0 && (tip.blockhash.height - fifo[i-1].blockhash.height) != i ) + if ( (0) && bits256_nonz(fifo[i-1].blockhash.hash) != 0 && (tip.blockhash.height - fifo[i-1].blockhash.height) != i ) printf("(%d != %d) ",(tip.blockhash.height - fifo[i-1].blockhash.height),i); if ( (ind= (tip.blockhash.height - fifo[i-1].blockhash.height)) >= 0 && ind < DPOW_FIFOSIZE ) newfifo[ind] = fifo[i-1]; @@ -228,6 +228,7 @@ void dpow_addresses() TWO_STRINGS(iguana,dpow,symbol,pubkey) { char *retstr,srcaddr[64],destaddr[64]; struct iguana_info *src,*dest; cJSON *ismine; int32_t i,srcvalid,destvalid; struct dpow_info *dp = &myinfo->DPOWS[myinfo->numdpows]; + destvalid = srcvalid = 0; if ( myinfo->NOTARY.RELAYID < 0 ) { if ( (retstr= basilisk_addrelay_info(myinfo,0,(uint32_t)calc_ipbits(myinfo->ipaddr),myinfo->myaddr.persistent)) != 0 ) diff --git a/iguana/iguana_payments.c b/iguana/iguana_payments.c index 9e3a10102..25999b922 100755 --- a/iguana/iguana_payments.c +++ b/iguana/iguana_payments.c @@ -565,7 +565,7 @@ char *sendtoaddress(struct supernet_info *myinfo,struct iguana_info *coin,char * jaddnum(valsobj,"basilisktag",basilisktag); jaddnum(valsobj,"locktime",locktime); jaddnum(valsobj,"timeout",30000); - if ( 0 && comment != 0 && is_hexstr(comment,0) > 0 ) + if ( (0) && comment != 0 && is_hexstr(comment,0) > 0 ) jaddstr(valsobj,"opreturn",comment); if ( (retstr= basilisk_bitcoinrawtx(myinfo,coin,remoteaddr,basilisktag,jint(valsobj,"timeout"),valsobj,V)) != 0 ) { @@ -981,6 +981,7 @@ HASH_AND_INT(bitcoinrpc,getrawtransaction,txid,verbose) if ( coin->notarychain >= 0 && coin->FULLNODE == 0 ) return(_dex_getrawtransaction(myinfo,coin->symbol,txid)); HASH_FIND(hh,coin->RTdataset,txid.bytes,sizeof(txid),RTptr); + memset(checktxid.bytes,0,sizeof(checktxid)); if ( RTptr != 0 && RTptr->rawtxbytes != 0 && RTptr->txlen > 0 ) { checktxid = RTptr->txid; @@ -1069,7 +1070,7 @@ char *iguana_validaterawtx(struct supernet_info *myinfo,struct iguana_info *coin if ( (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&msgtx->txid,msgtx,rawtx,extraspace,extralen,0,0,suppress_pubkeys)) != 0 ) { //printf("txobj.(%s)\n",jprint(txobj,0)); - if ( 0 && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 ) + if ( (0) && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,0)) != 0 ) { // no guarantee byte for byte identical tx is recreated if ( strcmp(rawtx,checkstr) != 0 ) @@ -1082,7 +1083,7 @@ char *iguana_validaterawtx(struct supernet_info *myinfo,struct iguana_info *coin break; jaddnum(retjson,"mismatch position",i); jadd(retjson,"origtx",txobj); - if ( 0 && (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&txid,msgtx,checkstr,extraspace,extralen,0,0,suppress_pubkeys)) != 0 ) + if ( (0) && (txobj= bitcoin_hex2json(coin,coin->blocks.hwmchain.height,&txid,msgtx,checkstr,extraspace,extralen,0,0,suppress_pubkeys)) != 0 ) jadd(retjson,"checktx",txobj); free(checkstr); return(jprint(retjson,1)); diff --git a/iguana/iguana_peers.c b/iguana/iguana_peers.c index bedda833f..c5ed454bd 100755 --- a/iguana/iguana_peers.c +++ b/iguana/iguana_peers.c @@ -594,7 +594,7 @@ int32_t iguana_send(struct iguana_info *coin,struct iguana_peer *addr,uint8_t *s } } addr->totalsent += len; - if ( 0 && addr->basilisk != 0 ) + if ( (0) && addr->basilisk != 0 ) printf("verack.%d (%s) sent.%d bytes to %s\n",addr->msgcounts.verack,cmdstr,len,addr->ipaddr); return(len); } @@ -623,7 +623,7 @@ int32_t iguana_queue_send(struct iguana_peer *addr,int32_t delay,uint8_t *serial packet->embargo.millis += delay; } memcpy(packet->serialized,serialized,datalen); - if ( 0 && addr->supernet != 0 ) + if ( (0) && addr->supernet != 0 ) printf("%p queue send.(%s) %d to (%s)\n",packet,serialized+4,datalen,addr->ipaddr); queue_enqueue("sendQ",&addr->sendQ,&packet->DL); return(datalen); @@ -1050,7 +1050,7 @@ int32_t iguana_pollsendQ(struct iguana_info *coin,struct iguana_peer *addr) struct iguana_packet *packet; if ( (packet= queue_dequeue(&addr->sendQ)) != 0 ) { - if ( 0 && (addr->supernet != 0 || strcmp((char *)&packet->serialized[4],"SuperNET") == 0) ) + if ( (0) && (addr->supernet != 0 || strcmp((char *)&packet->serialized[4],"SuperNET") == 0) ) printf("%s: send.(%s).%d usock.%d dead.%u ready.%u supernet.%d\n",addr->ipaddr,packet->serialized+4,packet->datalen,addr->usock,addr->dead,addr->ready,addr->supernet); if ( strcmp((char *)&packet->serialized[4],"getdata") == 0 ) { @@ -1385,18 +1385,18 @@ void iguana_dedicatedloop(struct supernet_info *myinfo,struct iguana_info *coin, } } //printf(">>>>>>>>>>>>>> finish %s dedicatedloop.%s\n",coin->symbol,addr->ipaddr); - if ( 0 ) + if ( (0) ) { if ( addr->vinsfp != 0 ) fclose(addr->vinsfp), addr->vinsfp = 0; if ( addr->voutsfp != 0 ) - fclose(addr->voutsfp), addr->voutsfp = 0; + fclose(addr->voutsfp), addr->voutsfp = 0; } iguana_iAkill(coin,addr,addr->dead != 0); myfree(buf,bufsize); //if ( addr->filehash2 != 0 ) // myfree(addr->filehash2,addr->maxfilehash2*sizeof(*addr->filehash2)), addr->filehash2 = 0; - if ( 0 ) + if ( (0) ) { iguana_mempurge(&addr->RAWMEM); iguana_mempurge(&addr->TXDATA); diff --git a/iguana/iguana_ramchain.c b/iguana/iguana_ramchain.c index 6f02973c3..a2cb07fdc 100755 --- a/iguana/iguana_ramchain.c +++ b/iguana/iguana_ramchain.c @@ -56,7 +56,7 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t printf("fatal alloc errorC in hashset\n"); iguana_exit(0,0); } - if ( 0 && ramchain->expanded && selector == 'T' ) + if ( (0) && ramchain->expanded && selector == 'T' ) printf("hashmem.%p selector.%c added.(%s) itemind.%x ptr.%p\n",ramchain->hashmem,selector,str,itemind,ptr); if ( selector == 'T' ) HASH_ADD_KEYPTR(hh,ramchain->txids,key,keylen,ptr); @@ -64,14 +64,14 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t ptr->hh.itemind = itemind; //if ( strcmp(str,"0000000000000000000000000000000000000000000000000000000000000000") == 0 ) // printf("added null txid?\n"), getchar(); - if ( 0 && ramchain->expanded && selector == 'T' ) + if ( (0) && ramchain->expanded && selector == 'T' ) printf("selector.%c added.(%s) itemind.%x ptr.%p tmp.%p\n",selector,str,itemind,ptr,tmp); if ( itemind == 0 ) { printf("negative itemind\n"); iguana_exit(0,0); } - if ( 0 ) + if ( (0) ) { if ( selector == 'T' ) HASH_FIND(hh,ramchain->txids,key,keylen,tmp); @@ -88,7 +88,7 @@ struct iguana_kvitem *iguana_hashsetPT(struct iguana_ramchain *ramchain,int32_t void iguana_blocksetcounters(struct iguana_info *coin,struct iguana_block *block,struct iguana_ramchain * ramchain) { - if ( 0 && coin->virtualchain != 0 ) + if ( (0) && coin->virtualchain != 0 ) printf("iguana_blocksetcounters.%s 1st txidind.%u <- ht.%d\n",coin->symbol,ramchain->H.txidind,block->height); block->RO.firsttxidind = ramchain->H.txidind; block->RO.firstvout = ramchain->H.unspentind; @@ -110,7 +110,7 @@ int32_t iguana_peerfname(struct iguana_info *coin,int32_t *hdrsip,char *dirname, bp = 0, bundlei = -2; if ( bits256_nonz(prevhash2) == 0 || (bp= iguana_bundlefind(coin,&bp,&bundlei,prevhash2)) == 0 || bundlei >= coin->chain->bundlesize-1 ) { - if ( 0 && dispflag != 0 ) + if ( (0) && dispflag != 0 ) printf("iguana_peerfname %s error finding.(%s) spec.%p bp.%p\n",coin->symbol,bits256_str(str,hash2),bp!=0?bp->speculative:0,bp); return(-2); } else bundlei++; @@ -191,7 +191,7 @@ uint32_t iguana_ramchain_addtxid(struct iguana_info *coin,RAMCHAIN_FUNC,bits256 } else { - if ( 0 && ramchain->expanded != 0 ) + if ( (0) && ramchain->expanded != 0 ) printf("T.%p txidind.%d numvouts.%d numvins.%d\n",T,txidind,numvouts,numvins); t->txidind = txidind, t->txid = txid, t->numvouts = numvouts, t->numvins = numvins; t->bundlei = bundlei; @@ -464,7 +464,7 @@ uint32_t iguana_ramchain_addspend(struct iguana_info *coin,RAMCHAIN_FUNC,bits256 { external = 1; txidind = ramchain->externalind++; - if ( 0 && ramchain->expanded != 0 ) + if ( (0) && ramchain->expanded != 0 ) { char str[65]; printf("%p X[%d] <- %s\n",X,txidind,bits256_str(str,prev_hash)); } if ( ramchain->H.ROflag != 0 ) { @@ -580,7 +580,7 @@ uint32_t iguana_ramchain_addspend256(struct iguana_info *coin,struct iguana_peer } else s->scriptpos = 0; //else printf("spend256 scriptfpos.%d\n",s->scriptfpos); char str[65]; - if ( 0 && coin->virtualchain != 0 ) + if ( (0) && coin->virtualchain != 0 ) printf("W.%p s.%d vout.%d/%d [%d] %s fpos.%u slen.%d\n",s,spendind,s->prevout,prev_vout,bp->hdrsi,bits256_str(str,prev_hash),(uint32_t)s->scriptpos,(int32_t)s->vinscriptlen); } return(spendind); @@ -813,7 +813,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS //P2 = 0;//iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_FIRSTSPENDS),fparg,fpos,P2,&offset,(sizeof(struct iguana_pkextra) * numpkinds),srcsize); A = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_ACCOUNTS),fparg,fpos,A,&offset,(sizeof(struct iguana_account) * numpkinds),srcsize); char str[65]; - if ( 0 && X != 0 ) + if ( (0) && X != 0 ) printf("%p X[1] -> %s\n",&X[1],bits256_str(str,X[1])); X = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_EXTERNALS),fparg,fpos,X,&offset,(sizeof(bits256) * numexternaltxids),srcsize); TXbits = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_TXBITS),fparg,fpos,TXbits,&offset,hconv_bitlen(txbits),srcsize); @@ -823,7 +823,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS { Ux = destptr, Sx = destptr, P = destptr, A = destptr, X = destptr, TXbits = destptr, PKbits = destptr, Kspace = destptr; //U2 = destptr, P2 = destptr, U = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_UNSPENTS),fparg,fpos,U,&offset,(sizeof(struct iguana_unspent20) * numunspents),srcsize); - if ( 0 && lhashes != 0 ) + if ( (0) && lhashes != 0 ) printf("iter.%d lhashes.%p offset.%ld destptr.%p len.%ld fparg.%p fpos.%ld srcsize.%ld\n",iter,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),(long)offset,destptr,(long)sizeof(struct iguana_spend256) * numspends,fparg,(long)fpos,(long)srcsize); S = iguana_ramchain_offset(fname,rdata,RAMCHAIN_LARG(IGUANA_LHASH_SPENDS),fparg,fpos,S,&offset,(sizeof(struct iguana_spend256) * numspends),srcsize); } @@ -871,7 +871,7 @@ int64_t _iguana_rdata_action(char *fname,FILE *fp,bits256 lhashes[IGUANA_NUMLHAS int64_t iguana_ramchain_action(char *fname,RAMCHAIN_FUNC,FILE *fp,bits256 lhashes[IGUANA_NUMLHASHES],struct iguana_ramchaindata *destdata,uint64_t fpos,struct iguana_ramchaindata *srcdata,int32_t numblocks,int32_t scriptspace,uint8_t zcash) { - if ( 0 && ramchain->expanded == 0 ) + if ( (0) && ramchain->expanded == 0 ) printf("action.%p (%p %p %p) %ld allocated.%ld [%d:%d %d:%d]\n",srcdata,fp,lhashes,destdata,(long)fpos,(long)srcdata->allocsize,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse); return(_iguana_rdata_action(fname,fp,lhashes,destdata,fpos,ramchain->expanded,srcdata->numtxids,srcdata->numunspents,srcdata->numspends,srcdata->numpkinds,srcdata->numexternaltxids,scriptspace,srcdata->txsparsebits,srcdata->numtxsparse,srcdata->pksparsebits,srcdata->numpksparse,srcdata->allocsize,RAMCHAIN_ARG,numblocks,zcash)); } @@ -882,7 +882,7 @@ int64_t iguana_ramchain_size(char *fname,RAMCHAIN_FUNC,int32_t numblocks,int32_t if ( (rdata= ramchain->H.data) != 0 ) { allocsize = iguana_ramchain_action(fname,RAMCHAIN_ARG,0,0,0,0,rdata,numblocks,scriptspace,zcash); - if ( 0 && ramchain->expanded != 0 ) + if ( (0) && ramchain->expanded != 0 ) printf("%p iguana_ramchain_size.expanded.%d %u: Koffset.%u scriptoffset.%u stacksize.%u stackspace.%u [%u]\n",ramchain,ramchain->expanded,(int32_t)allocsize,(int32_t)rdata->Koffset,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->stackspace,scriptspace); } return(allocsize); @@ -902,7 +902,7 @@ long iguana_ramchain_setsize(char *fname,struct iguana_ramchain *ramchain,struct rdata->scriptspace = ramchain->H.scriptoffset; rdata->stackspace = ramchain->H.stacksize; rdata->allocsize = iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,rdata->scriptspace,zcash); - if ( 0 && rdata->scriptspace != 0 ) + if ( (0) && rdata->scriptspace != 0 ) printf("iguana_ramchain_setsize: Koffset.%d scriptspace.%d stackspace.%d (scriptoffset.%d stacksize.%d) allocsize.%d\n",(int32_t)rdata->Koffset,(int32_t)rdata->scriptspace,(int32_t)rdata->stackspace,(int32_t)ramchain->H.scriptoffset,(int32_t)ramchain->H.stacksize,(int32_t)rdata->allocsize); ramchain->datasize = rdata->allocsize; return((long)rdata->allocsize); @@ -929,7 +929,7 @@ int64_t iguana_ramchain_saveaction(char *fname,RAMCHAIN_FUNC,FILE *fp,struct igu before = ftell(fp); iguana_ramchain_action(fname,RAMCHAIN_ARG,fp,0,rdata,0,rdata,numblocks,scriptspace,zcash); after = ftell(fp); - if ( 0 && ramchain->expanded == 0 ) + if ( (0) && ramchain->expanded == 0 ) { int32_t i; for (i=0; iallocsize; - if ( 0 && expanded != 0 ) + if ( (0) && expanded != 0 ) printf("init T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)offset); if ( rdata->allocsize != iguana_ramchain_size(fname,RAMCHAIN_ARG,numblocks,scriptspace,zcash) ) { @@ -997,12 +997,12 @@ int32_t iguana_ramchain_alloc(char *fname,struct iguana_info *coin,struct iguana memset(ramchain,0,sizeof(*ramchain)); ramchain->height = height; allocsize = _iguana_rdata_action(fname,0,0,0,0,1,numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace,0,0,0,0,0,RAMCHAIN_ARG,numblocks,zcash); - if ( 0 && ramchain->expanded != 0 ) + if ( (0) && ramchain->expanded != 0 ) printf("T.%d U.%d S.%d P.%d X.%d -> %ld\n",numtxids,numunspents,numspends,numpkinds,numexternaltxids,(long)allocsize); memset(mem,0,sizeof(*mem)); memset(hashmem,0,sizeof(*hashmem)); hashsize = iguana_hashmemsize(numtxids,numunspents,numspends,numpkinds,numexternaltxids,scriptspace); - while ( 0 && (x= (myallocated(0,-1)+hashsize+allocsize + 65536)) > coin->MAXMEM ) + while ( (0) && (x= (myallocated(0,-1)+hashsize+allocsize + 65536)) > coin->MAXMEM ) { char str[65],str2[65]; fprintf(stderr,"ht.%d wait for allocated %s < MAXMEM %s | elapsed %.2f minutes hashsize.%ld allocsize.%ld\n",height,mbstr(str,myallocated(0,-1)+hashsize+allocsize),mbstr(str2,coin->MAXMEM),(double)(time(NULL)-coin->startutc)/60.,(long)hashsize,(long)allocsize); sleep(13); @@ -1018,7 +1018,7 @@ int32_t iguana_ramchain_alloc(char *fname,struct iguana_info *coin,struct iguana long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,struct iguana_bundle *bp,uint8_t zcash) { - struct iguana_ramchaindata *rdata,tmp; char fname[1024]; long fpos = -1; int32_t hdrsi,checki; FILE *fp; + struct iguana_ramchaindata *rdata,tmp; char fname[1024]; long fpos = -1; int32_t hdrsi,checki = 0; FILE *fp; if ( (rdata= ramchain->H.data) == 0 ) { printf("ramchainsave no data ptr\n"); @@ -1045,7 +1045,7 @@ long iguana_ramchain_save(struct iguana_info *coin,RAMCHAIN_FUNC,uint32_t ipbits iguana_ramchain_lhashes(fname,RAMCHAIN_ARG,rdata,rdata,bp!=0?bp->n:1,ramchain->H.scriptoffset,zcash); tmp = *rdata; iguana_ramchain_compact(fname,RAMCHAIN_ARG,&tmp,rdata,bp!=0?bp->n:1,zcash); - if ( 0 && ramchain->expanded != 0 ) + if ( (0) && ramchain->expanded != 0 ) printf("compact.%s: Koffset.%d scriptoffset.%d stacksize.%d allocsize.%d\n",fname,(int32_t)rdata->Koffset,ramchain->H.scriptoffset,ramchain->H.stacksize,(int32_t)rdata->allocsize); if ( fwrite(&tmp,1,sizeof(tmp),fp) != sizeof(tmp) ) { @@ -1346,7 +1346,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha bp->startutxo = bp->utxofinish = (uint32_t)time(NULL); if ( bp->Xvalid == 0 ) { - if ( 0 && (rand() % 10) == 0 ) + if ( (0) && (rand() % 10) == 0 ) printf("[%d] filesize %ld Xspendptr.%p %p num.%d\n",bp->hdrsi,filesize,ramchain->Xspendptr,ramchain->Xspendinds,ramchain->numXspends); bp->Xvalid = 1; } @@ -1362,7 +1362,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha ramchain->Xspendinds = 0; } } - else if ( 0 && iter == 1 ) + else if ( (0) && iter == 1 ) printf("couldnt map.(%s)\n",fname); } return(ramchain->numXspends); @@ -1370,7 +1370,7 @@ int32_t iguana_Xspendmap(struct iguana_info *coin,struct iguana_ramchain *ramcha struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct iguana_info *coin,char *fname,struct iguana_bundle *bp,int32_t numblocks,struct iguana_ramchain *ramchain,struct OS_memspace *hashmem,uint32_t ipbits,bits256 hash2,bits256 prevhash2,int32_t bundlei,long fpos,int32_t allocextras,int32_t expanded,uint8_t zcash) { - RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize; void *ptr; char str[65],str2[65],dirstr[65]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata; + RAMCHAIN_DECLARE; int32_t valid,iter,i,checki,hdrsi; long filesize=0; void *ptr; char str[65],str2[65],dirstr[65]; struct iguana_block *block; struct iguana_zblockRO zRO; struct iguana_ramchaindata *rdata; /*if ( ramchain->expanded != 0 && (ramchain->sigsfileptr == 0 || ramchain->sigsfilesize == 0) ) { sprintf(sigsfname,"sigs/%s/%s",coin->symbol,bits256_str(str,hash2)); @@ -1423,7 +1423,7 @@ struct iguana_ramchain *_iguana_ramchain_map(struct supernet_info *myinfo,struct ramchain->expanded = expanded; ramchain->numblocks = (bp == 0) ? 1 : bp->n; //printf("ptr.%p exp.%d extra.%d %p mapped P[%d] fpos.%d + %ld -> %ld vs %ld offset.%u:%u stack.%u:%u\n",ptr,expanded,allocextras,rdata,(int32_t)rdata->Poffset,(int32_t)fpos,(long)rdata->allocsize,(long)(fpos + rdata->allocsize),ramchain->filesize,rscriptoffset,rdata->scriptspace,rstacksize,rdata->stackspace); - if ( 0 && bp != 0 ) + if ( (0) && bp != 0 ) { /*blocksRO = (struct iguana_blockRO *)rdata; for (i=0; in; i++) @@ -1637,7 +1637,7 @@ int32_t iguana_ramchain_cmp(struct iguana_ramchain *A,struct iguana_ramchain *B, int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_ramchain *dest,struct iguana_ramchain *ramchain,struct iguana_bundle *bp,int16_t bundlei) { RAMCHAIN_DECLARE; RAMCHAIN_DESTDECLARE; RAMCHAIN_DESTZEROES; - int32_t j,hdrsi,prevout,scriptlen; uint32_t timestamp=0,unspentind,sequenceid,destspendind=0,desttxidind=0; uint16_t fileid; uint64_t scriptpos; int64_t crypto777_payment = 0; + int32_t j,hdrsi,prevout,scriptlen; uint32_t timestamp=0,unspentind,sequenceid=0,destspendind=0,desttxidind=0; uint16_t fileid; uint64_t scriptpos; int64_t crypto777_payment = 0; bits256 prevhash; uint64_t value; uint8_t type; struct iguana_unspent *u; struct iguana_txid *tx; struct iguana_ramchaindata *rdata; uint8_t rmd160[20]; //if ( dest != 0 ) @@ -1667,7 +1667,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info { if ( coin->active == 0 ) return(-1);; - if ( 0 && ramchain->expanded == 0 && dest != 0 ) + if ( (0) && ramchain->expanded == 0 && dest != 0 ) printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids); tx = &T[ramchain->H.txidind]; if ( iguana_ramchain_addtxid(coin,RAMCHAIN_ARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 ) @@ -1678,7 +1678,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info if ( dest->expanded != 0 ) iguana_opreturn(myinfo,1,coin,tx->timestamp,bp,0,bp->bundleheight + bundlei,(((uint64_t)bp->hdrsi << 32) | dest->H.unspentind),0,0,0,0); //char str[65]; - if ( 0 && ramchain->expanded == 0 ) + if ( (0) && ramchain->expanded == 0 ) printf("ITER [%d] TXID.%d -> dest.%p desttxid.%d dest->hashmem.%p numtxids.%d\n",rdata->height,ramchain->H.txidind,dest,dest!=0?dest->H.txidind:0,dest!=0?dest->hashmem:0,rdata->numtxids); if ( iguana_ramchain_addtxid(coin,RAMCHAIN_DESTARG,tx->txid,tx->numvouts,tx->numvins,tx->locktime,tx->version,tx->timestamp,bundlei) == 0 ) return(-2); @@ -1689,6 +1689,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info if ( coin->active == 0 ) return(-1); fileid = 0; + unspentind = 0; scriptpos = 0; scriptlen = 0; memset(rmd160,0,sizeof(rmd160)); @@ -1740,7 +1741,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info } //else printf("no script\n");*/ if ( (unspentind= iguana_ramchain_addunspent20(coin,0,RAMCHAIN_ARG,value,0,scriptlen,tx->txid,j,type,bp,rmd160)) == 0 ) return(-4); - if ( 0 ) + if ( (0) ) { int32_t i; for (i=0; i<20; i++) printf("%02x",rmd160[i]); @@ -1839,7 +1840,7 @@ int32_t iguana_ramchain_iterate(struct supernet_info *myinfo,struct iguana_info long iguana_ramchain_data(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_peer *addr,struct iguana_txblock *origtxdata,struct iguana_msgtx *txarray,int32_t txn_count,uint8_t *data,int32_t recvlen,struct iguana_bundle *bp,struct iguana_block *block) { int32_t verifyflag = 0; - RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; + RAMCHAIN_DECLARE; struct iguana_ramchain R,*mapchain,*ramchain = &addr->ramchain; struct iguana_msgtx *tx; char fname[1024]; uint8_t rmd160[20]; struct iguana_ramchaindata *rdata; int32_t i,j,fpos,pubkeysize,sigsize,subdir,firsti=1,err,flag,bundlei=0; uint32_t scriptspace,stackspace; struct iguana_blockRO RO; if ( block == 0 || bp == 0 || addr == 0 || (block != 0 && (bundlei= block->bundlei) < 0) ) { //printf("iguana_ramchain_data: null ptr %p %p %p\n",block,bp,addr); @@ -2028,7 +2029,7 @@ void iguana_blockdelete(struct iguana_info *coin,bits256 hash2,int32_t i) void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,struct iguana_bundle *bp,int32_t i,int32_t deletefile) { void *ptr; int32_t recvlen,height = -1; - if ( 0 && bp != 0 ) + if ( (0) && bp != 0 ) printf("UNMARK.[%d:%d]\n",bp->hdrsi,i); if ( block != 0 ) { @@ -2056,7 +2057,7 @@ void iguana_blockunmark(struct iguana_info *coin,struct iguana_block *block,stru } if ( deletefile != 0 && block != 0 ) iguana_blockdelete(coin,block->RO.hash2,i); - if ( 0 && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) + if ( (0) && coin->RTheight > 0 && height > 0 && height < coin->blocks.hwmchain.height ) { printf("reduce %s HWM height from %d to %d\n",coin->symbol,coin->blocks.hwmchain.height,height); if ( (block= iguana_blockfind("unmark",coin,iguana_blockhash(coin,height))) != 0 ) diff --git a/iguana/iguana_realtime.c b/iguana/iguana_realtime.c index bedc4b911..ddd6d1685 100755 --- a/iguana/iguana_realtime.c +++ b/iguana/iguana_realtime.c @@ -170,7 +170,7 @@ void iguana_RTcoinaddr(struct iguana_info *coin,struct iguana_RTtxid *RTptr,stru } } //printf("%s %.8f [%.8f - %.8f] -> %.8f\n",coinaddr,dstr(value),dstr(coin->RTcredits),dstr(coin->RTdebits),dstr(coin->histbalance)+dstr(coin->RTcredits)-dstr(coin->RTdebits)); - if ( 0 && strcmp("BTC",coin->symbol) != 0 && strcmp("LTC",coin->symbol) != 0 && strcmp("DOGE",coin->symbol) != 0 ) + if ( (0) && strcmp("BTC",coin->symbol) != 0 && strcmp("LTC",coin->symbol) != 0 && strcmp("DOGE",coin->symbol) != 0 ) printf("%lld %s %.8f h %.8f, cr %.8f deb %.8f [%.8f] numunspents.%d %p\n",(long long)polarity,coinaddr,dstr(value),dstr(RTaddr->histbalance),dstr(RTaddr->credits),dstr(RTaddr->debits),dstr(RTaddr->credits)-dstr(RTaddr->debits)+dstr(RTaddr->histbalance),RTaddr->numunspents,unspent); } @@ -352,7 +352,7 @@ struct iguana_RTtxid *iguana_RTtxid_create(struct iguana_info *coin,struct iguan } HASH_ADD_KEYPTR(hh,coin->RTdataset,RTptr->txid.bytes,sizeof(RTptr->txid),RTptr); bits256_str(str,txid); - if ( 0 && strcmp("BTC",coin->symbol) != 0 ) + if ( (0) && strcmp("BTC",coin->symbol) != 0 ) printf("%s.%d txid.(%s) vouts.%d vins.%d version.%d lock.%u t.%u %lld\n",coin->symbol,block->height,str,numvouts,numvins,version,locktime,timestamp,(long long)polarity); } else if ( RTptr->txn_count != txn_count || RTptr->numvouts != numvouts || RTptr->numvins != numvins ) @@ -630,7 +630,7 @@ void *iguana_RTrawdata(struct iguana_info *coin,bits256 hash2,uint8_t *data,int3 return(&ptr[sizeof(*recvlenp) + sizeof(checknumtx)]); } else printf("checklen.%d vs %d, checknumtx %d vs %d\n",checklen,(int32_t)(filesize - sizeof(checklen) - sizeof(checknumtx)),checknumtx,*numtxp); } - else if ( 0 ) + else if ( (0) ) { OS_removefile(fname,0); printf("(%s) removed to suppress errors\n",fname); @@ -701,7 +701,7 @@ int32_t iguana_RTiterate(struct supernet_info *myinfo,struct iguana_info *coin,i { num++; iguana_blockQ("RTiterate",coin,0,-1,block->RO.hash2,1); - if ( 0 && coin->peers != 0 && (n= coin->peers->numranked) > 0 ) + if ( (0) && coin->peers != 0 && (n= coin->peers->numranked) > 0 ) { if ( (addr= coin->peers->ranked[rand() % n]) != 0 ) iguana_sendblockreqPT(coin,addr,0,-1,block->RO.hash2,1); @@ -809,7 +809,7 @@ void iguana_RTnewblock(struct supernet_info *myinfo,struct iguana_info *coin,str }*/ if ( block->height < coin->firstRTheight || block->height >= coin->firstRTheight+sizeof(coin->RTblocks)/sizeof(*coin->RTblocks) ) { - if ( 0 && coin->firstRTheight > 0 ) + if ( (0) && coin->firstRTheight > 0 ) printf("iguana_RTnewblock illegal blockheight.%d\n",block->height); return; } diff --git a/iguana/iguana_recv.c b/iguana/iguana_recv.c index 8a318fb58..d7426af08 100755 --- a/iguana/iguana_recv.c +++ b/iguana/iguana_recv.c @@ -85,7 +85,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, } if ( checkbp != bp || j != bundlei ) bp = 0, bundlei = -1; - if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 ) + if ( (0) && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 ) { if ( block != 0 && block->hdrsi != 0 && block->bundlei != 0 ) { @@ -127,7 +127,7 @@ int32_t iguana_sendblockreqPT(struct iguana_info *coin,struct iguana_peer *addr, iguana_send(coin,addr,serialized,len); if ( block != 0 ) block->issued = addr->pendtime; - if ( 0 && coin->current == bp ) + if ( (0) && coin->current == bp ) printf("REQ.(%s) [%d:%d] %s n.%d\n",bits256_str(hexstr,hash2),bundlei,bp!=0?bp->hdrsi:-1,addr->ipaddr,addr->pendblocks); } else printf("MSG_BLOCK null datalen.%d\n",len); return(len); @@ -267,7 +267,7 @@ int32_t iguana_speculativefind(struct iguana_info *coin,struct iguana_bundle *bp for (j=numcached=0; jn; j++) if ( bp->speculativecache[j] != 0 ) numcached++; - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("cache %s [%d:%d] h.%d s.%d c.%d -> %d\n",bits256_str(str,block->RO.hash2),bp->hdrsi,i,bp->numhashes,bp->numsaved,bp->numcached,numcached); return(i); } @@ -326,7 +326,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s printf("iguana_getblockM: illegal recvlen.%d\n",recvlen); return; } - if ( 0 ) + if ( (0) ) { for (i=0; ispace[0]; i++) if ( txdata->space[i] != 0 ) @@ -356,7 +356,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s { printf("got block that doesnt validate? %s\n",bits256_str(str,origtxdata->zblock.RO.hash2)); return; - } else if ( 0 && coin->enableCACHE != 0 ) + } else if ( (0) && coin->enableCACHE != 0 ) printf("c.%d v.(%s) %s n%d\n",coin->enableCACHE,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr,addr->pendblocks); origtxdata->zblock.txvalid = 1; if ( fromcache == 0 && coin->virtualchain == 0 && addr != 0 && addr != &coin->internaladdr ) @@ -430,7 +430,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s else { iguana_bundletime(coin,bp,bundlei,block,0); - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2)); } } @@ -462,7 +462,7 @@ void iguana_oldgotblockM(struct supernet_info *myinfo,struct iguana_info *coin,s req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen); req->copyflag = 1; req->H = *H; - if ( 0 && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) + if ( (0) && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) { int z; for (z=0; zaddr = addr; //if ( (bits256_cmp(origtxdata->zblock.RO.hash2,coin->blocks.hwmchain.RO.hash2) == 0 || req->zblock.mainchain == 0 || req->zblock.valid == 0 || req->zblock.txvalid == 0) && iguana_RTrawdata(coin,origtxdata->zblock.RO.hash2,0,&len,&numtx,1) == 0 ) queue_enqueue("recvQ",&coin->recvQ,&req->DL); - if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + if ( (0) && strcmp("BTCD",coin->symbol) == 0 ) printf("%s Q.(%s)\n",coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2)); } else printf("nonz fpos.%d %s\n",txdata->zblock.fpos,bits256_str(str,origtxdata->zblock.RO.hash2)); } @@ -609,7 +609,7 @@ int32_t iguana_bundlestats_update(struct iguana_info *coin,struct iguana_block * else { iguana_bundletime(coin,bp,bundlei,block,0); - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("recv [%d:%d] %s\n",bp->hdrsi,bundlei,bits256_str(str,block->RO.hash2)); return(0); } @@ -648,7 +648,7 @@ struct iguana_bundlereq *iguana_recv_bundlereq(struct iguana_info *coin,struct i req = iguana_bundlereq(coin,addr,'B',data,copyflag * recvlen); req->copyflag = 1; req->H = *H; - if ( 0 && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) + if ( (0) && iguana_sethdr(&checkH,coin->chain->netmagic,H->command,req->serializeddata,recvlen) > 0 && memcmp(&checkH,H,sizeof(checkH)) != 0 ) { int z; for (z=0; zenableCACHE != 0) && (strcmp(coin->symbol,"BTC") != 0); req = iguana_recv_bundlereq(coin,addr,copyflag,H,data,recvlen,bp,bundlei,txdata); queue_enqueue("recvQ",&coin->recvQ,&req->DL); - if ( 0 && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) + if ( (0) && bp->hdrsi == 0 && strcmp("SYS",coin->symbol) == 0 ) printf("[%d:%d].s%d %s Q.(%s) %s\n",bp->hdrsi,bundlei,numsaved,coin->symbol,bits256_str(str,origtxdata->zblock.RO.hash2),addr->ipaddr); if ( numsaved < coin->chain->bundlesize ) { @@ -991,14 +991,14 @@ void iguana_gotblockhashesM(struct iguana_info *coin,struct iguana_peer *addr,bi req = iguana_bundlereq(coin,addr,'S',0,0); req->hashes = blockhashes, req->n = n; char str[65]; - if ( 0 && n > 2 && addr != 0 ) + if ( (0) && n > 2 && addr != 0 ) printf("addr.%d %s [%d]\n",addr->rank,bits256_str(str,blockhashes[1]),n); queue_enqueue("recvQ",&coin->recvQ,&req->DL); if ( strcmp("BTC",coin->symbol) != 0 ) { if ( n > coin->chain->bundlesize ) iguana_sendblockreqPT(coin,addr,0,-1,blockhashes[1],0); - if ( 0 && coin->RTheight > 0 ) + if ( (0) && coin->RTheight > 0 ) { for (i=1; ihdrsi < coin->MAXBUNDLES || (coin->current != 0 && coin->lastpending != 0 && bp->hdrsi >= coin->current->hdrsi && bp->hdrsi <= coin->lastpending->hdrsi) ) // n = iguana_bundleissuemissing(myinfo,coin,bp,1,3.); - if ( 0 && n > 2 ) + if ( (0) && n > 2 ) printf("ALLHASHES FOUND! %d allhashes.%d issued %d\n",bp->bundleheight,coin->allhashes,n); //if ( bp->queued == 0 ) // iguana_bundleQ(myinfo,coin,bp,bp->n*5 + (rand() % 500)); @@ -1105,7 +1105,7 @@ int32_t iguana_bundlehashadd(struct iguana_info *coin,struct iguana_bundle *bp,i if ( firstflag != 0 && bp->emitfinish == 0 ) { //block->fpos = -1; - if ( 0 && iguana_ramchainfile(SuperNET_MYINFO(0),coin,0,&blockR,bp,bundlei,block) == 0 ) + if ( (0) && iguana_ramchainfile(SuperNET_MYINFO(0),coin,0,&blockR,bp,bundlei,block) == 0 ) { size = sizeof(blockR); iguana_ramchain_free(coin,&blockR,1); @@ -1192,7 +1192,7 @@ void iguana_mainchain_clear(struct supernet_info *myinfo,struct iguana_info *coi return; } } - if ( 0 && tmp != mainchain && coin->RTheight > 0 ) + if ( (0) && tmp != mainchain && coin->RTheight > 0 ) printf("iguana_mainchain_clear: unexpected mismatch ht.%d vs %d %s\n",tmp->height,mainchain->height,bits256_str(str,tmp->RO.hash2)); } } @@ -1208,7 +1208,7 @@ int32_t iguana_height_estimate(struct iguana_info *coin,struct iguana_block **ma if ( tmp->mainchain != 0 && tmp->height >= 0 ) { char str[65]; - if ( 0 && n > 0 && coin->RTheight > 0 ) + if ( (0) && n > 0 && coin->RTheight > 0 ) printf("%s M.%d dist.%d -> %d\n",bits256_str(str,block->RO.hash2),tmp->height,n,tmp->height+n); *mainchainp = tmp; return(tmp->height + n); @@ -1416,7 +1416,7 @@ struct iguana_bundlereq *iguana_recvblockhdrs(struct supernet_info *myinfo,struc prevhash2 = zblocks[i].RO.hash2; } char str[65]; - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("i.%d n.%d match.%d blockhdrs.%s hdrsi.%d\n",i,n,match,bits256_str(str,zblocks[0].RO.hash2),firstbp!=0?firstbp->hdrsi:-1); /*if ( firstbp != 0 && match >= coin->chain->bundlesize-1 ) { @@ -1479,7 +1479,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str memset(zero.bytes,0,sizeof(zero)); bp = 0, bundlei = -2; iguana_bundlefind(coin,&bp,&bundlei,blockhashes[1]); - if ( 0 && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize ) + if ( (0) && strcmp("BTCD",coin->symbol) == 0 )//0 && num >= coin->chain->bundlesize ) printf("blockhashes[%d] %d of %d %s bp.%d[%d]\n",num,bp==0?-1:bp->hdrsi,coin->bundlescount,bits256_str(str,blockhashes[1]),bp==0?-1:bp->bundleheight,bundlei); if ( num < 2 ) return(req); @@ -1510,7 +1510,7 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str iguana_blockQ("recvhash1",coin,0,-1,bp->nextbundlehash2,1); } //printf("call allhashes\n"); - if ( 0 && bp->hdrsi == coin->bundlescount-1 ) + if ( (0) && bp->hdrsi == coin->bundlescount-1 ) iguana_autoextend(myinfo,coin,bp); if ( iguana_allhashcmp(myinfo,coin,bp,blockhashes,num) > 0 ) return(req); @@ -1567,11 +1567,11 @@ struct iguana_bundlereq *iguana_recvblockhashes(struct supernet_info *myinfo,str { blockhashes[0] = bp->hashes[0]; vcalc_sha256(0,allhash.bytes,blockhashes[0].bytes,coin->chain->bundlesize * sizeof(*blockhashes)); - if ( 0 && i == starti ) + if ( (0) && i == starti ) printf("vcalc.(%s) [%d].(%s)\n",bits256_str(str,allhash),bp->hdrsi,bits256_str(str2,bp->hashes[0])); if ( bits256_cmp(allhash,bp->allhash) == 0 ) { - if ( 0 && bp->speculative == 0 ) + if ( (0) && bp->speculative == 0 ) printf("matched allhashes.[%d]\n",bp->hdrsi); if ( bp->queued != 0 ) bp->queued = 0; @@ -1655,11 +1655,11 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig coin->longestchain = prevblock->height+1; } else iguana_blockQ("prev",coin,0,-1,origblock->RO.prev_block,1); } - if ( 0 && block != 0 ) + if ( (0) && block != 0 ) printf("%s received.(%s) [%d:%d]\n",coin->symbol,bits256_str(str,origblock->RO.hash2),block->hdrsi,block->bundlei); if ( (bp= iguana_bundleset(myinfo,coin,&block,&bundlei,(struct iguana_block *)origblock)) != 0 && bp == coin->current && block != 0 && bp->speculative != 0 && bundlei >= 0 ) { - if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + if ( (0) && strcmp("BTCD",coin->symbol) == 0 ) printf("%s received.(%s) %s\n",coin->symbol,bits256_str(str,origblock->RO.hash2),addr->ipaddr); if ( bp->speculative != 0 && bp->numspec <= bundlei ) { @@ -1730,7 +1730,7 @@ struct iguana_bundlereq *iguana_recvblock(struct supernet_info *myinfo,struct ig } } // else printf("RECV MAINCHAIN.%d\n",coin->blocks.hwmchain.height); } - if ( 0 && time(NULL) > bp->hdrtime+3 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current ) + if ( (0) && time(NULL) > bp->hdrtime+3 && bundlei == 1 && bp != 0 && bp->numhashes < bp->n && strcmp("BTC",coin->symbol) != 0 && bp->speculative == 0 && bp == coin->current ) { printf("reissue hdrs request for [%d]\n",bp->hdrsi); bp->hdrtime = (uint32_t)time(NULL); @@ -1916,7 +1916,7 @@ int32_t iguana_reqblocks(struct supernet_info *myinfo,struct iguana_info *coin) if ( 1 && (rand() % 100000) == 0 )//|| bp->bundleheight > coin->longestchain-coin->chain->bundlesize ) printf("%s %s MAIN.%d t %.3f lag %.3f\n",coin->symbol,bits256_str(str,hash2),coin->blocks.hwmchain.height+1,threshold,lag); } - if ( 0 && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) + if ( (0) && bp != 0 && bundlei < bp->n-1 && (bits256_nonz(bp->hashes[bundlei+1]) != 0 || (bp->speculative != 0 && bits256_nonz(bp->speculative[bundlei+1]) != 0)) ) { int32_t j; //memset(bp->hashes[bundlei].bytes,0,sizeof(bp->hashes[bundlei])); @@ -2014,7 +2014,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) if ( now > bp->issuetime+lag && now > bp->hdrtime+3 ) { bp->hdrtime = now; - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("LAG.%d hdrsi.%d numhashes.%d:%d needhdrs.%d qsize.%d zcount.%d\n",(uint32_t)(now-bp->hdrtime),i,bp->numhashes,bp->n,iguana_needhdrs(coin),queue_size(&coin->hdrsQ),coin->zcount); if ( bp->issuetime == 0 ) coin->numpendings++; @@ -2045,7 +2045,7 @@ int32_t iguana_reqhdrs(struct iguana_info *coin) } } } - if ( 0 && n > 0 ) + if ( (0) && n > 0 ) printf("REQ HDRS pending.%d\n",n); coin->zcount = 0; } @@ -2062,7 +2062,7 @@ int32_t iguana_blockQ(char *argstr,struct iguana_info *coin,struct iguana_bundle //getchar(); return(-1); } - if ( 0 && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 && block != 0 && block->txvalid != 0 ) + if ( (0) && coin->enableCACHE != 0 && iguana_speculativesearch(coin,&block,hash2) != 0 && block != 0 && block->txvalid != 0 ) { //printf("found valid [%d:%d] in blockQ\n",block!=0?block->hdrsi:-1,block!=0?block->bundlei:-1); return(0); @@ -2159,7 +2159,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) { uint8_t serialized[sizeof(struct iguana_msghdr) + sizeof(uint32_t)*32 + sizeof(bits256)]; struct iguana_block *block; struct iguana_blockreq *req=0; char *hashstr=0; bits256 hash2; - int32_t bundlei,priority,i,m,z,pend,limit,height=-1,datalen,flag = 0; struct stritem *hashitem; + int32_t bundlei,priority,i,m=0,z,pend,limit,height=-1,datalen,flag = 0; struct stritem *hashitem; uint32_t now; struct iguana_bundle *bp; struct iguana_peer *ptr; if ( addr->msgcounts.verack == 0 ) return(0); @@ -2193,7 +2193,7 @@ int32_t iguana_pollQsPT(struct iguana_info *coin,struct iguana_peer *addr) } if ( bp == 0 || bp->speculative == 0 || bp == coin->current || bp->hdrsi == coin->bundlescount-1 || bp->numhashes < bp->n ) { - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("%s request HDR.(%s) numhashes.%d [%d]\n",addr!=0?addr->ipaddr:"local",hashstr,bp!=0?bp->numhashes:0,bp!=0?bp->hdrsi:-1); iguana_send(coin,addr,serialized,datalen); addr->pendhdrs++; diff --git a/iguana/iguana_rpc.c b/iguana/iguana_rpc.c index ed70729f7..d88605b6c 100755 --- a/iguana/iguana_rpc.c +++ b/iguana/iguana_rpc.c @@ -1144,7 +1144,7 @@ void iguana_rpcloop(void *args) { static char *jsonbuf; uint16_t port; struct supernet_info *myinfo = args; char filetype[128],content_type[128]; - int32_t recvlen,flag,bindsock,postflag,contentlen,sock,remains,numsent,jsonflag,hdrsize,len; + int32_t recvlen,flag,bindsock,postflag=0,contentlen,sock,remains,numsent,jsonflag=0,hdrsize,len; socklen_t clilen; char helpname[512],remoteaddr[64],*buf,*retstr,*space;//,*retbuf; ,n,i,m struct sockaddr_in cli_addr; uint32_t ipbits,i,size = IGUANA_WIDTH*IGUANA_HEIGHT*16 + 512; if ( (port= myinfo->argport) == 0 ) diff --git a/iguana/iguana_scripts.c b/iguana/iguana_scripts.c index a0cb4a07a..d8bd60c71 100755 --- a/iguana/iguana_scripts.c +++ b/iguana/iguana_scripts.c @@ -333,9 +333,9 @@ int32_t _iguana_calcrmd160(struct iguana_info *coin,struct vin_info *vp) if ( (plen= vp->spendscript[2]+5) != vp->spendlen ) { return(IGUANA_SCRIPT_STRANGE); - while ( plen < vp->spendlen ) + /*while ( plen < vp->spendlen ) if ( vp->spendscript[plen++] != 0x61 ) // nop - return(IGUANA_SCRIPT_STRANGE); + return(IGUANA_SCRIPT_STRANGE);*/ } return(IGUANA_SCRIPT_76A988AC); } diff --git a/iguana/iguana_secp.c b/iguana/iguana_secp.c index 05e43e01a..614f970e4 100755 --- a/iguana/iguana_secp.c +++ b/iguana/iguana_secp.c @@ -655,9 +655,9 @@ int32_t iguana_schnorr_test(void *ctx) { sigs[i] = sig64[i]; continue; - for (j=0; j<64; j++) - printf("%02x",sig64[i][j]); - printf(" sig[%d]\n",i); + //for (j=0; j<64; j++) + // printf("%02x",sig64[i][j]); + //printf(" sig[%d]\n",i); } for (i=0; i> 8) & 0xff); } else return(-1); memcpy(&serialized[len],msg->redeemscript,p2shlen), len += p2shlen; - if ( 0 ) + if ( (0) ) { int32_t j; for (j=0; jsequence),&msg->sequence); - if ( 0 ) + if ( (0) ) { int32_t i; char str[65]; for (i=0; ipk_scriptlen > 0 ) { memcpy(&serialized[len],msg->pk_script,msg->pk_scriptlen); - if ( 0 ) + if ( (0) ) { int32_t i; for (i=0; ipk_scriptlen; i++) @@ -294,7 +294,7 @@ int32_t iguana_parsevinobj(struct supernet_info *myinfo,struct iguana_info *coin // continue; if ( serialized[len + m + siglen - 1] == SIGHASH_ALL ) memcpy(V->signers[i++].sig,&serialized[len + m],siglen); - if ( 0 ) + if ( (0) ) { int32_t j; for (j=0; jprivkey = privkey; if ( bitcoin_priv2wif(waddr->wifstr,waddr->privkey,coin->chain->wiftype) > 0 ) { - if ( 0 && waddr->wiftype != coin->chain->wiftype ) + if ( (0) && waddr->wiftype != coin->chain->wiftype ) printf("ensurepriv warning: mismatched wiftype %02x != %02x\n",waddr->wiftype,coin->chain->wiftype); - if ( 0 && waddr->addrtype != coin->chain->pubtype ) + if ( (0) && waddr->addrtype != coin->chain->pubtype ) printf("ensurepriv warning: mismatched addrtype %02x != %02x\n",waddr->addrtype,coin->chain->pubtype); } } @@ -1220,7 +1220,7 @@ cJSON *iguana_pubkeysjson(uint8_t *pubkeyptrs[],int32_t numpubkeys) cJSON *bitcoin_txinput(struct iguana_info *coin,cJSON *txobj,bits256 txid,int32_t vout,uint32_t sequenceid,uint8_t *spendscript,int32_t spendlen,uint8_t *redeemscript,int32_t p2shlen,uint8_t *pubkeys[],int32_t numpubkeys,uint8_t *sig,int32_t siglen) { - cJSON *item,*vins; char p2shscriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t *script,len; + cJSON *item,*vins; char p2shscriptstr[IGUANA_MAXSCRIPTSIZE*2+1]; uint8_t *script,len=0; vins = jduplicate(jobj(txobj,"vin")); jdelete(txobj,"vin"); item = cJSON_CreateObject(); @@ -1284,7 +1284,7 @@ cJSON *bitcoin_txoutput(cJSON *txobj,uint8_t *paymentscript,int32_t len,uint64_t int32_t iguana_interpreter(struct iguana_info *coin,cJSON *logarray,int64_t nLockTime,struct vin_info *V,int32_t numvins) { - uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item; + uint8_t script[IGUANA_MAXSCRIPTSIZE],*activescript,savescript[IGUANA_MAXSCRIPTSIZE]; char str[IGUANA_MAXSCRIPTSIZE*2+1]; int32_t vini,scriptlen,activescriptlen,savelen,errs = 0; cJSON *spendscript,*item=0; for (vini=0; vini>1) < maxsize ) { serialized = malloc(maxsize); @@ -1421,13 +1422,13 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf decode_hex(serialized,len,rawtx); if ( (txobj= bitcoin_hex2json(coin,height,&txid,msgtx,rawtx,extraspace,extralen,serialized4,vins,V->suppress_pubkeys)) != 0 ) { - if ( 0 && vins != 0 ) + if ( (0) && vins != 0 ) printf("txobj.(%s)\n",jprint(txobj,0)); if ( jobj(txobj,"error") != 0 ) { printf("txobj.(%s)\n",jprint(txobj,0)); } - if ( 0 && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,V)) != 0 ) // no guarantee of identical regen + if ( (0) && (checkstr= bitcoin_json2hex(myinfo,coin,&txid,txobj,V)) != 0 ) // no guarantee of identical regen { if ( strcmp(rawtx,checkstr) != 0 ) { @@ -1467,6 +1468,7 @@ int32_t iguana_signrawtransaction(struct supernet_info *myinfo,struct iguana_inf if ( msgtx->vins[i].p2shlen != 0 ) { char coinaddr[64]; uint32_t userdatalen,sigsize,pubkeysize; uint8_t *userdata; int32_t j,k,hashtype,type,flag; struct vin_info mvin,mainvin; bits256 zero; + memset(zero.bytes,0,sizeof(zero)); coinaddr[0] = 0; sigsize = 0; flag = (msgtx->vins[i].vinscript[0] == 0); diff --git a/iguana/iguana_spendvectors.c b/iguana/iguana_spendvectors.c index 2da998af4..7a0cc5a27 100755 --- a/iguana/iguana_spendvectors.c +++ b/iguana/iguana_spendvectors.c @@ -238,8 +238,8 @@ struct iguana_bundle *iguana_fastexternalspent(struct supernet_info *myinfo,stru int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coin,struct iguana_bundle *bp,struct iguana_ramchain *ramchain,int32_t starti,int32_t numblocks,int32_t convertflag,int32_t iterate) { static uint64_t total,emitted; - int32_t iter,spendind,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis; bits256 prevhash; - uint32_t spent_unspentind,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata; + int32_t iter,spendind=0,n=0,txidind,errs=0,emit=0,i,j,k; double startmillis; bits256 prevhash; + uint32_t spent_unspentind=0,spent_pkind,now,starttime; struct iguana_ramchaindata *rdata; struct iguana_bundle *spentbp; struct iguana_blockRO *B; struct iguana_spendvector *ptr; struct iguana_unspent *u,*spentU; struct iguana_txid *T; char str[65]; struct iguana_spend *S,*s; //void *fastfind = 0; @@ -270,7 +270,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi ptr = mycalloc('x',sizeof(*ptr),n); total += n; startmillis = OS_milliseconds(); - if ( 0 && strcmp(coin->symbol,"BTC") == 0 ) + if ( (0) && strcmp(coin->symbol,"BTC") == 0 ) printf("start UTXOGEN.%d max.%d ptr.%p millis.%.3f\n",bp->bundleheight,n,ptr,startmillis); starttime = (uint32_t)time(NULL); iguana_ramchain_prefetch(coin,&bp->ramchain,3); @@ -383,7 +383,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi ptr[emit].unspentind = spent_unspentind; ptr[emit].fromheight = bp->bundleheight + i; ptr[emit].tmpflag = 1; - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("fromht.%d spends [%d] TMPVECTOR u%d s%u\n",ptr[emit].fromheight,ptr[emit].hdrsi,ptr[emit].unspentind,spendind); emit++; } @@ -436,7 +436,7 @@ int32_t iguana_spendvectors(struct supernet_info *myinfo,struct iguana_info *coi //printf("ALLOC tmpspends.[%d]\n",bp->hdrsi); ptr = 0; } - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("spendvectors.[%d]: tmpspends.%p[%d] after += emit.%d X.%p\n",bp->hdrsi,bp->tmpspends,bp->numtmpspends,emit,bp->ramchain.Xspendinds); } else errs = -iguana_spendvectorsave(coin,bp,ramchain,ptr!=0?ptr:bp->tmpspends,emit,n); } @@ -486,12 +486,12 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig spendind = B[starti].firstvin; unspentind = B[starti].firstvout; emit = startemit; - if ( 0 && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) + if ( (0) && (coin->RTheight == 0 || bp->bundleheight+bp->n < coin->RTheight) ) fprintf(stderr,"BALANCEGEN.[%d] %p[%d] starti.%d s%d <-> endi.%d s%d startemit.%d\n",bp->hdrsi,Xspendinds,numXspends,starti,spendind,endi,B[endi].firstvin+B[endi].numvins,startemit); for (i=starti; i<=endi; i++) { now = (uint32_t)time(NULL); - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("hdrs.[%d] B[%d] 1st txidind.%d txn_count.%d firstvin.%d firstvout.%d\n",bp->hdrsi,i,B[i].firsttxidind,B[i].txn_count,B[i].firstvin,B[i].firstvout); if ( txidind != B[i].firsttxidind || spendind != B[i].firstvin || unspentind != B[i].firstvout ) { @@ -506,7 +506,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig printf("balancegen: txidind %u != %u T[txidind].firsttxidind || spendind %u != %u T[txidind].firstvin errs.%d (%d %d)\n",txidind,(uint32_t)T[txidind].txidind,spendind,(uint32_t)T[txidind].firstvin,errs,unspentind,B[i].firstvout); return(-1); } - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("starti.%d txidind.%d txi.%d numvins.%d spendind.%d\n",i,txidind,j,T[txidind].numvins,spendind); /*if ( bp == coin->current )//ramchain == &coin->RTramchain ) { @@ -541,7 +541,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig spent_hdrsi = spend->hdrsi; h = spend->fromheight; } - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("external prevout.%d (emit.%d numX.%d) %p u%d p%d errs.%d spent_hdrsi.%d s%u\n",s->prevout,emit,numXspends,Xspendinds,spent_unspentind,spent_pkind,errs,spent_hdrsi,spendind); } else if ( s->prevout >= 0 ) @@ -567,7 +567,7 @@ int32_t iguana_balancegen(struct iguana_info *coin,int32_t incremental,struct ig spentbp = 0; if ( (spentbp= coin->bundles[spent_hdrsi]) != 0 && spent_unspentind > 0 && spent_pkind > 0 ) { - if ( 0 && bp == coin->current ) + if ( (0) && bp == coin->current ) printf("[%d] spendind.%u -> [%d] u%d\n",bp->hdrsi,spendind,spent_hdrsi,spent_unspentind); if ( iguana_volatileupdate(coin,incremental,&spentbp->ramchain,spent_hdrsi,spent_unspentind,spent_pkind,spent_value,spendind,h) < 0 ) //(spentbp == coin->current) ? &coin->RTramchain : errs++; @@ -967,7 +967,7 @@ int32_t iguana_balanceflush(struct supernet_info *myinfo,struct iguana_info *coi } char str[65]; printf("BALANCES WRITTEN for %d orig.%d bundles %s\n",coin->balanceswritten,coin->origbalanceswritten,bits256_str(str,coin->balancehash)); //iguana_utxoaddr_gen(myinfo,coin,(coin->balanceswritten - 1) * coin->chain->bundlesize); - if ( 0 && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 && + if ( (0) && coin->balanceswritten > coin->origbalanceswritten+10 ) // strcmp(coin->symbol,"BTC") == 0 && { coin->active = 0; coin->started = 0; @@ -1119,7 +1119,7 @@ int32_t iguana_convert(struct iguana_info *coin,int32_t helperid,struct iguana_b total[helperid % max] += converted; for (i=sum=0; icurrent ) + if ( (0) && converted != 0 && bp != coin->current ) printf("[%4d] millis %7.3f converted.%-7d balance calc.%-4d of %4d | total.%llu of %llu depth.%d\n",bp->hdrsi,OS_milliseconds()-startmillis,converted,m,n,(long long)sum,(long long)total_tmpspends,(int32_t)depth); } depth--; @@ -1134,7 +1134,7 @@ int32_t iguana_bundlevalidate(struct supernet_info *myinfo,struct iguana_info *c if ( coin->chain->zcash != 0 ) { static uint32_t counter; - if ( 0 && counter++ < 3 ) + if ( (0) && counter++ < 3 ) printf("need to process joinsplits before can validate.%s\n",coin->symbol); bp->validated = (uint32_t)time(NULL); forceflag = 1; diff --git a/iguana/iguana_tx.c b/iguana/iguana_tx.c index 36972a0c6..e096ab1bb 100755 --- a/iguana/iguana_tx.c +++ b/iguana/iguana_tx.c @@ -44,7 +44,7 @@ int32_t iguana_scriptdata(struct iguana_info *coin, uint8_t *scriptspace, long f memcpy(scriptspace,(void *)(fileptr[0] + (uint32_t)scriptpos),scriptlen); return(retval); } - else if ( 0 ) + else if ( (0) ) { printf("munmap (%s)\n",fname); munmap((void *)fileptr[0],fileptr[1]); @@ -350,7 +350,7 @@ int32_t iguana_peerblockrequest(struct supernet_info *myinfo,struct iguana_info { addr->lastsent = block->height; printf("Sendlen.%d block.%d %s to %s\n",total,block->height,bits256_str(str,block->RO.hash2),addr->ipaddr); - if ( 0 ) + if ( (0) ) { struct iguana_txblock txdata; int32_t checklen; static struct OS_memspace RAWMEM; if ( RAWMEM.ptr == 0 ) diff --git a/iguana/iguana_txidfind.c b/iguana/iguana_txidfind.c index 6db6d03ed..6f9e81f52 100755 --- a/iguana/iguana_txidfind.c +++ b/iguana/iguana_txidfind.c @@ -18,7 +18,7 @@ int32_t iguana_alloctxbits(struct iguana_info *coin,struct iguana_ramchain *ramchain) { static int64_t total; struct iguana_ramchaindata *rdata; - if ( 0 && ramchain->txbits == 0 && (rdata= ramchain->H.data) != 0 ) + if ( (0) && ramchain->txbits == 0 && (rdata= ramchain->H.data) != 0 ) { int32_t tlen; uint8_t *TXbits; TXbits = RAMCHAIN_PTR(rdata,TXoffset); @@ -65,7 +65,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl printf("iguana_sparseadd tablesize zero illegal\n"); return(0); } - if ( 0 && setind == 0 ) + if ( (0) && setind == 0 ) { char str[65]; for (i=n=0; isparsesearches++; //else ramchain->sparseadds++; - if ( 0 && (rdata= ramchain->H.data) != 0 && (ramchain->sparsesearches % 1000000) == 0 ) + if ( (0) && (rdata= ramchain->H.data) != 0 && (ramchain->sparsesearches % 1000000) == 0 ) printf("[%3d] %7d.[%-2d %8d] %5.3f adds.(%-10ld %10ld) search.(hits.%-10ld %10ld) %5.2f%% max.%ld\n",ramchain->height/rdata->numblocks,ramchain->height,width,tablesize,(double)(ramchain->sparseadditers + ramchain->sparsesearchiters)/(1+ramchain->sparsesearches+ramchain->sparseadds),ramchain->sparseadds,ramchain->sparseadditers,ramchain->sparsehits,ramchain->sparsesearches,100.*(double)ramchain->sparsehits/(1+ramchain->sparsesearches),ramchain->sparsemax+1); if ( width == 32 ) { @@ -123,7 +123,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl else { bitoffset = (ind * width); - if ( 0 && setind == 0 ) + if ( (0) && setind == 0 ) printf("tablesize.%d width.%d bitoffset.%d\n",tablesize,width,(int32_t)bitoffset); for (i=0; i> 3]; modval = (bitoffset & 7); - if ( 0 && setind == 0 ) + if ( (0) && setind == 0 ) printf("tablesize.%d width.%d bitoffset.%d modval.%d i.%d\n",tablesize,width,(int32_t)bitoffset,modval,i); for (x=j=0; j> 3]; - if ( 0 && setind == 0 ) + if ( (0) && setind == 0 ) printf("x.%d\n",x); if ( x == 0 ) { @@ -179,7 +179,7 @@ uint32_t iguana_sparseadd(uint8_t *bits,uint32_t ind,int32_t width,uint32_t tabl } } else bits[bitoffset >> 3] = setind; - if ( 0 ) + if ( (0) ) { for (x=j=0; jn; j++) @@ -395,7 +395,7 @@ int32_t iguana_txidfastfind(struct iguana_info *coin,int32_t *heightp,bits256 tx } return(firstvout); } - else if ( 0 ) + else if ( (0) ) { int32_t k; for (k=-16; k<0; k++) @@ -497,7 +497,7 @@ uint32_t iguana_fastfindinit(struct iguana_info *coin) { fprintf(stderr,"."); sorted = coin->fast[i]; - if ( 0 ) + if ( (0) ) { coin->fast[i] = calloc(1,coin->fastsizes[i]); memcpy(coin->fast[i],sorted,coin->fastsizes[i]); @@ -509,7 +509,7 @@ uint32_t iguana_fastfindinit(struct iguana_info *coin) if ( (num+1)*16 + tablesize*sizeof(*hashtable) == coin->fastsizes[i] ) { hashtable = (int32_t *)((long)sorted + (1 + num)*16); - if ( 0 ) + if ( (0) ) { coin->fasttables[i] = calloc(tablesize,sizeof(*hashtable)); memcpy(coin->fasttables[i],hashtable,tablesize * sizeof(*hashtable)); diff --git a/iguana/iguana_unspents.c b/iguana/iguana_unspents.c index dea1a720c..0a2951429 100755 --- a/iguana/iguana_unspents.c +++ b/iguana/iguana_unspents.c @@ -361,7 +361,7 @@ struct iguana_pkhash *iguana_pkhashfind(struct iguana_info *coin,struct iguana_r { if ( (bp= coin->bundles[i]) != 0 ) { - if ( 0 && coin->RTramchain_busy != 0 ) + if ( (0) && coin->RTramchain_busy != 0 ) { printf("iguana_pkhashfind: unexpected access when RTramchain_busy\n"); return(0); @@ -511,10 +511,10 @@ int32_t iguana_RTscanunspents(struct supernet_info *myinfo,struct iguana_info *c int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info *coin,cJSON *array,uint64_t *spentp,struct iguana_outpoint *unspents,int32_t *nump,struct iguana_ramchain *ramchain,struct iguana_pkhash *p,struct iguana_outpoint lastpt,uint8_t rmd160[20],char *coinaddr,uint8_t *pubkey33,int32_t lastheight,int32_t minconf,int32_t maxconf,char *remoteaddr,int32_t includespent) { - struct iguana_unspent *U; struct iguana_utxo *U2; int32_t firstslot,vout,spentflag,max,uheight,spentheight; uint32_t pkind=0,unspentind; uint64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; uint64_t RTspend = 0; bits256 txid; + struct iguana_unspent *U; struct iguana_utxo *U2; int32_t firstslot,vout,spentflag,max,uheight,spentheight=0; uint32_t pkind=0,unspentind; uint64_t spent = 0,checkval,deposits = 0; struct iguana_txid *T; struct iguana_account *A2; struct iguana_outpoint outpt; struct iguana_ramchaindata *rdata = 0; uint64_t RTspend = 0; bits256 txid; max = *nump; *spentp = *nump = 0; - if ( 0 && coin->RTramchain_busy != 0 ) + if ( (0) && coin->RTramchain_busy != 0 ) { printf("iguana_pkhashbalance: unexpected access when RTramchain_busy\n"); return(0); @@ -599,7 +599,7 @@ int64_t iguana_RTpkhashbalance(struct supernet_info *myinfo,struct iguana_info * } unspentind = U2[unspentind].prevunspentind; } - if ( 0 && llabs((int64_t)spent - (int64_t)checkval - (int64_t)RTspend) > SMALLVAL ) + if ( (0) && llabs((int64_t)spent - (int64_t)checkval - (int64_t)RTspend) > SMALLVAL ) printf("spend %s: [%d] deposits %.8f spent %.8f check %.8f (%.8f) vs A2[%u] %.8f\n",lastheight==IGUANA_MAXHEIGHT?"checkerr":"",lastpt.hdrsi,dstr(deposits),dstr(spent),dstr(checkval)+dstr(RTspend),dstr(*spentp),pkind,dstr(A2[pkind].total)); } (*spentp) = spent; @@ -613,7 +613,7 @@ int32_t iguana_RTpkhasharray(struct supernet_info *myinfo,struct iguana_info *co int32_t i,n,m,numunspents; uint64_t spent,deposits,netbalance,total; struct iguana_outpoint lastpt; struct iguana_pkhash *p,_p; struct iguana_ramchain *ramchain; struct iguana_bundle *bp; if ( coin->RTheight == 0 ) return(-1); - if ( 0 && coin->RTramchain_busy != 0 ) + if ( (0) && coin->RTramchain_busy != 0 ) { printf("iguana_pkhasharray: unexpected access when RTramchain_busy\n"); return(-1); @@ -682,7 +682,7 @@ uint64_t iguana_RTunspents(struct supernet_info *myinfo,struct iguana_info *coin { uint64_t total=0,sum=0; struct iguana_pkhash *P; uint8_t *addrtypes,*pubkeys; int32_t i,j,numunspents,maxunspents,flag = 0; char coinaddr[64]; //portable_mutex_lock(&coin->RTmutex); - while ( 0 && coin->RTramchain_busy != 0 ) + while ( (0) && coin->RTramchain_busy != 0 ) { fprintf(stderr,"iguana_pkhasharray: %s unexpected access when RTramchain_busy\n",coin->symbol); sleep(1); @@ -1181,7 +1181,7 @@ cJSON *iguana_RTlistunspent(struct supernet_info *myinfo,struct iguana_info *coi int32_t iguana_RTunspentslists(struct supernet_info *myinfo,struct iguana_info *coin,uint64_t *totalp,struct iguana_outpoint *unspents,int32_t max,uint64_t required,int32_t minconf,cJSON *addresses,char *remoteaddr) { - uint64_t sum = 0; int32_t i,n,firstslot,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item; + uint64_t sum = 0; int32_t i=0,n,firstslot,numunspents,numaddrs; uint8_t pubkey[65]; char *coinaddr,*spendscriptstr; struct iguana_outpoint outpt; cJSON *array,*item; *totalp = 0; numunspents = 0; if ( (numaddrs= cJSON_GetArraySize(addresses)) == 0 ) @@ -1538,7 +1538,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c sum = 0; bitcoin_address(coinaddr,utxoaddr->p2sh == 0 ? coin->chain->pubtype : coin->chain->p2shtype,utxoaddr->rmd160,sizeof(utxoaddr->rmd160)); numunspents += iguana_RTaddr_unspents(myinfo,coin,&sum,&unspents[numunspents],max-numunspents,coinaddr,0,lastheight,0); - if ( 0 && utxoaddr->histbalance != 0 && strcmp(coin->symbol,"BTCD") == 0 ) + if ( (0) && utxoaddr->histbalance != 0 && strcmp(coin->symbol,"BTCD") == 0 ) { total += utxoaddr->histbalance; //printf("fiat/revs sendtoaddress %s %.8f # total %.8f\n",coinaddr,dstr(utxoaddr->histbalance),dstr(total)); @@ -1554,7 +1554,7 @@ int32_t iguana_utxoaddr_check(struct supernet_info *myinfo,struct iguana_info *c flag = 1; //break; } - if ( 0 && flag == 0 )//sum != utxoaddr->histbalance || checkbalance != sum ) + if ( (0) && flag == 0 )//sum != utxoaddr->histbalance || checkbalance != sum ) { bad++; for (i=0; ibundlescount-1; hdrsi++) { if ( (bp= coin->bundles[hdrsi]) != 0 && bp->bundleheight < maxheight ) @@ -1633,7 +1633,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co sprintf(fname2,"%s/%s/utxoaddrs.%d",GLOBAL_DBDIR,coin->symbol,height), OS_portable_path(fname2); if ( iguana_utxoaddr_map(coin,fname2) != 0 ) { - if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + if ( (0) && strcmp("BTCD",coin->symbol) == 0 ) errs = iguana_utxoaddr_validate(myinfo,coin,height); printf("nogen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); if ( errs == 0 && coin->histbalance > 0 && height > 0 ) @@ -1731,14 +1731,14 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co { qsort(&table[offsets[ind] * UTXOADDR_ITEMSIZE],counts[ind],UTXOADDR_ITEMSIZE,_utxoaddr_cmp); continue; - for (j=0; jchain->pubtype,UA.rmd160,sizeof(UA.rmd160)); //printf(" [%4d] p%-5d %12.8f ind.%04x %d %s\n",UA.hdrsi,UA.pkind,dstr(UA.histbalance),ind,j,coinaddr); - } + }*/ } } if ( iguana_utxoaddr_save(coin,fname,balance,counts,offsets,table) == 0 ) @@ -1762,7 +1762,7 @@ uint64_t iguana_utxoaddr_gen(struct supernet_info *myinfo,struct iguana_info *co { printf("validating %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); errs = 0; - if ( 0 && strcmp("BTCD",coin->symbol) == 0 ) + if ( (0) && strcmp("BTCD",coin->symbol) == 0 ) errs = iguana_utxoaddr_validate(myinfo,coin,height); printf("gen %s HIST BALANCE %s %.8f errs %d\n",fname2,bits256_str(str,coin->utxoaddrhash),dstr(coin->histbalance),errs); if ( errs != 0 || height == 0 ) diff --git a/iguana/iguana_volatiles.c b/iguana/iguana_volatiles.c index 8bf4923f1..b671f0012 100755 --- a/iguana/iguana_volatiles.c +++ b/iguana/iguana_volatiles.c @@ -290,7 +290,7 @@ int32_t iguana_volatileupdate(struct iguana_info *coin,int32_t incremental,struc utxo = &spentchain->Uextras[spent_unspentind]; if ( utxo->spentflag == 0 ) { - if ( 0 && fromheight/coin->chain->bundlesize >= coin->current->hdrsi ) + if ( (0) && fromheight/coin->chain->bundlesize >= coin->current->hdrsi ) printf("iguana_volatileupdate.%d: [%d] spent.(u%u %.8f pkind.%d) fromht.%d [%d] spendind.%d\n",incremental,spent_hdrsi,spent_unspentind,dstr(spent_value),spent_pkind,fromheight,fromheight/coin->chain->bundlesize,spendind); utxo->prevunspentind = A2[spent_pkind].lastunspentind; utxo->spendind = spendind; diff --git a/iguana/iguana_wallet.c b/iguana/iguana_wallet.c index 9e7afcaef..11d631d2b 100755 --- a/iguana/iguana_wallet.c +++ b/iguana/iguana_wallet.c @@ -818,7 +818,7 @@ cJSON *iguana_walletiterate(struct supernet_info *myinfo,struct iguana_info *coi } printf("persistent address not found in wallet, autoadd.(%s)\n",coinaddr); } - else if ( persistent_flag != 0 && 0 ) + else if ( persistent_flag != 0 && (0) ) printf("found persistent address in wallet\n"); } portable_mutex_unlock(&myinfo->bu_mutex); @@ -1593,7 +1593,7 @@ STRING_ARG(bitcoinrpc,dumpwallet,filename) { if ( (walletobj= jobj(strobj,"wallet")) != 0 ) jadd(retjson,"wallet",jduplicate(walletobj)); - if ( 0 && (walletobj= iguana_walletjson(myinfo)) != 0 ) + if ( (0) && (walletobj= iguana_walletjson(myinfo)) != 0 ) jadd(retjson,"memory",walletobj); free_json(strobj); } diff --git a/iguana/m b/iguana/m new file mode 100755 index 000000000..ef91df931 --- /dev/null +++ b/iguana/m @@ -0,0 +1,9 @@ +#!/bin/bash +#./configure --enable-endomorphism --enable-module-ecdh --enable-module-schnorr --enable-module-rangeproof --enable-experimental --enable-module_recovery +rm -f ../agents/iguana *.o +git pull +cd secp256k1; ./m_unix; cd .. +cd ../crypto777; ./m_LP; cd ../iguana +clang -g -Wno-deprecated -c -O2 -DLIQUIDITY_PROVIDER=1 *.c ../basilisk/basilisk.c ../gecko/gecko.c ../datachain/datachain.c +clang -g -Wno-deprecated -c -DLIQUIDITY_PROVIDER=1 main.c iguana777.c iguana_bundles.c ../basilisk/basilisk.c +clang -g -o ../agents/iguana *.o ../agents/libcrypto777.a /usr/local/lib/libnanomsg.dylib -lcurl -lssl -lcrypto -lpthread -lz -lm diff --git a/iguana/main.c b/iguana/main.c index d469e7d30..c451568cc 100755 --- a/iguana/main.c +++ b/iguana/main.c @@ -543,7 +543,7 @@ void iguana_appletests(struct supernet_info *myinfo) { char *str; //iguana_chaingenesis(1,1403138561,0x1e0fffff,8359109,bits256_conv("fd1751cc6963d88feca94c0d01da8883852647a37a0a67ce254d62dd8c9d5b2b")); // BTCD - if ( 0 ) + if ( (0) ) { char genesisblock[1024]; //iguana_chaingenesis("VPN",0,bits256_conv("00000ac7d764e7119da60d3c832b1d4458da9bc9ef9d5dd0d91a15f690a46d99"),genesisblock,"scrypt",1,1409839200,0x1e0fffff,64881664,bits256_conv("698a93a1cacd495a7a4fb3864ad8d06ed4421dedbc57f9aaad733ea53b1b5828")); // VPN @@ -571,13 +571,13 @@ void iguana_appletests(struct supernet_info *myinfo) bitcoin_sharedsecret(myinfo->ctx,hash2,pubkey,33); printf("secp256k1 elapsed %.3f for %d iterations\n",OS_milliseconds() - startmillis,i); getchar();**/ - if ( 0 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) + if ( (0) && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"protover\":70002,\"RELAY\":1,\"VALIDATE\":1,\"portp2p\":14631,\"rpc\":14632,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":512,\"endpend\":512,\"services\":129,\"maxpeers\":8,\"newcoin\":\"BTCD\",\"active\":1,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( 1 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTC"),cJSON_Parse("{\"portp2p\":8333,\"RELAY\":0,\"VALIDATE\":0,\"agent\":\"iguana\",\"method\":\"addcoin\",\"startpend\":1,\"endpend\":1,\"services\":128,\"maxpeers\":8,\"newcoin\":\"BTC\",\"active\":0,\"numhelpers\":1,\"poll\":100}"),0,myinfo->rpcport)) != 0 ) { free(str); - if ( 0 && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 ) + if ( (0) && (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"alice\",\"password\":\"alice\",\"passphrase\":\"alice\"}"),0,myinfo->rpcport)) != 0 ) { free(str); if ( (str= SuperNET_JSON(myinfo,iguana_coinfind("BTCD"),cJSON_Parse("{\"agent\":\"SuperNET\",\"method\":\"login\",\"handle\":\"bob\",\"password\":\"bob\",\"passphrase\":\"bob\"}"),0,myinfo->rpcport)) != 0 ) @@ -641,7 +641,7 @@ int32_t iguana_commandline(struct supernet_info *myinfo,char *arg) free(str); } free_json(argjson); - if ( 0 ) + if ( (0) ) { uint32_t buf[81],c; OS_randombytes((void *)buf,sizeof(buf)); @@ -1612,7 +1612,7 @@ void komodo_ICO_batch(cJSON *array,int32_t batchid) printf("# %s KMD %.8f\n",coinaddr,dstr(kmdamount)); if ( (iter & 1) == 0 ) { - if ( 0 ) + if ( (0) ) { printf("curl --url \"http://127.0.0.1:7778\" --data \"{\\\"agent\\\":\\\"dex\\\",\\\"method\\\":\\\"importaddress\\\",\\\"address\\\":\\\"%s\\\",\\\"symbol\\\":\\\"KMD\\\"}\" # %.8f\n",coinaddr,dstr(kmdamount)); printf("sleep 3\n"); @@ -1678,7 +1678,7 @@ void iguana_main(void *arg) #ifdef __APPLE__ char *batchstr,*batchstr2; cJSON *batchjson; long batchsize; char fname[512],fname2[512]; int32_t batchid = 10; sprintf(fname,"REVS.raw"), sprintf(fname2,"REVS.rawtxids"); - if ( 0 && (batchstr= OS_filestr(&batchsize,fname)) != 0 && (batchstr2= OS_filestr(&batchsize,fname2)) != 0 ) + if ( (0) && (batchstr= OS_filestr(&batchsize,fname)) != 0 && (batchstr2= OS_filestr(&batchsize,fname2)) != 0 ) { komodo_REVS_merge(batchstr,batchstr2); } @@ -1763,7 +1763,7 @@ void iguana_main(void *arg) { basilisks_init(myinfo); } - if ( 0 ) + if ( (0) ) { char *jsonstr = "[\"03b7621b44118017a16043f19b30cc8a4cfe068ac4e42417bae16ba460c80f3828\", \"02ebfc784a4ba768aad88d44d1045d240d47b26e248cafaf1c5169a42d7a61d344\", \"03750cf30d739cd7632f77c1c02812dd7a7181628b0558058d4755838117e05339\", \"0394f3529d2e8cc69ffa7a2b55f3761e7be978fa1896ef4c55dc9c275e77e5bf5e\", \"0243c1eeb3777af47187d542e5f8c84f0ac4b05cf5a7ad77faa8cb6d2d56db7823\", \"02bb298844175640a34e908ffdfa2839f77aba3d5edadefee16beb107826e00063\", \"02fa88e549b4b871498f892e527a5d57287916809f8cc3163f641d71c535e8df5a\", \"032f799e370f06476793a122fcd623db7804898fe5aef5572095cfee6353df34bf\", \"02c06fe5401faff4442ef87b7d1b56c2e5a214166615f9a2f2030c71b0cb067ae8\", \"038ac67ca49a8169bcc5de83fe020071095a2c3b2bc4d1c17386977329758956d5\"]"; @@ -1785,4 +1785,4 @@ void iguana_main(void *arg) // features // komodod convert passphrase to privkey // Z -> Z -// iguana init nanomsg in own thread \ No newline at end of file +// iguana init nanomsg in own thread diff --git a/iguana/mini-gmp.c b/iguana/mini-gmp.c index 720cf5fbc..ef9e235df 100644 --- a/iguana/mini-gmp.c +++ b/iguana/mini-gmp.c @@ -4416,6 +4416,7 @@ void mpz_from_bits256(mpz_t bn,bits256 x) bits256 mpz_to_bits256(mpz_t bn) { bits256 x,rev; size_t count; int32_t i; + memset(x.bytes,0,sizeof(x)); mpz_export(rev.bytes,&count,1,sizeof(uint64_t),1,0,bn); for (i=0; i<32; i++) x.bytes[i] = rev.bytes[31-i]; diff --git a/iguana/pangea_api.c b/iguana/pangea_api.c index 3329fd45f..ea7d942e5 100755 --- a/iguana/pangea_api.c +++ b/iguana/pangea_api.c @@ -530,7 +530,7 @@ char *pangea_hexmsg(struct supernet_info *myinfo,struct gecko_chain *cat,void *d } } } - else if ( 0 ) + else if ( (0) ) { for (i=0; ipriv.myind == activej && tp->priv.automuck == 0 ) + if ( (0) && tp->priv.myind == activej && tp->priv.automuck == 0 ) { pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[0].bytes,sizeof(tp->priv.holecards[0]),tp->priv.cardis[0],tp->priv.cardis[0] != 0xff); pangea_sendcmd(myinfo,tp,"faceup",-1,tp->priv.holecards[1].bytes,sizeof(tp->priv.holecards[1]),tp->priv.cardis[1],tp->priv.cardis[1] != 0xff); diff --git a/iguana/pangea_json.c b/iguana/pangea_json.c index c325c4a69..0c3b19840 100755 --- a/iguana/pangea_json.c +++ b/iguana/pangea_json.c @@ -227,6 +227,7 @@ cJSON *pangea_tablestatus(struct supernet_info *myinfo,struct table_info *tp) jaddi64bits(array,tp->active[i]!=0?tp->active[i]->nxt64bits:0); jadd(json,"addrs",array);*/ total = 0; + str = "error"; for (iter=0; iter<6; iter++) { array = cJSON_CreateArray(); @@ -243,22 +244,23 @@ cJSON *pangea_tablestatus(struct supernet_info *myinfo,struct table_info *tp) case 3: val = p->betstatus; str = "status"; break; case 4: val = p->bets; str = "bets"; break; case 5: val = p->won; str = "won"; break; + default: str = "error"; break; } } if ( iter == 5 ) won[i] = val; else { - if ( iter == 3 ) - jaddistr(array,pangea_statusstr((int32_t)val)); - else - { - if ( iter == 4 ) - total += val, bets[i] = val; - else if ( iter == 2 ) - snapshot[i] = val; - jaddinum(array,val); - } + if ( iter == 3 ) + jaddistr(array,pangea_statusstr((int32_t)val)); + else + { + if ( iter == 4 ) + total += val, bets[i] = val; + else if ( iter == 2 ) + snapshot[i] = val; + jaddinum(array,val); + } } } jadd(json,str,array); diff --git a/iguana/ramchain_api.c b/iguana/ramchain_api.c index 90fa47819..7f4878d62 100755 --- a/iguana/ramchain_api.c +++ b/iguana/ramchain_api.c @@ -82,7 +82,7 @@ STRING_ARG(iguana,removecoin,activecoin) { coin->active = 0; coin->started = 0; - if ( 0 ) + if ( (0) ) { for (i=0; i