diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 7ee20daa6..eb5638ff4 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -265,7 +265,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65];//,str[65],str2[65],str3[65]; vout = jitem(vouts,numvouts-1); - if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36 && len < sizeof(script)*2 ) + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 35*2 && len < sizeof(script)*2 ) { len >>= 1; decode_hex(script,len,hexstr); @@ -401,7 +401,7 @@ void dpow_statemachinestart(void *ptr) { kmdheight = dest->longestchain; //portable_mutex_lock(&myinfo->MoM_mutex); - if ( Notaries_port != DPOW_SOCKPORT ) + //if ( Notaries_port != DPOW_SOCKPORT ) MoM = dpow_calcMoM(&MoMdepth,myinfo,src,checkpoint.blockhash.height); //portable_mutex_unlock(&myinfo->MoM_mutex); } @@ -638,12 +638,11 @@ void dpow_statemachinestart(void *ptr) extralen = dpow_paxpending(extras,&bp->paxwdcrc,bp->MoM,bp->MoMdepth); bp->notaries[bp->myind].paxwdcrc = bp->paxwdcrc; } - sleep(30); if ( (checkpoint.blockhash.height % 100) != 0 && dp->checkpoint.blockhash.height > checkpoint.blockhash.height ) { if ( bp->isratify == 0 ) { - printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); + //printf("abort %s ht.%d due to new checkpoint.%d\n",dp->symbol,checkpoint.blockhash.height,dp->checkpoint.blockhash.height); break; } } @@ -660,6 +659,7 @@ void dpow_statemachinestart(void *ptr) { printf("%s ht.%d %s got reorged to %s, abort notarization\n",bp->srccoin->symbol,bp->height,bits256_str(str,bp->hashmsg),bits256_str(str2,checkhash)); bp->state = 0xffffffff; + break; } } if ( bp->state != 0xffffffff ) @@ -677,6 +677,7 @@ void dpow_statemachinestart(void *ptr) printf("abort pending ratify\n"); break; } + sleep(30); } printf("[%d] END isratify.%d:%d bestk.%d %llx sigs.%llx state.%x machine ht.%d completed state.%x %s.%s %s.%s recvmask.%llx paxwdcrc.%x %p %p\n",Numallocated,bp->isratify,dp->ratifying,bp->bestk,(long long)bp->bestmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),bp->state,bp->height,bp->state,dp->dest,bits256_str(str,bp->desttxid),dp->symbol,bits256_str(str2,bp->srctxid),(long long)bp->recvmask,bp->paxwdcrc,src,dest); dp->lastrecvmask = bp->recvmask; diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 27ebcf91e..bbbfcad68 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -1901,7 +1901,7 @@ void dpow_notarize_update(struct supernet_info *myinfo,struct dpow_info *dp,stru printf("mypaxcrc.%x\n",bp->paxwdcrc); } char str[65]; - if ( (rand() % 130) == 0 )//|| strcmp(dp->symbol,"CHIPS") == 0 ) + if ( (rand() % 130) == 0 || strcmp(dp->symbol,"CHIPS") == 0 ) printf("%p ht.%d [%d] ips.%d %s NOTARIZE.%d matches.%d paxmatches.%d bestmatches.%d bestk.%d %llx recv.%llx sigmasks.(%llx %llx) senderind.%d state.%x (%x %x %x) MoM.%s [%d]\n",bp,bp->height,bp->myind,dp->numipbits,dp->symbol,bp->minsigs,matches,paxmatches,bestmatches,bp->bestk,(long long)bp->bestmask,(long long)bp->recvmask,(long long)(bp->bestk>=0?bp->destsigsmasks[bp->bestk]:0),(long long)(bp->bestk>=0?bp->srcsigsmasks[bp->bestk]:0),senderind,bp->state,bp->hashmsg.uints[0],bp->desttxid.uints[0],bp->srctxid.uints[0],bits256_str(str,bp->MoM),bp->MoMdepth); } } diff --git a/iguana/dpow/dpow_rpc.c b/iguana/dpow/dpow_rpc.c index 39b5e046b..b649708a1 100755 --- a/iguana/dpow/dpow_rpc.c +++ b/iguana/dpow/dpow_rpc.c @@ -71,11 +71,11 @@ cJSON *dpow_getinfo(struct supernet_info *myinfo,struct iguana_info *coin) return(json); } -char *Notaries_elected[64][2]; +char *Notaries_elected[65][2]; char *seeds[] = { "78.47.196.146", "5.9.102.210", "149.56.29.163", "191.235.80.138", "88.198.65.74", "94.102.63.226", "129.232.225.202", "104.255.64.3", "52.72.135.200", "149.56.28.84", "103.18.58.150", "221.121.144.140", "123.249.79.12", "103.18.58.146", "27.50.93.252", "176.9.0.233", "94.102.63.227", "167.114.227.223", "27.50.68.219", "192.99.233.217", "94.102.63.217", "45.64.168.216" }; int32_t Notaries_numseeds = (int32_t)(sizeof(seeds)/sizeof(*seeds)),Notaries_num,Notaries_BTCminsigs = DPOW_MINSIGS,Notaries_minsigs = DPOW_MIN_ASSETCHAIN_SIGS; uint16_t Notaries_port = DPOW_SOCKPORT; -char *Notaries_seeds[64]; +char *Notaries_seeds[65]; int32_t komodo_initjson(char *fname) { @@ -94,7 +94,7 @@ int32_t komodo_initjson(char *fname) Notaries_minsigs = num; if ( (array= jarray(&n,argjson,"seeds")) != 0 && n <= 64 ) { - for (i=0; i dp->maxblocks ) { + if ( dp->maxblocks+incr < height+10000 ) + incr = (height+10000) - dp->maxblocks; dp->blocks = realloc(dp->blocks,sizeof(*dp->blocks) * (dp->maxblocks + incr)); memset(&dp->blocks[dp->maxblocks],0,sizeof(*dp->blocks) * incr); dp->maxblocks += incr; diff --git a/iguana/exchanges/LP_etomic.c b/iguana/exchanges/LP_etomic.c index 0086b47d3..c6f135a42 100644 --- a/iguana/exchanges/LP_etomic.c +++ b/iguana/exchanges/LP_etomic.c @@ -28,15 +28,23 @@ int32_t LP_etomic_wait_for_confirmation(char *txId) return(waitForConfirmation(txId)); } +void LP_etomic_pubkeystr_to_addr(char *pubkey, char *output) +{ + char *address = pubKey2Addr(pubkey); + strcpy(output, address); + free(address); +} + char *LP_etomicalice_send_fee(struct basilisk_swap *swap) { - char amount[100], secretKey[70]; + char amount[100], secretKey[70], dexaddr[50]; satoshisToWei(amount, swap->myfee.I.amount); uint8arrayToHex(secretKey, swap->persistent_privkey.bytes, 32); + LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if (strcmp(swap->I.alicestr,"ETH") == 0 ) { - return(sendEth(ETH_FEE_ACCEPTOR, amount, secretKey, 1)); + return(sendEth(dexaddr, amount, secretKey, 1)); } else { - return(sendErc20(swap->I.alicetomic, ETH_FEE_ACCEPTOR, amount, secretKey, 1)); + return(sendErc20(swap->I.alicetomic, dexaddr, amount, secretKey, 1)); } } @@ -52,8 +60,10 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) return(0); } + char dexaddr[50]; + LP_etomic_pubkeystr_to_addr(INSTANTDEX_PUBKEY, dexaddr); if ( strcmp(swap->I.alicestr,"ETH") == 0 ) { - if (strcmp(data.to, ETH_FEE_ACCEPTOR) != 0) { + if (strcmp(data.to, dexaddr) != 0) { printf("Alice fee %s was sent to wrong address %s\n", swap->otherfee.I.ethTxid, data.to); return(0); } @@ -70,7 +80,7 @@ uint8_t LP_etomic_verify_alice_fee(struct basilisk_swap *swap) } char weiAmount[70]; satoshisToWei(weiAmount, swap->otherfee.I.amount); - return(verifyAliceErc20FeeData(swap->I.alicetomic, ETH_FEE_ACCEPTOR, weiAmount, data.input)); + return(verifyAliceErc20FeeData(swap->I.alicetomic, dexaddr, weiAmount, data.input)); } } diff --git a/iguana/exchanges/etomicswap/bob.c b/iguana/exchanges/etomicswap/bob.c index 794b0b533..6b3f28261 100644 --- a/iguana/exchanges/etomicswap/bob.c +++ b/iguana/exchanges/etomicswap/bob.c @@ -330,11 +330,14 @@ int main(int argc, char** argv) default: return 1; } - /* char *pubkey = getPubKeyFromPriv(getenv("BOB_PK")); printf("pubkey: %s\n", pubkey); free(pubkey); + char *address = pubKey2Addr("03bc2c7ba671bae4a6fc835244c9762b41647b9827d4780a89a949b984a8ddcc06"); + printf("address: %s\n", address); + free(address); + uint64_t satoshis = 100000000; char weiBuffer[100]; satoshisToWei(weiBuffer, satoshis); @@ -346,16 +349,15 @@ int main(int argc, char** argv) uint64_t tokenAllowance = getErc20Allowance(bobAddress, bobContractAddress, tokenAddress); printf("allowance: %" PRIu64 "\n", tokenAllowance); - char *sendEthTx = sendEth(bobAddress, "100000000000000", getenv("BOB_PK")); + char *sendEthTx = sendEth(bobAddress, "100000000000000", getenv("BOB_PK"), 0); printf("sent ETH: %s\n", sendEthTx); free(sendEthTx); - char *sendErc20Tx = sendErc20(tokenAddress, bobAddress, "100000000000000", getenv("BOB_PK")); + char *sendErc20Tx = sendErc20(tokenAddress, bobAddress, "100000000000000", getenv("BOB_PK"), 0); printf("sent Erc20: %s\n", sendErc20Tx); free(sendErc20Tx); uint64_t gasPrice = getGasPriceFromStation(); printf("gasPrice: %" PRIu64 "\n", gasPrice); - */ return 0; } diff --git a/iguana/exchanges/etomicswap/etomiclib.h b/iguana/exchanges/etomicswap/etomiclib.h index cc5ccebfc..c7b846ddb 100644 --- a/iguana/exchanges/etomicswap/etomiclib.h +++ b/iguana/exchanges/etomicswap/etomiclib.h @@ -16,7 +16,6 @@ extern "C" { #endif #define EMPTY_ETH_TX_ID "0x0000000000000000000000000000000000000000000000000000000000000000" -#define ETH_FEE_ACCEPTOR "0x485d2cc2d13a9e12e4b53d606db1c8adc884fb8a" typedef struct { char from[65]; diff --git a/iguana/iguana777.h b/iguana/iguana777.h index 02dbc4e84..3e643bdaf 100755 --- a/iguana/iguana777.h +++ b/iguana/iguana777.h @@ -167,7 +167,7 @@ struct supernet_info uint8_t *pingbuf; struct basilisk_request DEXaccept; FILE *dexfp; - struct dpow_info DPOWS[128]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock; + struct dpow_info DPOWS[1024]; int32_t numdpows,dpowsock,dexsock,pubsock,repsock,subsock,reqsock; struct delayedPoW_info dPoW; struct basilisk_spend *spends; int32_t numspends; char bindaddr[64]; diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 9faf49570..a45e8fa19 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -95,7 +95,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( height > 0 && blocktime > 0 ) { dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); - if ( (0) &&strcmp("BEER",dp->symbol) == 0 ) + if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) printf("dynamic set %s/%s %s <- height.%d\n",dp->symbol,dp->dest,bits256_str(str,hash),height); checkpoint = dp->last; } else return; @@ -109,7 +109,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he printf("lastnotarized.(%s) is current checkpoint, skip\n",bits256_str(str,dp->lastnotarized)); return; } - if ( (0) && strcmp("BEER",dp->symbol) == 0 ) + if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) printf("checkpoint.(%s) is not active and not lastnotarized\n",bits256_str(str,checkpoint.blockhash.hash)); } else return; } else return; @@ -118,14 +118,14 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he } if ( bits256_nonz(checkpoint.blockhash.hash) != 0 && (checkpoint.blockhash.height % freq) == 0 ) { - if ( (0) && strcmp("BEER",dp->symbol) == 0 ) + if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) printf("%s/%s src ht.%d dest.%u nonz.%d %s minsigs.%d\n",dp->symbol,dp->dest,checkpoint.blockhash.height,dp->destupdated,bits256_nonz(checkpoint.blockhash.hash),bits256_str(str,dp->last.blockhash.hash),minsigs); dpow_heightfind(myinfo,dp,checkpoint.blockhash.height + 1000); ptrs = calloc(1,sizeof(void *)*5 + sizeof(struct dpow_checkpoint) + sizeof(pthread_t)); ptrs[0] = (void *)myinfo; ptrs[1] = (void *)dp; ptrs[2] = (void *)(uint64_t)minsigs; - if ( strcmp(dp->dest,"KMD") != 0 && strcmp(dp->dest,"CHAIN") != 0 ) + if ( strcmp(dp->dest,"KMD") != 0 ) ptrs[3] = (void *)DPOW_DURATION; else ptrs[3] = (void *)(DPOW_DURATION * 60); // essentially try forever for assetchains ptrs[4] = 0; @@ -135,9 +135,11 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( OS_thread_create((void *)((uint64_t)&ptrs[5] + sizeof(struct dpow_checkpoint)),NULL,(void *)dpow_statemachinestart,(void *)ptrs) != 0 ) { } - if ( ht > 100 ) + if ( ht > 500 ) { - for (i=ht-100; i>=0; i--) + if ( (0) && strcmp("CHIPS",dp->symbol) == 0 ) + printf("ht.%d maxblocks.%d\n",ht,dp->maxblocks); + for (i=ht-500; i>ht-10000; i--) { if ( (i % 100) != 0 && (bp= dp->blocks[i]) != 0 && bp->state == 0xffffffff ) { diff --git a/iguana/keccak.c b/iguana/keccak.c index 9c9fa40a2..86ce1387d 100644 --- a/iguana/keccak.c +++ b/iguana/keccak.c @@ -39,9 +39,7 @@ extern "C"{ #endif -#if defined(WIN32) #include -#endif /* * Parameters: