diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 3e71cb498..02ca131b4 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -473,20 +473,28 @@ void dpow_statemachinestart(void *ptr) } else { - if ( dpow_checkutxo(myinfo,dp,bp,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr,src->symbol) < 0 ) - { - printf("dont have %s %s utxo, please send funds\n",dp->dest,destaddr); - dp->ratifying -= bp->isratify; - free(ptr); - return; - } - if ( dpow_checkutxo(myinfo,dp,bp,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr,"") < 0 ) + if ( dpow_haveutxo(myinfo,bp->destcoin,&ep->dest.prev_hash,&ep->dest.prev_vout,destaddr,src->symbol) > 0 ) + { + if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) ) + { + // lock the dest utxo if destination coin is KMD. + if (dpow_lockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout) != 0) + printf(">>>> LOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + else + printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); + } + } + if ( dpow_haveutxo(myinfo,bp->srccoin,&ep->src.prev_hash,&ep->src.prev_vout,srcaddr,"") > 0 ) + { + if ( ( strcmp("KMD",src->symbol) == 0 ) && (ep->src.prev_vout != -1) ) { - printf("dont have %s %s utxo, please send funds\n",dp->symbol,srcaddr); - dp->ratifying -= bp->isratify; - free(ptr); - return; + // lock the src coin selected utxo if the source coin is KMD. + if (dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout) != 0) + printf(">>>> LOCKED %s UTXO.(%s) vout.(%d\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); + else + printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); } + } if ( bp->isratify != 0 ) { bp->notaries[myind].ratifysrcutxo = ep->src.prev_hash; @@ -508,24 +516,6 @@ void dpow_statemachinestart(void *ptr) dpow_signedtxgen(myinfo,dp,src,bp,bp->myind,1LL<myind,bp->myind,DPOW_SIGCHANNEL,0,0); }*/ - if ( (strcmp("KMD",dest->symbol) == 0 ) && (ep->dest.prev_vout != -1) ) - { - // lock the dest utxo if destination coin is KMD. - if (dpow_lockunspent(myinfo,bp->destcoin,destaddr,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout) != 0) - printf(">>>> LOCKED %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); - else - printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",dest->symbol,bits256_str(str2,ep->dest.prev_hash),ep->dest.prev_vout); - } - - if ( ( strcmp("KMD",src->symbol) == 0 ) && (ep->src.prev_vout != -1) ) - { - // lock the src coin selected utxo if the source coin is KMD. - if (dpow_lockunspent(myinfo,bp->srccoin,srcaddr,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout) != 0) - printf(">>>> LOCKED %s UTXO.(%s) vout.(%d\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); - else - printf("<<<< FAILED TO LOCK %s UTXO.(%s) vout.(%d)\n",src->symbol,bits256_str(str2,ep->src.prev_hash),ep->src.prev_vout); - } - bp->recvmask |= (1LL << myind); bp->notaries[myind].othermask |= (1LL << myind); dp->checkpoint = checkpoint; diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index f5700c1a5..79bd76e60 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -50,7 +50,7 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) { buf[0] = 0; retstr = bitcoind_getinfo(coin->symbol,coin->chain->serverport,coin->chain->userpass,coin->getinfostr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -274,7 +274,7 @@ cJSON *dpow_MoMoMdata(struct iguana_info *coin,char *symbol,int32_t kmdheight,ui printf("%s kmdheight.%d CCid.%u MoMoM.%s -> %s\n",symbol,kmdheight,CCid,buf,retstr); free(retstr); } - usleep(10000); + usleep(1000); } return(retjson); } @@ -350,7 +350,7 @@ bits256 dpow_getblockhash(struct supernet_info *myinfo,struct iguana_info *coin, sprintf(buf,"%d",height); retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getblockhash",buf); //printf("%s ht.%d -> getblockhash.(%s)\n",coin->symbol,height,retstr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -401,7 +401,7 @@ int dpow_unlockunspent(struct supernet_info *myinfo,struct iguana_info *coin,cha } return(0); } - + cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits256 blockhash) { @@ -412,7 +412,7 @@ cJSON *dpow_getblock(struct supernet_info *myinfo,struct iguana_info *coin,bits2 retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getblock",buf); if ( 0 && strcmp(coin->symbol,"USD") == 0 ) printf("%s getblock.(%s)\n",coin->symbol,retstr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -458,7 +458,7 @@ char *dpow_validateaddress(struct supernet_info *myinfo,struct iguana_info *coin } free_json(retjson); } - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -478,7 +478,7 @@ cJSON *dpow_gettxout(struct supernet_info *myinfo,struct iguana_info *coin,bits2 if ( coin->FULLNODE < 0 ) { retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"gettxout",buf); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -509,7 +509,7 @@ char *dpow_decoderawtransaction(struct supernet_info *myinfo,struct iguana_info retstr = bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"decoderawtransaction",paramstr); //printf("%s decoderawtransaction.(%s) <- (%s)\n",coin->symbol,retstr,paramstr); free(paramstr); - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -531,7 +531,7 @@ cJSON *dpow_gettransaction(struct supernet_info *myinfo,struct iguana_info *coin if ( (retstr= bitcoind_passthru(coin->symbol,coin->chain->serverport,coin->chain->userpass,"getrawtransaction",buf)) != 0 ) { } - usleep(10000); + usleep(1000); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) { @@ -648,7 +648,7 @@ char *dpow_signrawtransaction(struct supernet_info *myinfo,struct iguana_info *c } //printf("%s signrawtransaction.(%s) params.(%s)\n",coin->symbol,retstr,paramstr); free(paramstr); - usleep(10000); + usleep(1000); return(retstr); } else if ( coin->FULLNODE > 0 || coin->VALIDATENODE > 0 ) @@ -952,22 +952,17 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits { if ( (n= cJSON_GetArraySize(unspents)) > 0 ) { - /*{ - "txid" : "34bc21b40d6baf38e2db5be5353dd0bcc9fe416485a2a68753541ed2f9c194b1", - "vout" : 0, - "address" : "RFBmvBaRybj9io1UpgWM4pzgufc3E4yza7", - "scriptPubKey" : "21039a3f7373ae91588b9edd76a9088b2871f62f3438d172b9f18e0581f64887404aac", - "amount" : 3.00000000, - "confirmations" : 4282, - "spendable" : true - },*/ - //r = 0; - //memcpy(&r,coin->symbol,3); - //r = calc_crc32(0,(void *)&r,sizeof(r)); - OS_randombytes((uint8_t *)&r,sizeof(r)); - for (j=0; jsymbol,i,n,j); if ( (item= jitem(unspents,i)) == 0 ) continue; if ( is_cJSON_False(jobj(item,"spendable")) != 0 ) @@ -993,7 +988,7 @@ int32_t dpow_haveutxo(struct supernet_info *myinfo,struct iguana_info *coin,bits } } if ( haveutxo == 0 ) - printf("no (%s -> %s) utxo: need to fund address.(%s) or wait for splitfund to confirm\n",srccoin,coin->symbol,coinaddr); + printf("no (%s -> %s) utxo: need to fund address.(%s) or wait for splitfund to confirm\n",srccoin,coin->symbol,coinaddr); } //else printf("null utxo array size\n"); free_json(unspents); } else printf("null return from dpow_listunspent\n"); diff --git a/iguana/dpow/dpow_tx.c b/iguana/dpow/dpow_tx.c index 148827d68..f099eef92 100755 --- a/iguana/dpow/dpow_tx.c +++ b/iguana/dpow/dpow_tx.c @@ -329,7 +329,7 @@ bits256 dpow_notarytx(struct supernet_info *myinfo,char *signedtx,int32_t *numsi memcpy(&serialized[len],sig,siglen); len += siglen; numsigs++; - } //else printf("%s -> %s src_or_dest.%d Missing sig from k.%d\n",bp->srccoin->symbol,bp->destcoin->symbol,src_or_dest,k); + } else printf("%s -> %s src_or_dest.%d Missing sig from k.%d\n",bp->srccoin->symbol,bp->destcoin->symbol,src_or_dest,k); } else serialized[len++] = 0; len += iguana_rwnum(1,&serialized[len],sizeof(sequenceid),&sequenceid); //printf("height.%d mod.%d VINI.%d <- i.%d j.%d\n",height,height % numnotaries,m,i,j); @@ -581,8 +581,8 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo { dpow_notarytx(myinfo,bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,0,src_or_dest,pubkeys,numratified); // setcrcval signedtxid = dpow_notarytx(myinfo,bp->signedtx,&numsigs,coin->chain->isPoS,bp,bestk,bestmask,1,src_or_dest,pubkeys,numratified); - if ( strcmp("GAME",coin->symbol) == 0 || strcmp("EMC2",coin->symbol) == 0 ) - printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx); + //if ( strcmp("GAME",coin->symbol) == 0 || strcmp("EMC2",coin->symbol) == 0 ) + // printf("src_or_dest.%d bestk.%d %llx %s numsigs.%d signedtx.(%s)\n",src_or_dest,bestk,(long long)bestmask,bits256_str(str,signedtxid),numsigs,bp->signedtx); bp->state = 1; if ( bits256_nonz(signedtxid) != 0 && numsigs == bp->minsigs ) { @@ -615,7 +615,14 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo else { bp->state = 0xffffffff; - printf("dpow_sigscheck.(%s): mismatched txid.%s vs %s\n",bp->signedtx,bits256_str(str,txid),retstr); + printf("dpow_sigscheck: [src.%s] mismatched txid.%s vs %s\n",bp->srccoin->symbol,bits256_str(str,txid),retstr); +#ifdef LOGTX + FILE * fptr; + fptr = fopen("/home/node/failed_notarizations", "a+"); + unsigned long dwy_timestamp = time(NULL); + fprintf(fptr, "%lu %s %s %d %s\n", dwy_timestamp, bp->srccoin->symbol,bp->destcoin->symbol,src_or_dest,bp->signedtx); + fclose(fptr); +#endif } free(retstr); retstr = 0; @@ -625,7 +632,6 @@ void dpow_sigscheck(struct supernet_info *myinfo,struct dpow_info *dp,struct dpo printf("NULL return from sendrawtransaction. abort\n"); bp->state = 0xffffffff; } - } else printf("numsigs.%d vs required.%d\n",numsigs,bp->minsigs); + } //else printf("numsigs.%d vs required.%d\n",numsigs,bp->minsigs); } } - diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 4eb574b6a..8174b5075 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -143,7 +143,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks); for (i=ht-DPOW_MAXFREQ*5; i>ht-DPOW_MAXFREQ*100&&i>DPOW_MAXFREQ; i--) { - if ( (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) //(i % DPOW_MAXFREQ) != 0 && + if ( (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) //(i % DPOW_MAXFREQ) != 0 && { if ( dp->currentbp == dp->blocks[i] ) dp->currentbp = 0; @@ -222,8 +222,8 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp) if ( (height= dpow_getchaintip(myinfo,&merkleroot,&blockhash,&blocktime,dp->desttx,&dp->numdesttx,dest)) != dp->destchaintip.blockhash.height && height >= 0 ) { char str[65]; - if ( (0) && strcmp(dp->symbol,"KMD") == 0 )//|| height != dp->destchaintip.blockhash.height+1 ) - printf("[%s].%d %s %s height.%d vs last.%d\n",dp->symbol,dp->SRCHEIGHT,dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height); + //if ( (0) && strcmp(dp->symbol,"KMD") == 0 )//|| height != dp->destchaintip.blockhash.height+1 ) + // printf("[%s].%d %s %s height.%d vs last.%d\n",dp->symbol,dp->SRCHEIGHT,dp->dest,bits256_str(str,blockhash),height,dp->destchaintip.blockhash.height); if ( height <= dp->destchaintip.blockhash.height ) { printf("iguana_dPoWupdate dest.%s reorg detected %d vs %d\n",dp->dest,height,dp->destchaintip.blockhash.height); @@ -242,7 +242,7 @@ void iguana_dPoWupdate(struct supernet_info *myinfo,struct dpow_info *dp) { if ( dp->lastheight == 0 ) dp->lastheight = height-1; - char str[65]; printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->lastheight); + char str[65]; //printf("[%s].%d %s %s height.%d vs last.%d\n",dp->dest,dp->SRCHEIGHT,dp->symbol,bits256_str(str,blockhash),height,dp->lastheight); dp->SRCHEIGHT = height; if ( height < dp->last.blockhash.height ) { @@ -384,7 +384,7 @@ THREE_STRINGS_AND_DOUBLE(iguana,dpow,symbol,dest,pubkey,freq) char tmp[67]; safecopy(tmp,pubkey,sizeof(tmp)); decode_hex(dp->minerkey33,33,tmp); - + if (strcmp(src->chain->symbol, "HUSH") == 0) bitcoin_address_ex(src->chain->symbol, srcaddr, 0x1c, src->chain->pubtype, dp->minerkey33, 33); else @@ -540,7 +540,7 @@ STRING_ARG(iguana,addnotary,ipaddr) } char NOTARY_CURRENCIES[][65] = { - "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "NINJA", "OOT", "CHAIN", "BNTN", "PRLPAY", "DSEC", "GLXT", "EQL", "ZILLA", "RFOX", "SEC", "CCL" + "REVS", "SUPERNET", "DEX", "PANGEA", "JUMBLR", "BET", "CRYPTO", "HODL", "BOTS", "MGW", "COQUI", "WLC", "KV", "CEAL", "MESH", "MNZ", "CHIPS", "MSHARK", "AXO", "ETOMIC", "BTCH", "VOTE2018", "NINJA", "OOT", "CHAIN", "BNTN", "PRLPAY", "DSEC", "GLXT", "EQL", "ZILLA", "RFOX", "SEC", "CCL" }; // "LTC", "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK",