From 92c2aa6ba5f0e5a9e3819bcb5418d861531552b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 23 Feb 2017 18:22:58 +0200 Subject: [PATCH 01/50] Test for many utxo --- src/wallet/wallet.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 48bacd562..05a18c8cf 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2384,6 +2384,11 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int //fprintf(stderr,"count.%d %.8f\n",count,(double)pcoin->vout[i].interest/COIN); interests[count++] = pcoin->vout[i].interest; } + if ( nTotalLower > 2*nTargetValue + CENT ) + { + fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n"); + break; + } } else if (n < coinLowestLarger.first) { From bc653eee608bb5d300a8e0199021f4b78ef201d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 08:24:00 +0200 Subject: [PATCH 02/50] Test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9176bffe1..3ef2c91c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -834,7 +834,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) { - if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp("KMD",(char *)&opretbuf[opretlen-4]) != 0 ) + if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 ) { for (i=0; ivtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); From c96df8ecc921a4b4acd72e697ab933cd36be401c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 08:36:55 +0200 Subject: [PATCH 03/50] Test --- src/miner.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8385ba80a..042bda961 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -552,7 +552,8 @@ void static BitcoinMiner(CWallet *pwallet) //else solver = "default"; assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); - //fprintf(stderr,"Mining with %s\n",solver.c_str()); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"Mining with %s\n",solver.c_str()); std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( @@ -563,7 +564,8 @@ void static BitcoinMiner(CWallet *pwallet) ); try { - //fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { if (chainparams.MiningRequiresPeers()) @@ -602,7 +604,7 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); From 796bbf8aa3a5fb099592ce2b992398bd4d116fb0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 08:46:55 +0200 Subject: [PATCH 04/50] Test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 80f2a75b6..4740436f2 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -528,7 +528,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin int32_t i,nonz=0; int64_t diff; uint64_t price,seed,sum = 0; if ( ASSETCHAINS_SYMBOL[0] == 0 && chainActive.Tip() != 0 && height > chainActive.Tip()->nHeight ) { - if ( height < 1381319936 ) + if ( height < 100000000 ) printf("height.%d vs tip.%d\n",height,chainActive.Tip()->nHeight); return(0); } From 106a1d040e724c4690c9d30f59154ed41f60e100 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 08:59:57 +0200 Subject: [PATCH 05/50] Test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3ef2c91c4..1ceabfdc6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -35,7 +35,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); - } else printf("pax_fiatstatus illegal base.%s\n",base); + } // else printf("pax_fiatstatus illegal base.%s\n",base); return(-1); } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4740436f2..3e2a8aab4 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -604,7 +604,7 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu *seedp = komodo_seed(height); if ( (baseid= komodo_baseid(origbase)) < 0 || baseid == MAX_CURRENCIES ) { - if ( origbase[0] != 0 ) + if ( 0 && origbase[0] != 0 ) printf("[%s] PAX_fiatdest illegal base.(%s)\n",ASSETCHAINS_SYMBOL,origbase); return(0); } From 17d204f5f9b50189d5dc1635153d9530e7801a49 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:29:14 +0200 Subject: [PATCH 06/50] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 042bda961..eba720721 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -423,8 +423,8 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CValidationState state; if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { - fprintf(stderr,"testblockvalidity failed\n"); - throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); + fprintf(stderr,"warning: testblockvalidity failed\n"); + //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } } From 056bd9be2ac14c81dc9f1597ad559a25eac7ca5c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:31:56 +0200 Subject: [PATCH 07/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ceabfdc6..1c74b120a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -489,7 +489,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) { if ( strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) - printf("miner.[%s]: skip %s %.8f when avail %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available)); + printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } /*printf("pax.%s marked.%d %.8f -> %.8f ready.%d validated.%d\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->ready!=0,pax->validated!=0); From ac4cbeef42cc14892382f7f8e7d4e18363ff4e84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:33:45 +0200 Subject: [PATCH 08/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1c74b120a..64c0e20dd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,7 +542,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { len += komodo_rwapproval(1,&data[len],pax); PENDING_KOMODO_TX += pax->komodoshis; - printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); + printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->kmdheight,pax->otherheight,dstr(PENDING_KOMODO_TX)); } if ( numvouts++ >= 64 ) break; From 1eaffd746bf973f32b45fe6c6a66b84197b59b2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:34:44 +0200 Subject: [PATCH 09/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 64c0e20dd..543bde41f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,7 +542,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { len += komodo_rwapproval(1,&data[len],pax); PENDING_KOMODO_TX += pax->komodoshis; - printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->kmdheight,pax->otherheight,dstr(PENDING_KOMODO_TX)); + printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } if ( numvouts++ >= 64 ) break; From 507fbc478a340d4e42bee91696b9a133876287b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:46:49 +0200 Subject: [PATCH 10/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 543bde41f..d499d3101 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -620,7 +620,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above pax->type = opcode; if ( opcode == 'I' && pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) { - printf("checkdeposit: skip %s %.8f when avail %.8f\n",pax->symbol,dstr(pax->fiatoshis),dstr(available)); + printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } if ( ((opcode == 'I' && (pax->fiatoshis == 0 || pax->fiatoshis == block.vtx[0].vout[i].nValue)) || (opcode == 'X' && (pax->komodoshis == 0 || pax->komodoshis == block.vtx[0].vout[i].nValue))) ) From d5894ea8737094e112eaeaadc8ad4ca097397a40 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 09:56:03 +0200 Subject: [PATCH 11/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d499d3101..3df6fddf6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -618,7 +618,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; - if ( opcode == 'I' && pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) + if ( opcode == 'I' && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) { printf("checkdeposit.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; From eaba9a27a8b6e3f8e0edde3281e8cbe64ccfd5f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 17:44:34 +0200 Subject: [PATCH 12/50] Test --- src/miner.cpp | 2 +- src/wallet/wallet.cpp | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index eba720721..bae222120 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -670,7 +670,7 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt { fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 05a18c8cf..091fb5e22 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2386,7 +2386,7 @@ bool CWallet::SelectCoinsMinConf(const CAmount& nTargetValue, int nConfMine, int } if ( nTotalLower > 2*nTargetValue + CENT ) { - fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n"); + //fprintf(stderr,"why bother with all the utxo if we have double what is needed?\n"); break; } } From 5c92f750f32cea401fa281dfb4eafbff572b01a2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 18:14:23 +0200 Subject: [PATCH 13/50] Test --- src/komodo_gateway.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3df6fddf6..1fa77c6cf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -466,8 +466,14 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { opcode = 'I'; - if ( komodo_isrealtime(&ht) == 0 ) - return(0); + for (i=0; i<10; i++) + { + if ( komodo_isrealtime(&ht) != 0 ) + break; + sleep(1); + } + printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); + return(0); } else { From fe9dc3b890ff744d426c3e62fbe08d9c655450d7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 18:30:26 +0200 Subject: [PATCH 14/50] Test --- src/bitcoind.cpp | 2 +- src/komodo_gateway.h | 7 +++++-- 2 files changed, 6 insertions(+), 3 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index b11f5508c..b81ffc32f 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -41,7 +41,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. while (!fShutdown) { - MilliSleep(16000); + MilliSleep(10000); komodo_passport_iteration(); fShutdown = ShutdownRequested(); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1fa77c6cf..319ad3e7d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -472,8 +472,11 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to break; sleep(1); } - printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); - return(0); + if ( i == 10 ) + { + printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); + return(0); + } } else { From 2bec17cb64508aea322d22173fdf453c37f9c6e4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 18:37:40 +0200 Subject: [PATCH 15/50] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index bae222120..4673f17e4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -134,7 +134,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } - else if ( deposits != 0 || (int32_t)mempool.GetTotalTxSize() > 0 ) + else if ( komodo_isrealtime(&kmdheight) != 0 && (deposits != 0 || (int32_t)mempool.GetTotalTxSize() > 0) ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; From 13c01d29cfd20967acdea7622f9a5c3eda3fecc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 19:28:32 +0200 Subject: [PATCH 16/50] Test --- src/komodo_gateway.h | 2 ++ src/miner.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 319ad3e7d..2f244cf07 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -493,6 +493,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( kmdsp != 0 && (kmdsp->NOTARIZED_HEIGHT >= pax->height || kmdsp->CURRENT_HEIGHT > pax->height+30) ) // assumes same chain as notarize pax->validated = pax->komodoshis; //kmdsp->NOTARIZED_HEIGHT; else pax->validated = pax->ready = 0; +#else + pax->validated = pax->komodoshis; #endif } if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) diff --git a/src/miner.cpp b/src/miner.cpp index 4673f17e4..58a96d300 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -400,7 +400,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) else if ( komodo_is_issuer() != 0 ) { komodo_gateway_deposits(&txNew,ASSETCHAINS_SYMBOL,0); - if ( txNew.vout.size() > 1 ) + //if ( txNew.vout.size() > 1 ) fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } pblock->vtx[0] = txNew; From 6813c8d5a2c6cc9c96c11630e7aedeaeca6b4632 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 25 Feb 2017 22:37:02 +0200 Subject: [PATCH 17/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2f244cf07..9de1616a4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -658,7 +658,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } } - else + else if ( kmdheights[i-1] > 0 && otherheights[i-1] > 0 ) { hash = block.GetHash(); for (j=0; j<32; j++) From 283168fdf61b74c78ba925c55d94f5fa761a8295 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 09:36:48 +0200 Subject: [PATCH 18/50] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9de1616a4..ada55ed66 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -666,9 +666,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf(" kht.%d ht.%d %.8f %.8f blockhash couldnt find vout.[%d]\n",kmdheights[i-1],otherheights[i-1],dstr(values[i-1]),dstr(srcvalues[i]),i); } } - if ( height < 225000 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - if ( (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) + if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) { printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); // can easily happen depending on order of loading @@ -681,7 +681,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else { - if ( height < chainActive.Tip()->nHeight && matched != num ) + if ( komodo_isrealtime(&ht) != 0 && height > 0 && height < chainActive.Tip()->nHeight && matched != num ) { printf("REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); return(-1); From 4df419cd3b88bed8f0ea28c1eabdc7cc13855ae1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 09:38:56 +0200 Subject: [PATCH 19/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ada55ed66..36dbea914 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -681,7 +681,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else { - if ( komodo_isrealtime(&ht) != 0 && height > 0 && height < chainActive.Tip()->nHeight && matched != num ) + if ( height > 0 && (height < chainActive.Tip()->nHeight || (height >= chainActive.Tip()->nHeight && komodo_isrealtime(&ht) != 0)) && matched != num ) { printf("REJECT %s: ht.%d (%c) matched.%d vs num.%d tip.%d isRT.%d\n",symbol,height,opcode,matched,num,(int32_t)chainActive.Tip()->nHeight,komodo_isrealtime(&ht)); return(-1); From 2d3c928f6a20004da64df5d9fcf5431af6e3b650 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 09:43:26 +0200 Subject: [PATCH 20/50] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 36dbea914..be7a9892e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -585,7 +585,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; - if ( KOMODO_PAX == 0 ) + if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 ) return(0); memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -645,7 +645,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else { - if ( opcode == 'X' ) + if ( opcode == 'X' && strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i]]) == 0 ) printf("check deposit validates %s %.8f -> %.8f\n",CURRENCIES[baseids[i]],dstr(srcvalues[i]),dstr(values[i])); matched++; } From ba37a6b98e0b45ec078dee6caaf7f686a6c97653 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:03:38 +0200 Subject: [PATCH 21/50] Test --- src/komodo.h | 2 +- src/komodo_gateway.h | 20 +++++++++++++++----- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 43c192274..51217dec2 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -337,7 +337,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { if ( i == 0 && j == 0 && memcmp(NOTARY_PUBKEY33,scriptbuf+1,33) == 0 ) { - printf("KOMODO_LASTMINED.%d -> %d\n",KOMODO_LASTMINED,height); + printf("%s KOMODO_LASTMINED.%d -> %d\n",ASSETCHAINS_SYMBOL,KOMODO_LASTMINED,height); KOMODO_LASTMINED = height; } decode_hex(crypto777,33,(char *)CRYPTO777_PUBSECPSTR); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index be7a9892e..0e7e06122 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -466,13 +466,13 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { opcode = 'I'; - for (i=0; i<10; i++) + for (i=0; i<3; i++) { if ( komodo_isrealtime(&ht) != 0 ) break; sleep(1); } - if ( i == 10 ) + if ( i == 3 ) { printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); return(0); @@ -1010,7 +1010,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; - FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3]; cJSON *infoobj,*result; uint64_t RTmask = 0; + FILE *fp; int32_t baseid,n,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); while ( KOMODO_INITDONE == 0 ) { @@ -1034,6 +1034,7 @@ void komodo_passport_iteration() KOMODO_PASSPORT_INITDONE = 1; return; } + starttime = (uint32_t)time(NULL); //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { @@ -1045,6 +1046,7 @@ void komodo_passport_iteration() komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); sp = komodo_stateptrget(symbol); + n = 0; if ( (fp= fopen(fname,"rb")) != 0 && sp != 0 ) { fseek(fp,0,SEEK_END); @@ -1053,8 +1055,16 @@ void komodo_passport_iteration() if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) - ; + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 ) + { + if ( n == 999 ) + { + if ( time(NULL) < starttime+5 ) + n = 0; + else printf("expire passport loop %s\n",ASSETCHAINS_SYMBOL,base); + } + n++; + } lastpos[baseid] = ftell(fp); if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); From ffa4f44706d1f7a1124102c05819ef2560f4f7c1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:05:48 +0200 Subject: [PATCH 22/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0e7e06122..aa2828c14 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1061,7 +1061,7 @@ void komodo_passport_iteration() { if ( time(NULL) < starttime+5 ) n = 0; - else printf("expire passport loop %s\n",ASSETCHAINS_SYMBOL,base); + else printf("expire passport loop %s -> %s\n",ASSETCHAINS_SYMBOL,base); } n++; } From 588bc897210c8c8a95df6aa077ad0aabb83ba692 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:11:09 +0200 Subject: [PATCH 23/50] Test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index aa2828c14..9cdaa55fb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1009,7 +1009,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { - static long lastpos[34]; static char userpass[33][1024]; + static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 7; FILE *fp; int32_t baseid,n,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); while ( KOMODO_INITDONE == 0 ) @@ -1038,6 +1038,8 @@ void komodo_passport_iteration() //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { + if ( time(NULL) > starttime+maxseconds ) + break; sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; @@ -1059,14 +1061,14 @@ void komodo_passport_iteration() { if ( n == 999 ) { - if ( time(NULL) < starttime+5 ) + if ( time(NULL) < starttime+maxseconds ) n = 0; else printf("expire passport loop %s -> %s\n",ASSETCHAINS_SYMBOL,base); } n++; } lastpos[baseid] = ftell(fp); - if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) + if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); From 8d4fe13311952faf184c3ef06252e9ccaeb642af Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:13:52 +0200 Subject: [PATCH 24/50] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9cdaa55fb..ffa0b51f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1010,7 +1010,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 7; - FILE *fp; int32_t baseid,n,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; + FILE *fp; int32_t baseid,n,ht,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); while ( KOMODO_INITDONE == 0 ) { @@ -1069,7 +1069,7 @@ void komodo_passport_iteration() } lastpos[baseid] = ftell(fp); if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) - printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + printf("from.(%s) lastpos[%s] %ld isrt.%d\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid],komodo_isrealtime(&ht)); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } else printf("error.(%s) %p\n",fname,sp); From e22dcc1e45f61832bab810f2f1bbc4668e2f5736 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:17:48 +0200 Subject: [PATCH 25/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ffa0b51f2..b41735751 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1038,7 +1038,7 @@ void komodo_passport_iteration() //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { - if ( time(NULL) > starttime+maxseconds ) + if ( time(NULL) >= starttime+maxseconds ) break; sp = 0; isrealtime = 0; From 5254630aecc402101951222dcc8bae4eccb13be0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:29:23 +0200 Subject: [PATCH 26/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b41735751..f2a88916b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1063,7 +1063,7 @@ void komodo_passport_iteration() { if ( time(NULL) < starttime+maxseconds ) n = 0; - else printf("expire passport loop %s -> %s\n",ASSETCHAINS_SYMBOL,base); + else printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]); } n++; } From 430d3c7766ca777b00dc5fa4fdcd49c613e94ed6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 10:33:40 +0200 Subject: [PATCH 27/50] Test --- src/komodo_gateway.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f2a88916b..439272fb5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1010,8 +1010,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 7; - FILE *fp; int32_t baseid,n,ht,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; + FILE *fp; int32_t baseid,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); + expired = 0; while ( KOMODO_INITDONE == 0 ) { fprintf(stderr,"[%s] PASSPORT iteration waiting for KOMODO_INITDONE\n",ASSETCHAINS_SYMBOL); @@ -1063,7 +1064,11 @@ void komodo_passport_iteration() { if ( time(NULL) < starttime+maxseconds ) n = 0; - else printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]); + else + { + printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]); + expired++; + } } n++; } @@ -1115,7 +1120,10 @@ void komodo_passport_iteration() } komodo_paxtotal(); refsp->RTmask = RTmask; - KOMODO_PASSPORT_INITDONE = 1; - //printf("done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + if ( expired == 0 && KOMODO_PASSPORT_INITDONE == 0 ) + { + KOMODO_PASSPORT_INITDONE = 1; + printf("done PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + } } From b8cceac522fa180e3624cc3486599304160a3a98 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 11:25:44 +0200 Subject: [PATCH 28/50] Test --- src/komodo_gateway.h | 28 +++++++++++++++++----------- 1 file changed, 17 insertions(+), 11 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 439272fb5..e71c41757 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -463,20 +463,20 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 ) return(0); PENDING_KOMODO_TX = 0; + for (i=0; i<3; i++) + { + if ( komodo_isrealtime(&ht) != 0 ) + break; + sleep(1); + } + if ( i == 3 ) + { + printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); + return(0); + } if ( tokomodo == 0 ) { opcode = 'I'; - for (i=0; i<3; i++) - { - if ( komodo_isrealtime(&ht) != 0 ) - break; - sleep(1); - } - if ( i == 3 ) - { - printf("%s not realtime ht.%d\n",ASSETCHAINS_SYMBOL,ht); - return(0); - } } else { @@ -626,6 +626,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; iRTmask & (1LL << baseid)) == 0 ) + { + printf("skip checkdeposit.%s not RT\n",CURRENCIES[baseids[i-1]]); + matched++; + continue; + } if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; From 4f83a8f7f2c3ad7446cb05b397c81f999f1230b1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 11:42:10 +0200 Subject: [PATCH 29/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e71c41757..c241ab30c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -584,7 +584,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; + int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 ) return(0); memset(baseids,0xff,sizeof(baseids)); From fe348242d7ac0fb952839f9f95ad0fd29f35fda9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 11:43:06 +0200 Subject: [PATCH 30/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c241ab30c..e9f214a13 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -626,7 +626,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; iRTmask & (1LL << baseid)) == 0 ) + if ( (sp= komodo_stateptrget(CURRENCIES[baseids[i-1]])) != 0 && (sp->RTmask & (1LL << baseids[i-1])) == 0 ) { printf("skip checkdeposit.%s not RT\n",CURRENCIES[baseids[i-1]]); matched++; From a822a07057f92b11cba97865974b74d91b1f98c2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 11:54:27 +0200 Subject: [PATCH 31/50] Test --- src/komodo_gateway.h | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e9f214a13..9ef44b175 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -509,9 +509,10 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to printf("reject 2\n"); continue; }*/ - if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0) ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) ) { - //printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); + if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) + printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height); continue; } if ( pax->ready == 0 ) @@ -1072,7 +1073,7 @@ void komodo_passport_iteration() n = 0; else { - printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]); + //printf("expire passport loop %s -> %s at %ld\n",ASSETCHAINS_SYMBOL,base,lastpos[baseid]); expired++; } } From 846304163cfc68704ab05059074acbec327959a8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 12:13:58 +0200 Subject: [PATCH 32/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9ef44b175..afb40d303 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -378,7 +378,7 @@ uint64_t komodo_paxtotal() } } } - if ( 0 && pax->ready != 0 ) + if ( pax->ready != 0 ) printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); } } From 9aefc81b626f852815f03aa722b7f9284b4e1926 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 12:26:10 +0200 Subject: [PATCH 33/50] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index afb40d303..782e4382a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -281,7 +281,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che uint64_t komodo_paxtotal() { struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; - if ( KOMODO_PAX == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); if ( komodo_isrealtime(&ht) == 0 ) return(0); @@ -406,7 +406,7 @@ static int _paxorder(const void *a,const void *b) int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic order { struct pax_transaction *pax,*pax2,*tmp,*paxes[64]; uint8_t opretbuf[16384]; int32_t i,n,ht,len=0; uint64_t total = 0; - if ( KOMODO_PAX == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); if ( komodo_isrealtime(&ht) == 0 || ASSETCHAINS_SYMBOL[0] != 0 ) return(0); @@ -455,7 +455,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t tokomodo) { struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; uint8_t *script,opcode,opret[16384],data[16384]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t available,deposited,issued,withdrawn,approved,redeemed,mask; - if ( KOMODO_PAX == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); sp = komodo_stateptr(symbol,dest); @@ -586,7 +586,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { int32_t i,j,n,ht,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; - if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 ) + if ( KOMODO_PAX == 0 || komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); From 1dc7baaae3ef8b59fdcf636fce7061690023dbb5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 12:54:19 +0200 Subject: [PATCH 34/50] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 782e4382a..8ac105628 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -499,7 +499,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) { - if ( strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) + if ( height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } @@ -511,7 +511,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to }*/ if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) ) { - if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) + if ( height > 214700 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height); continue; } @@ -796,7 +796,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( seed != 0 && kmdheight > 182000 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + else if ( kmdheight > 182000 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) //seed != 0 && printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed); } //else printf("paxdeposit height.%d vs kmdheight.%d\n",height,kmdheight); } From 68cfaa1356576e378af8a6c8ad4b9c30eef6d728 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 12:56:04 +0200 Subject: [PATCH 35/50] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8ac105628..29f458105 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -499,7 +499,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to } if ( ASSETCHAINS_SYMBOL[0] != 0 && (pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis) ) { - if ( height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) + if ( pax->height > 214700 || strcmp(ASSETCHAINS_SYMBOL,symbol) == 0 ) printf("miner.[%s]: skip %s %.8f when avail %.8f deposited %.8f, issued %.8f withdrawn %.8f approved %.8f redeemed %.8f\n",ASSETCHAINS_SYMBOL,symbol,dstr(pax->fiatoshis),dstr(available),dstr(deposited),dstr(issued),dstr(withdrawn),dstr(approved),dstr(redeemed)); continue; } @@ -511,7 +511,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to }*/ if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) ) { - if ( height > 214700 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) + if ( pax->height > 214700 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height); continue; } From 649a9ebfed8245b2cf51d7dd79226b2730ca3492 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 13:31:01 +0200 Subject: [PATCH 36/50] Test --- src/komodo_gateway.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 29f458105..4df9fe089 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -82,7 +82,12 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout //printf("ht.%d create pax.%p mark.%d\n",height,pax,mark); } if ( pax != 0 ) + { pax->marked = mark; + if ( height > 214700 || pax->height > 214700 ) + printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + + } pthread_mutex_unlock(&komodo_mutex); return(pax); } @@ -379,7 +384,7 @@ uint64_t komodo_paxtotal() } } if ( pax->ready != 0 ) - printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d ready.%d ht.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,pax->ready,pax->height); } } } From 9e44127296f0e4ffcbcc2b087316f6d8a3947849 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 13:42:41 +0200 Subject: [PATCH 37/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4df9fe089..a8d0ef63d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -741,7 +741,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); for (i=0; i<32; i++) From ebd3b25254ce47ed9061821e6a12ca5c7d78fa7b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 13:53:45 +0200 Subject: [PATCH 38/50] Test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a8d0ef63d..cc511ec63 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,7 +736,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); - checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); + //checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); + checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,height,base,fiatoshis); typestr = "deposit"; if ( kmdheight > 195000 || kmdheight <= height ) { @@ -751,7 +752,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); } - if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(base,height,value,checktoshis,seed) == 0 ) + // if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { @@ -801,7 +803,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( kmdheight > 182000 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) //seed != 0 && + else if ( kmdheight > 182000 && (kmdheight > 214700 || strcmp(base,ASSETCHAINS_SYMBOL) == 0) ) //seed != 0 && printf("pax %s deposit %.8f rejected kmdheight.%d %.8f KMD check %.8f seed.%llu\n",base,dstr(fiatoshis),kmdheight,dstr(value),dstr(checktoshis),(long long)seed); } //else printf("paxdeposit height.%d vs kmdheight.%d\n",height,kmdheight); } From 81a991e482aefb7379abeefd70c3b328c4e62c04 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 13:58:21 +0200 Subject: [PATCH 39/50] Test --- src/komodo_gateway.h | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cc511ec63..ed715f828 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,8 +736,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(base,0,sizeof(base)); PAX_pubkey(0,&opretbuf[1],&addrtype,rmd160,base,&shortflag,&fiatoshis); bitcoin_address(coinaddr,addrtype,rmd160,20); - //checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); - checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,height,base,fiatoshis); + checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,fiatoshis); typestr = "deposit"; if ( kmdheight > 195000 || kmdheight <= height ) { @@ -752,8 +751,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); } - if ( komodo_paxcmp(base,height,value,checktoshis,seed) == 0 ) - // if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { From f8e70860887270ba260b577473e8d6b335f2a14f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:03:36 +0200 Subject: [PATCH 40/50] Test --- src/komodo_gateway.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ed715f828..d93871022 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -751,7 +751,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); } - if ( komodo_paxcmp(base,kmdheight,value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(base,kmdheight,value,checktoshis,kmdheight < chainActive.Tip()->nHeight ? seed : 0) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { From 41b528bb978dcdbe2687658681e5ba7959e78bcd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:10:27 +0200 Subject: [PATCH 41/50] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d93871022..3be114bac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -741,7 +741,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); for (i=0; i<32; i++) @@ -751,7 +751,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); } - if ( komodo_paxcmp(base,kmdheight,value,checktoshis,kmdheight < chainActive.Tip()->nHeight ? seed : 0) == 0 ) + if ( komodo_paxcmp(base,kmdheight,value,checktoshis,kmdheight < 225000 ? seed : 0) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { From a8ffc9b98ec5811756c791d6eb0eb21bd3aa4084 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:17:43 +0200 Subject: [PATCH 42/50] Test --- src/komodo_gateway.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3be114bac..e3e9c91e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -383,7 +383,7 @@ uint64_t komodo_paxtotal() } } } - if ( pax->ready != 0 ) + if ( 0 && pax->ready != 0 ) printf("%p (%c) pax.%s marked.%d %.8f -> %.8f validated.%d approved.%d ready.%d ht.%d\n",pax,pax->type,pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,pax->ready,pax->height); } } @@ -516,7 +516,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to }*/ if ( ASSETCHAINS_SYMBOL[0] != 0 && (strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 || pax->ready == 0) ) { - if ( pax->height > 214700 || strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp(pax->symbol,ASSETCHAINS_SYMBOL) == 0 ) printf("pax->symbol.%s != %s or null pax->validated %.8f ready.%d ht.(%d %d)\n",pax->symbol,symbol,dstr(pax->validated),pax->ready,kmdsp->CURRENT_HEIGHT,pax->height); continue; } From 08d0b73ce3ac221f04019f103b6549d5f86ebe96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:26:00 +0200 Subject: [PATCH 43/50] Test --- src/miner.cpp | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 58a96d300..6dc5ec03b 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -424,6 +424,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { fprintf(stderr,"warning: testblockvalidity failed\n"); + return(0); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } } @@ -606,8 +607,13 @@ void static BitcoinMiner(CWallet *pwallet) } if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); - - unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); + CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); + if ( ptr == 0 ) + { + fprintf(stderr,"created illegal block, retry\n"); + continue; + } + unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) { LogPrintf("Error in KomodoMiner: Keypool ran out, please call keypoolrefill before restarting the mining thread\n"); From 017d82119c6f61d7abc9466e78b26adaff0c460a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:34:39 +0200 Subject: [PATCH 44/50] Test --- src/komodo_gateway.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e3e9c91e3..cfc942bdb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1021,7 +1021,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { - static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 7; + static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 17; FILE *fp; int32_t baseid,n,ht,isrealtime,expired,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3],starttime; cJSON *infoobj,*result; uint64_t RTmask = 0; //printf("PASSPORT.(%s)\n",ASSETCHAINS_SYMBOL); expired = 0; @@ -1070,7 +1070,7 @@ void komodo_passport_iteration() if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); fseek(fp,lastpos[baseid],SEEK_SET); - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 ) + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 10000 ) { if ( n == 999 ) { @@ -1101,7 +1101,7 @@ void komodo_passport_iteration() isrealtime = 1; RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); - } else if ( (time(NULL)-buf[2]) > 1200 ) + } else if ( (time(NULL)-buf[2]) > 1800 ) fprintf(stderr,"[%s]: %s not RT %u %u %d\n",ASSETCHAINS_SYMBOL,base,buf[0],buf[1],(int32_t)(time(NULL)-buf[2])); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); From eaf1e6145f095fc00a8459ac8f39633643dd694b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:46:12 +0200 Subject: [PATCH 45/50] Test --- src/komodo.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo.h b/src/komodo.h index 51217dec2..702b11cf8 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -495,6 +495,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); return; } + fprintf(stderr,"%s connect\n",pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -605,6 +606,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); + fprintf(stderr,"%s end connect\n",pindex->nHeight); } From 3ddd2800400faf0a0652229d9b4137c4d96aaf41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 14:48:10 +0200 Subject: [PATCH 46/50] Test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 702b11cf8..df1431d0d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -495,7 +495,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); return; } - fprintf(stderr,"%s connect\n",pindex->nHeight); + fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -606,7 +606,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); - fprintf(stderr,"%s end connect\n",pindex->nHeight); + fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); } From 5c81c5719f5aa28d0cbec7185264d2eb731d8955 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 15:16:30 +0200 Subject: [PATCH 47/50] Test --- src/bitcoind.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index b81ffc32f..c751dca21 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -41,6 +41,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. while (!fShutdown) { + fprintf(stderr,"call passport iteration\n"); MilliSleep(10000); komodo_passport_iteration(); fShutdown = ShutdownRequested(); @@ -188,7 +189,7 @@ bool AppInit(int argc, char* argv[]) } catch (...) { PrintExceptionContinue(NULL, "AppInit()"); } - + fprintf(stderr,"fRet.%d\n",(int32_t)fRet); if (!fRet) { threadGroup.interrupt_all(); From 38671f757e116b6b1351518f3dd105927c6153ab Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 15:21:03 +0200 Subject: [PATCH 48/50] Test --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index c751dca21..63adecece 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -41,7 +41,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) // Tell the main threads to shutdown. while (!fShutdown) { - fprintf(stderr,"call passport iteration\n"); + //fprintf(stderr,"call passport iteration\n"); MilliSleep(10000); komodo_passport_iteration(); fShutdown = ShutdownRequested(); From dd42fd9b20ab05ade51b2bb534998fd598adaa7d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 15:47:26 +0200 Subject: [PATCH 49/50] Test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index df1431d0d..27e8a53e4 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -495,7 +495,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) fprintf(stderr,"unexpected null komodostateptr.[%s]\n",ASSETCHAINS_SYMBOL); return; } - fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); + //fprintf(stderr,"%s connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); numnotaries = komodo_notaries(pubkeys,pindex->nHeight); calc_rmd160_sha256(rmd160,pubkeys[0],33); if ( pindex->nHeight > hwmheight ) @@ -606,7 +606,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) komodo_stateupdate(height,0,0,0,zero,0,0,0,0,height,(uint32_t)pindex->nTime,0,0,0,0); } else fprintf(stderr,"komodo_connectblock: unexpected null pindex\n"); //KOMODO_INITDONE = (uint32_t)time(NULL); - fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); + //fprintf(stderr,"%s end connect.%d\n",ASSETCHAINS_SYMBOL,pindex->nHeight); } From cfd94f88ba7269064aaa94f508f98eef5bcf1c29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Feb 2017 16:10:10 +0200 Subject: [PATCH 50/50] Test --- src/komodo_gateway.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cfc942bdb..62b544da6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -84,8 +84,8 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout if ( pax != 0 ) { pax->marked = mark; - if ( height > 214700 || pax->height > 214700 ) - printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); + //if ( height > 214700 || pax->height > 214700 ) + // printf("mark ht.%d %.8f %.8f\n",pax->height,dstr(pax->komodoshis),dstr(pax->fiatoshis)); } pthread_mutex_unlock(&komodo_mutex); @@ -634,9 +634,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( (sp= komodo_stateptrget(CURRENCIES[baseids[i-1]])) != 0 && (sp->RTmask & (1LL << baseids[i-1])) == 0 ) { - printf("skip checkdeposit.%s not RT\n",CURRENCIES[baseids[i-1]]); + /*printf("skip checkdeposit.%s not RT %llx\n",CURRENCIES[baseids[i-1]],(long long)sp->RTmask); matched++; - continue; + continue;*/ } if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one {