From 7255df320a3100a5c7b1a2a6292ed7e0d3e54597 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 09:14:57 +0200 Subject: [PATCH 001/121] Test --- src/miner.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..74e72aad6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -426,10 +426,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CValidationState state; if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { - static uint32_t counter; - if ( counter++ < 100 ) + //static uint32_t counter; + //if ( counter++ < 100 ) fprintf(stderr,"warning: testblockvalidity failed\n"); - return(0); + //return(0); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } } @@ -612,15 +612,15 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - static uint32_t counter; - if ( counter++ < 100 ) + //static uint32_t counter; + //if ( counter++ < 100 ) fprintf(stderr,"created illegal block, retry\n"); - continue; + //continue; } unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) From e2ab5cb17bfd117dd22a3df103529d2fb6ef4263 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 09:34:13 +0200 Subject: [PATCH 002/121] Test --- src/komodo_gateway.h | 12 ++++++------ src/miner.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 016309a86..d7127bdb6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -661,7 +661,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 ) { - //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); +fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) return(-1); } @@ -701,9 +701,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 %llx\n",CURRENCIES[baseids[i-1]],(long long)sp->RTmask); - matched++; - continue;*/ + printf("checkdeposit.%s not RT %llx\n",CURRENCIES[baseids[i-1]],(long long)sp->RTmask); + //matched++; + //continue; } if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { @@ -724,7 +724,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } else { - if ( opcode == 'X' && strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i]]) == 0 ) + //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++; } @@ -756,7 +756,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); } - } + } else printf("accept paxdeposit\n"); } else { diff --git a/src/miner.cpp b/src/miner.cpp index 74e72aad6..429d4b6d1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -620,7 +620,7 @@ void static BitcoinMiner(CWallet *pwallet) //static uint32_t counter; //if ( counter++ < 100 ) fprintf(stderr,"created illegal block, retry\n"); - //continue; + continue; } unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) From 4fb9b7064c74c996743a957af397af6b86e7b909 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 09:45:12 +0200 Subject: [PATCH 003/121] Revert "Test" This reverts commit e2ab5cb17bfd117dd22a3df103529d2fb6ef4263. --- src/komodo_gateway.h | 12 ++++++------ src/miner.cpp | 2 +- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d7127bdb6..016309a86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -661,7 +661,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 ) { -fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); + //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) return(-1); } @@ -701,9 +701,9 @@ fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",heigh { if ( (sp= komodo_stateptrget(CURRENCIES[baseids[i-1]])) != 0 && (sp->RTmask & (1LL << baseids[i-1])) == 0 ) { - printf("checkdeposit.%s not RT %llx\n",CURRENCIES[baseids[i-1]],(long long)sp->RTmask); - //matched++; - //continue; + /*printf("skip checkdeposit.%s not RT %llx\n",CURRENCIES[baseids[i-1]],(long long)sp->RTmask); + matched++; + continue;*/ } if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { @@ -724,7 +724,7 @@ fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",heigh } else { - //if ( opcode == 'X' && strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i]]) == 0 ) + 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++; } @@ -756,7 +756,7 @@ fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",heigh printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); } - } else printf("accept paxdeposit\n"); + } } else { diff --git a/src/miner.cpp b/src/miner.cpp index 429d4b6d1..74e72aad6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -620,7 +620,7 @@ void static BitcoinMiner(CWallet *pwallet) //static uint32_t counter; //if ( counter++ < 100 ) fprintf(stderr,"created illegal block, retry\n"); - continue; + //continue; } unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) From d0f7ead0c488816f7591cb03acb59def332276a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 09:45:22 +0200 Subject: [PATCH 004/121] Revert "Test" This reverts commit 7255df320a3100a5c7b1a2a6292ed7e0d3e54597. --- src/miner.cpp | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 74e72aad6..e9ab80741 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -426,10 +426,10 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) CValidationState state; if ( !TestBlockValidity(state, *pblock, pindexPrev, false, false)) { - //static uint32_t counter; - //if ( counter++ < 100 ) + static uint32_t counter; + if ( counter++ < 100 ) fprintf(stderr,"warning: testblockvalidity failed\n"); - //return(0); + return(0); //throw std::runtime_error("CreateNewBlock(): TestBlockValidity failed"); } } @@ -612,15 +612,15 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) { - //static uint32_t counter; - //if ( counter++ < 100 ) + static uint32_t counter; + if ( counter++ < 100 ) fprintf(stderr,"created illegal block, retry\n"); - //continue; + continue; } unique_ptr pblocktemplate(ptr); if (!pblocktemplate.get()) From 6c8cc7ee1f05c333ed7d75f5bef98001bc7a26a6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 16:40:44 +0200 Subject: [PATCH 005/121] Sum outputs --- src/komodo_gateway.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 016309a86..e46ad39ee 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -630,7 +630,7 @@ void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[15]; - int32_t i,j,k,n,ht,txn_count,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; + int32_t i,j,k,n,ht,txn_count,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 total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -659,7 +659,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); if ( n <= 2 || script[0] != 0x6a ) { - if ( n == 2 && block.vtx[0].vout[1].nValue > COIN/10 ) + total = 0; + for (i=1; i COIN/10 ) { //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) From fa6b77c682799c68e08239b44be17bd033c50287 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 16:44:04 +0200 Subject: [PATCH 006/121] 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 e46ad39ee..cf7d01201 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -661,7 +661,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { total = 0; for (i=1; i COIN/10 ) { //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); From 295c54ebb8e3e14ac08404a20d59fd101a535ae1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:01:45 +0200 Subject: [PATCH 007/121] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 7779eba6e..c8111e99e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -115,7 +115,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; } - //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From d9fb6501c0fd95da2596b7610c1d6da18109346b Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:01:55 +0200 Subject: [PATCH 008/121] Revert "Test" This reverts commit 295c54ebb8e3e14ac08404a20d59fd101a535ae1. --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index c8111e99e..7779eba6e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -115,7 +115,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; } - fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From 3899eedf50e66b98ed1f0d4cc57ea37595857e06 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:02:51 +0200 Subject: [PATCH 009/121] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 7779eba6e..c8111e99e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -115,7 +115,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin numerator = (nValue * KOMODO_INTEREST); interest = (numerator / denominator) / COIN; } - //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From 87ce5503063900841a5205c62f6d40539c350eb1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:17:06 +0200 Subject: [PATCH 010/121] Test --- src/komodo_interest.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index c8111e99e..c1943eda0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -102,7 +102,10 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - interest = (numerator / denominator); + if ( txheight < 236000 ) + interest = (numerator / denominator); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + } else { @@ -113,9 +116,11 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - interest = (numerator / denominator) / COIN; + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + interest = (numerator / denominator) / COIN; + else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From c73a1174b52fe9f468375351c0eb031952c55170 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:38:35 +0200 Subject: [PATCH 011/121] Test --- src/komodo_interest.h | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index c1943eda0..fd07a44e0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,6 +73,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { + if ( minutes > 365 * 24 * 60 ) + minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -102,10 +104,13 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 236000 ) + if ( txheight < 30000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - + else + { + interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); + } } else { @@ -120,7 +125,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From 7f2e458b29ce9f5b8cae624d060d34c3206c11ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 19:58:01 +0200 Subject: [PATCH 012/121] Test --- src/komodo_interest.h | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index fd07a44e0..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,13 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 30000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); - else - { - interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); - printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); - } + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -125,7 +121,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From dd2850969594a03d50a69ff7e8997a8b8125a1fb Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:19:27 +0200 Subject: [PATCH 013/121] Revert "Test" This reverts commit 7f2e458b29ce9f5b8cae624d060d34c3206c11ae. --- src/komodo_interest.h | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..fd07a44e0 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,13 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 300000 ) + if ( txheight < 30000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else + { + interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + printf("(%llu * %llu) = %llu; ",(long long)numerator,(long long)minutes,(long long)(numerator * minutes)); + } } else { @@ -121,7 +125,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } - //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); + fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } return(interest); From 2fa533e1cd316e291c827919d9bfcddb87d3bc0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:21:28 +0200 Subject: [PATCH 014/121] Test --- src/komodo_interest.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..3b9540a1c 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 300000 ) + //if ( txheight < 300000 ) interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + //else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -117,9 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + //if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; - else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + //else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } From 9b82df63592bcb6a1c7271fa1b44cd8519e58117 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:26:06 +0200 Subject: [PATCH 015/121] Test --- src/komodo_interest.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 3b9540a1c..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,9 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - //if ( txheight < 300000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); - //else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -117,9 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - //if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) interest = (numerator / denominator) / COIN; - //else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } From 8f68a6a7608363d50f4c3f9dae54bb591dbc1a4d Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 20:58:50 +0200 Subject: [PATCH 016/121] 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 cf7d01201..6ed8d8138 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -821,9 +821,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 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); + printf("(%s) (%s) kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); From cfa255d35b08a075b13b4fa8b32ce93ff05959b9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:04:07 +0200 Subject: [PATCH 017/121] 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 6ed8d8138..ddd54de2c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -839,7 +839,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -856,7 +856,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -874,7 +874,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); } } From b61ed4395c2e81a124b055e978cfa41dbf77c515 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:15:51 +0200 Subject: [PATCH 018/121] 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 ddd54de2c..d67e0fba9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -921,7 +921,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; pax->height = pax2->height; pax->otherheight = height; - if ( 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } From 9b445a1d0e64edc9becab9612c56ae588b829d4a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:24:33 +0200 Subject: [PATCH 019/121] 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 d67e0fba9..67f2cc749 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -787,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -875,7 +875,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,pax2->txid)); } } } From 4c9da8cf5d00dbaca1e084126938a19b76ad8aba Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:26:53 +0200 Subject: [PATCH 020/121] Test --- src/komodo_gateway.h | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 67f2cc749..2d40c3262 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -787,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64],str[65]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -875,7 +875,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,pax2->txid)); + { + char str[65]; bits256 tmp; + memcpy(&tmp,&pax2->txid,sizeof(tmp)); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); + } } } } From 05d80480128496afe4dde41c3f514a56f9bf7f25 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:31:02 +0200 Subject: [PATCH 021/121] 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 2d40c3262..6751cc07b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -878,7 +878,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d %s\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d (%s)\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); } } } From 134c49d281ef5847780c69acb69b8edf1b6c97c0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:36:20 +0200 Subject: [PATCH 022/121] Test --- src/komodo_gateway.h | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6751cc07b..57ee014cd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,7 +343,7 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - if ( 0 && pax->type == 'A' ) + if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; @@ -821,7 +821,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp("USD",ASSETCHAINS_SYMBOL) == 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 paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) @@ -839,7 +839,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -856,7 +856,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -874,7 +874,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From 9f22a3940bc711dba29637137d9769e5ada47d2c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:41:05 +0200 Subject: [PATCH 023/121] 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 57ee014cd..127de8272 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s) pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From f06a20267695f53ec9e6185722eeed11f51655a0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:41:22 +0200 Subject: [PATCH 024/121] 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 127de8272..00a0fed30 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s) pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 6ada6d9a008cd2fb0858ac39e16352238fa73566 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:42:09 +0200 Subject: [PATCH 025/121] Test --- src/komodo_gateway.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 00a0fed30..c59a67b02 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,8 +343,10 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; + char str[65]; bits256 tmp; + memcpy(&tmp,pax->txid,sizeof(tmp)); if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 7658f5bdb117434e7ab2a9629a65670f22317cef Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:42:54 +0200 Subject: [PATCH 026/121] 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 c59a67b02..b60656781 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -344,7 +344,7 @@ uint64_t komodo_paxtotal() { pax->ready = 0; char str[65]; bits256 tmp; - memcpy(&tmp,pax->txid,sizeof(tmp)); + memcpy(&tmp,&pax->txid,sizeof(tmp)); if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) From d9229150424f7039f0be8fcdc854d254ba6ebbb7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:47:55 +0200 Subject: [PATCH 027/121] 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 b60656781..5628a8a93 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -343,10 +343,11 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - char str[65]; bits256 tmp; + char str[65],coinaddr[64]; bits256 tmp; + bitcoin_address(coinaddr,60,pax->rmd160,20); memcpy(&tmp,&pax->txid,sizeof(tmp)); - if ( 1 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",pax->coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); + if ( 0 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) + printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) From 5618b77a65c8b025dba7e7d5e9034b07a7f84e6c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 21:49:17 +0200 Subject: [PATCH 028/121] 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 5628a8a93..af63957f9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -373,8 +373,8 @@ uint64_t komodo_paxtotal() { seed = 0; checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 && checktoshis != 0 ) { if ( checktoshis == pax->komodoshis ) From 9ae3d21c0cc4a4552477348ebf889a63e511b6e2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:12:57 +0200 Subject: [PATCH 029/121] 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 af63957f9..8259824a8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -373,8 +373,8 @@ uint64_t komodo_paxtotal() { seed = 0; checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); - printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); + //printf("paxtotal PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",pax->height,pax->symbol,(double)pax->fiatoshis/COIN,(double)pax->komodoshis/COIN,(double)checktoshis/COIN); + //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 && checktoshis != 0 ) { if ( checktoshis == pax->komodoshis ) @@ -519,7 +519,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { 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; + //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); if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) @@ -574,7 +574,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to 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->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + //if ( numvouts++ >= 64 ) break; } if ( numvouts > 1 ) From d4ab9b565af55cb89a4b88f93a95e9555122171c Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:13:21 +0200 Subject: [PATCH 030/121] 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 8259824a8..2c0e8a322 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to 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->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - //if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) From 4502c41e746aa251e4c586e1a946191aa1bc98ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:29:53 +0200 Subject: [PATCH 031/121] Test --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2c0e8a322..93ca7b889 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -28,7 +28,8 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + netliability = (sp->issued - MAX(sp->approved,sp->withdrawn)) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -519,7 +520,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { 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; + pax->marked = pax->fiatoshis; + 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); if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) From 4445eeae6a66227e36ee0071336850d09356a3d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 16 Mar 2017 22:36:07 +0200 Subject: [PATCH 032/121] Test --- src/komodo_gateway.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 93ca7b889..b3eec1c66 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -29,7 +29,10 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *approved = sp->approved; *redeemed = sp->redeemed; //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; - netliability = (sp->issued - MAX(sp->approved,sp->withdrawn)) - sp->shorted; + maxval = sp->approved; + if ( sp->withdrawn > maxval ) + maxval = sp->withdrawn; + netliability = (sp->issued - maxval) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); From 8dfdb3d0871aee51f2f01f5cb1bf0f9433eb45c9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 01:40:08 +0200 Subject: [PATCH 033/121] Test --- src/komodo_gateway.h | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b3eec1c66..0a5661b95 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -60,12 +60,22 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } -struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) +struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t vout) { struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; - for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; @@ -716,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(1,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) ) @@ -724,7 +734,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above 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))) ) + if ( (opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue) ) { if ( pax->marked != 0 && height >= 80820 ) { From e7b74d684713dff3f5a0608efb84576dae955721 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:01:21 +0200 Subject: [PATCH 034/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..8802362af 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 29 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From 8b64937a1efd04787c359dde688d4a11a6e0463c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:01:42 +0200 Subject: [PATCH 035/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 8802362af..e9ab80741 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -100,7 +100,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 -#define ROUNDROBIN_DELAY 29 +#define ROUNDROBIN_DELAY 59 extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; From f3b1dadf87f46d45c536432d3c28327401d5f097 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:17:20 +0200 Subject: [PATCH 036/121] 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 0a5661b95..c727ecbf2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -726,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(1,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(0,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) ) From d92731b20108f4b1b33f1f8379b79ddf5da144d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:29:52 +0200 Subject: [PATCH 037/121] Test --- src/komodo_gateway.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c727ecbf2..0b93777d0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -648,7 +648,7 @@ void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[15]; - int32_t i,j,k,n,ht,txn_count,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 total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,retval,txn_count,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 maxval,total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -729,7 +729,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(0,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 ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) + { + matched++; // this node isnt running this assetchain, leaves validation to others + continue; + } + maxval = approved; + if ( redeemed > maxval ) + maxval = redeemed; + if ( (opcode == 'I' && available < pax->fiatoshis) || (opcode == 'X' && pax->komodoshis > issued-maxval) ) { 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 caa197e878565afd7d76fed0d469e0b7b77b0e70 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:39:01 +0200 Subject: [PATCH 038/121] Tighten paxdeposit limits --- src/wallet/rpcwallet.cpp | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e68ccc9be..2bcb3f703 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -627,12 +627,23 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + errflag = 1; + minval = approved; + if ( withdrawn < minval ) + minval = withdrawn; + netliability = (deposited - minval); + maxallowed = komodo_maxallowed(baseid); + if ( fiatoshis > (maxallowed - netliability) ) + errflag = 1; + if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); + komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From bf1f6b3355998ca2554c1438ce47dff46fcc439e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:42:05 +0200 Subject: [PATCH 039/121] Syntax fix --- src/wallet/rpcwallet.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2bcb3f703..4e8f2fc93 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,6 +496,8 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); +uint64_t komodo_maxallowed(int32_t baseid); +int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { From 82ecec24a7aa525e7f602ab9703136d7dd94170a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 02:43:05 +0200 Subject: [PATCH 040/121] Syntax --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 4e8f2fc93..07c8fd377 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -629,7 +629,7 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; From c6bd7b17969ffe40bbe1ed80da536bccd66ac580 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 03:44:55 +0200 Subject: [PATCH 041/121] test --- src/komodo.h | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 94fb1347c..037aa1601 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -427,8 +427,11 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( i == 0 && j == 1 && opretlen == 149 ) { - if ( notaryid >= 0 && notaryid < 64 ) + if ( signedmask != 0 ) //notaryid >= 0 && notaryid < 64 ) + { + printf("pricefeed.%llx\n",(long long)signedmask); komodo_paxpricefeed(height,&scriptbuf[len],opretlen); + } } else { @@ -446,7 +449,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I') ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } From 634aefee09e498274e70c671fec3fcf8ae7db3fa Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 03:46:19 +0200 Subject: [PATCH 042/121] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 037aa1601..f12dc723f 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -449,7 +449,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I') ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } From 37d2dcfaaafb2a42a601cc3836f4dfe76421abed Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:05:40 +0200 Subject: [PATCH 043/121] Test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index f12dc723f..aeb055f87 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -431,7 +431,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr { printf("pricefeed.%llx\n",(long long)signedmask); komodo_paxpricefeed(height,&scriptbuf[len],opretlen); - } + } else printf("ht.%d null signedmask for pricefeed?\n",height); } else { From 76b9b8b8081ff4a2dddc112d99a70d11912128ec Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:12:24 +0200 Subject: [PATCH 044/121] Test --- src/komodo.h | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index aeb055f87..bdb692d09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -427,11 +427,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr } else if ( i == 0 && j == 1 && opretlen == 149 ) { - if ( signedmask != 0 ) //notaryid >= 0 && notaryid < 64 ) - { - printf("pricefeed.%llx\n",(long long)signedmask); + if ( notaryid >= 0 && notaryid < 64 ) komodo_paxpricefeed(height,&scriptbuf[len],opretlen); - } else printf("ht.%d null signedmask for pricefeed?\n",height); } else { From 2cb18e4c818292ee6dde9c34dc49b589ac4a8024 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:35:01 +0200 Subject: [PATCH 045/121] Test --- src/komodo_gateway.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0b93777d0..d03f4fb87 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -67,8 +67,8 @@ struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t { if ( (pax= komodo_paxfind(txid,vout,'I')) != 0 ) return(pax); - if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) - return(pax); + //if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) + // return(pax); } else { @@ -726,7 +726,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(opcode == 'I',txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) @@ -847,7 +847,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("USD",ASSETCHAINS_SYMBOL) == 0 && kmdheight > 214700 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp("EUR",ASSETCHAINS_SYMBOL) == 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 paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,0)); for (i=0; i<32; i++) @@ -865,7 +865,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -882,7 +882,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -900,7 +900,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From e827f4d820e300a1e75b3bd99113199920a0a8e8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:44:23 +0200 Subject: [PATCH 046/121] 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 d03f4fb87..c6c03d3b6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -514,7 +514,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE if ( pax->height > 236000 ) { - if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) + if ( pax->type == 'D' || (kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height) ) pax->validated = pax->komodoshis; else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) pax->validated = pax->ready = 0; From 94933685a114e589a76ffc9e6a11ff986b7c2a01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 04:55:30 +0200 Subject: [PATCH 047/121] Test --- src/komodo_gateway.h | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c6c03d3b6..546c49b7f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -132,7 +132,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t memcpy(pax->buf,buf,sizeof(pax->buf)); HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; - if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); @@ -599,9 +599,12 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - for (i=0; itxid)[i]); + printf(" <- data[%d]\n",len); + } opretlen = komodo_opreturnscript(opret,opcode,data,len); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = 0; From 3c89218a54e6543e5717110d947743c3285e3760 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 05:30:52 +0200 Subject: [PATCH 048/121] 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 546c49b7f..d6d70d507 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -65,7 +65,7 @@ struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; if ( strictflag != 0 ) { - if ( (pax= komodo_paxfind(txid,vout,'I')) != 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) return(pax); //if ( (pax= komodo_paxfind(txid,vout,'X')) != 0 ) // return(pax); From 56b38b8cf8d83d1584e45281ae16ac71fc141744 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 05:42:09 +0200 Subject: [PATCH 049/121] 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 d6d70d507..465705a39 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -253,7 +253,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t for (j=0; j<32; j++) { ((uint8_t *)&txids[n])[j] = opretbuf[len++]; - //printf("%02x",((uint8_t *)&txids[n])[j]); + printf("%02x",((uint8_t *)&txids[n])[j]); } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; @@ -267,7 +267,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t memcpy(&rmd160s[n * 20],pax->rmd160,20); } } - //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); @@ -729,7 +729,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(opcode == 'I',txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) From 5e8e89d8c9fd1ba0d256071705108e7e03144356 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:10:12 +0200 Subject: [PATCH 050/121] 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 465705a39..38cba956d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -601,8 +601,8 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to data[len++] = 0; if ( pax != 0 ) { - for (i=0; itxid)[i]); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); printf(" <- data[%d]\n",len); } opretlen = komodo_opreturnscript(opret,opcode,data,len); From ea6bdd9bf2c8c5989bddd7d38ca13f4d99eecf12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:40:33 +0200 Subject: [PATCH 051/121] Test --- src/bitcoind.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 63adecece..3abaef959 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -42,7 +42,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); - MilliSleep(10000); + MilliSleep(10000/100); komodo_passport_iteration(); fShutdown = ShutdownRequested(); } From 572f12e98878d60f86cf0aa757aa251db89b5044 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 06:55:35 +0200 Subject: [PATCH 052/121] Test --- src/bitcoind.cpp | 2 +- src/main.cpp | 2 +- src/miner.cpp | 1 + 3 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/bitcoind.cpp b/src/bitcoind.cpp index 3abaef959..63adecece 100644 --- a/src/bitcoind.cpp +++ b/src/bitcoind.cpp @@ -42,7 +42,7 @@ void WaitForShutdown(boost::thread_group* threadGroup) while (!fShutdown) { //fprintf(stderr,"call passport iteration\n"); - MilliSleep(10000/100); + MilliSleep(10000); komodo_passport_iteration(); fShutdown = ShutdownRequested(); } diff --git a/src/main.cpp b/src/main.cpp index 455e6f78e..c674a3766 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3293,7 +3293,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn CScript expect = CScript() << nHeight; if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { - return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); + return state.DoS(100, error("%s: block height mismatch in coinbase ht.%d", __func__,nHeight), REJECT_INVALID, "bad-cb-height"); } } diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..e18e0d962 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -383,6 +383,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; + fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; From a13467f55fab9133d4f5d195e84637c2aaa5f250 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:01:14 +0200 Subject: [PATCH 053/121] Test --- src/komodo_gateway.h | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 38cba956d..22a1de15e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -253,7 +253,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t for (j=0; j<32; j++) { ((uint8_t *)&txids[n])[j] = opretbuf[len++]; - printf("%02x",((uint8_t *)&txids[n])[j]); + //printf("%02x",((uint8_t *)&txids[n])[j]); } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; @@ -267,7 +267,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t memcpy(&rmd160s[n * 20],pax->rmd160,20); } } - printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); + //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } } return(n); @@ -599,7 +599,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - if ( pax != 0 ) + if ( 0 && pax != 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); @@ -868,7 +868,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p deposited %s += %.8f kmdheight.%d %.8f\n",basesp,base,dstr(fiatoshis),kmdheight,dstr(value)); } else printf("cant get stateptr.(%s)\n",base); komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); @@ -885,7 +885,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } } @@ -903,7 +903,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) { char str[65]; bits256 tmp; memcpy(&tmp,&pax2->txid,sizeof(tmp)); From a17692de3c029489ddebaf92f49597b80f5fcd6e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:13:51 +0200 Subject: [PATCH 054/121] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index e18e0d962..b1cab7ba5 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -383,7 +383,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - fprintf(stderr,"set coinbase height to %d\n",nHeight); + //fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; @@ -577,7 +577,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && + if (0 && chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From 2c70b583c50306fd067789bfd6a7c2fcefb98de2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:19:58 +0200 Subject: [PATCH 055/121] 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 22a1de15e..1e5f21f96 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1092,7 +1092,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'X' ) + else if ( opretbuf[0] == 'x' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index b1cab7ba5..5d4d85493 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -577,7 +577,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"try %s Mining with %s\n",ASSETCHAINS_SYMBOL,solver.c_str()); while (true) { - if (0 && chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && + if (chainparams.MiningRequiresPeers()) //chainActive.Tip()->nHeight != 235300 && { //if ( ASSETCHAINS_SEED != 0 && chainActive.Tip()->nHeight < 100 ) // break; From dd67ab017e72afafc461a83db4defacecd381d21 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:23:10 +0200 Subject: [PATCH 056/121] Test --- src/wallet/rpcwallet.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 07c8fd377..cc5aa132e 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -672,6 +672,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; + throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From f3159f7712b33ae48260e4f855d0bb1be685525b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:24:40 +0200 Subject: [PATCH 057/121] 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 1e5f21f96..d19eca9f2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -132,7 +132,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t memcpy(pax->buf,buf,sizeof(pax->buf)); HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; - if ( 1 && ASSETCHAINS_SYMBOL[0] == 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); From 47609f61aa560a66fb1637e8b9e1b97997454dd4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:43:44 +0200 Subject: [PATCH 058/121] 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 d19eca9f2..a10dbb822 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -442,7 +442,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic if ( pax2->approved != 0 ) pax->approved = pax2->approved; } - else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 ) + else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'x')) != 0 ) pax->approved = pax->height; //printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated); if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) //strcmp((char *)"KMD",pax->symbol) == 0 && @@ -477,7 +477,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 || KOMODO_PASSPORT_INITDONE == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 || ASSETCHAINS_SYMBOL[0] == 0 ) return(0); struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); sp = komodo_stateptr(symbol,dest); From 8c782a55cba002d67fbd2da7be4ab0bef1081c12 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:51:04 +0200 Subject: [PATCH 059/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5d4d85493..da7e737c6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -142,7 +142,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) 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; } - sleep(10); + sleep(1); } KOMODO_ON_DEMAND = 0; if ( 0 && deposits != 0 ) From 6fd0ae11b7b7ef1f5b6dcfd6fdad4d6630c20d4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 07:56:32 +0200 Subject: [PATCH 060/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index da7e737c6..5d4d85493 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -142,7 +142,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) 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; } - sleep(1); + sleep(10); } KOMODO_ON_DEMAND = 0; if ( 0 && deposits != 0 ) From 05ca2ffc177742137b1abbf2307fc7ddf59430dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 08:15:03 +0200 Subject: [PATCH 061/121] disable redeems --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a10dbb822..914a5a182 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -702,6 +702,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); + return(-1); // no redeems for now } else { From ad4559b1405440079e8d3e034d7a7546a8d2c0c6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 08:24:48 +0200 Subject: [PATCH 062/121] Test --- src/komodo_gateway.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 914a5a182..d7bf08219 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -702,7 +702,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); - return(-1); // no redeems for now + if ( height >= 235300 ) + return(-1); // no redeems for now } else { From 72460f0d6b42094d039376bb0847fcf66f48313e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 13:37:30 +0200 Subject: [PATCH 063/121] Test --- src/miner.cpp | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5d4d85493..5073923aa 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -630,6 +630,12 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; + if ( 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); + continue; + } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -686,12 +692,6 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - 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); - break; - } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; From 7f44a3a97a4032193f749ce028435887780af9ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 13:58:04 +0200 Subject: [PATCH 064/121] Test --- src/miner.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 5073923aa..9318ff1a6 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -630,11 +630,14 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; - if ( ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + if ( ASSETCHAINS_SYMBOL[0] != 0 ) { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); - sleep(10); - continue; + if ( 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); + continue; + } else printf("vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); From 93722bf74151cea5eba32aa48febd998fae8da97 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:02:32 +0200 Subject: [PATCH 065/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 9318ff1a6..15a878b21 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; - } else printf("vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); From 6a235586d9627f3c7f97026d9e9ac1acbb0191d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:11:36 +0200 Subject: [PATCH 066/121] 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 d7bf08219..04c049159 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1216,7 +1216,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]) > 1800 ) + } else if ( 0 && (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 d82233d9409098c21bafe9e479d72b7376a440a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:13:25 +0200 Subject: [PATCH 067/121] Test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 15a878b21..7265935d7 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -145,7 +145,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) sleep(10); } KOMODO_ON_DEMAND = 0; - if ( 0 && deposits != 0 ) + if ( 1 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); } // -regtest only: allow overriding block.nVersion with From 8aed57832b5c3837ec354632b0e5345e3da3a953 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:23:43 +0200 Subject: [PATCH 068/121] 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 04c049159..77e9c696e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -503,7 +503,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( komodo_paxtotal() == 0 ) + if ( 1 || komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -514,7 +514,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE if ( pax->height > 236000 ) { - if ( pax->type == 'D' || (kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height) ) + if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) pax->validated = pax->komodoshis; else if ( kmdsp->CURRENT_HEIGHT > pax->height+30 ) pax->validated = pax->ready = 0; From d19a9837c2c8300c59b8156e46a7fe6124475c71 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 14:27:01 +0200 Subject: [PATCH 069/121] Test --- src/miner.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 7265935d7..5140d3595 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } From c2070e57ff9d9e9c3b224baa714df1087d88d8f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 15:09:19 +0200 Subject: [PATCH 070/121] Revert "Merge branch 'master' into dev" This reverts commit c0addba809c63493eb87ab06bed9da7d7ae89452, reversing changes made to d19a9837c2c8300c59b8156e46a7fe6124475c71. --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index cfdaea121..9246d6838 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -170,7 +170,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in for (i=0; i<66; i++) printf("%d ",mids[i]); printf(" minerids from ht.%d\n",height); - if ( notaryid >= 0 || height > 225000 ) + if ( notaryid >= 0 || height > 225065 ) return error("CheckProofOfWork(): hash doesn't match nBits"); } } From 16cd9f2db34da324f388114a22f9705ca7f79cdd Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 15:42:27 +0200 Subject: [PATCH 071/121] Revert to main --- src/komodo.h | 2 +- src/komodo_gateway.h | 87 ++++++++++++---------------------------- src/komodo_interest.h | 10 +---- src/main.cpp | 2 +- src/miner.cpp | 22 +++++----- src/pow.cpp | 2 +- src/wallet/rpcwallet.cpp | 16 +------- 7 files changed, 41 insertions(+), 100 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index bdb692d09..94fb1347c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,7 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) + if ( *isratificationp == 0 ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 77e9c696e..cf7d01201 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -28,11 +28,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - //netliability = (sp->deposited - sp->withdrawn) - sp->shorted; - maxval = sp->approved; - if ( sp->withdrawn > maxval ) - maxval = sp->withdrawn; - netliability = (sp->issued - maxval) - sp->shorted; + netliability = (sp->deposited - sp->withdrawn) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -60,22 +56,12 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) return(pax); } -struct pax_transaction *komodo_paxfinds(int32_t strictflag,uint256 txid,uint16_t vout) +struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'I', 'D', 'X', 'A', 'W' }; - if ( strictflag != 0 ) - { - if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; @@ -357,11 +343,8 @@ uint64_t komodo_paxtotal() HASH_ITER(hh,PAX,pax,tmp) { pax->ready = 0; - char str[65],coinaddr[64]; bits256 tmp; - bitcoin_address(coinaddr,60,pax->rmd160,20); - memcpy(&tmp,&pax->txid,sizeof(tmp)); - if ( 0 && pax->fiatoshis > 9000*SATOSHIDEN )//pax->type == 'A' ) - printf("(%s).%c pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d %s\n",coinaddr,pax->type,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0,bits256_str(str,tmp)); + if ( 0 && pax->type == 'A' ) + printf("%p pax.%s <- %s marked.%d %.8f -> %.8f validated.%d approved.%d\n",pax,pax->symbol,pax->source,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis),pax->validated != 0,pax->approved != 0); if ( pax->marked != 0 ) continue; if ( strcmp(symbol,pax->symbol) == 0 || pax->type == 'A' ) @@ -442,7 +425,7 @@ int32_t komodo_pending_withdraws(char *opretstr) // todo: enforce deterministic if ( pax2->approved != 0 ) pax->approved = pax2->approved; } - else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'x')) != 0 ) + else if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'X')) != 0 ) pax->approved = pax->height; //printf("pending_withdraw: pax %s marked.%u approved.%u validated.%llu\n",pax->symbol,pax->marked,pax->approved,(long long)pax->validated); if ( pax->marked == 0 && pax->approved == 0 && pax->validated != 0 ) //strcmp((char *)"KMD",pax->symbol) == 0 && @@ -477,7 +460,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 || KOMODO_PASSPORT_INITDONE == 0 || ASSETCHAINS_SYMBOL[0] == 0 ) + if ( KOMODO_PAX == 0 || KOMODO_PASSPORT_INITDONE == 0 ) return(0); struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); sp = komodo_stateptr(symbol,dest); @@ -503,7 +486,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else { opcode = 'X'; - if ( 1 || komodo_paxtotal() == 0 ) + if ( komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -533,7 +516,6 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { 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)); - pax->marked = pax->fiatoshis; 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); @@ -589,7 +571,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to 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->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 1 ) + if ( numvouts++ >= 64 ) break; } if ( numvouts > 1 ) @@ -599,12 +581,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to for (i=0; symbol[i]!=0; i++) data[len++] = symbol[i]; data[len++] = 0; - if ( 0 && pax != 0 ) - { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[32-1-i]); - printf(" <- data[%d]\n",len); - } + for (i=0; ivout.resize(numvouts+1); txNew->vout[numvouts].nValue = 0; @@ -651,7 +630,7 @@ void komodo_bannedset(uint256 *array,int32_t max) int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[15]; - int32_t i,j,k,n,ht,retval,txn_count,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 maxval,total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,txn_count,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 total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; if ( *(int32_t *)&array[0] == 0 ) komodo_bannedset(array,(int32_t)(sizeof(array)/sizeof(*array))); memset(baseids,0xff,sizeof(baseids)); @@ -702,8 +681,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; strcpy(symbol,(char *)"KMD"); - if ( height >= 235300 ) - return(-1); // no redeems for now } else { @@ -731,23 +708,15 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above matched++; continue;*/ } - if ( (pax= komodo_paxfinds(0,txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one + if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) // finds... make sure right one { pax->type = opcode; - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) < 0 ) - { - matched++; // this node isnt running this assetchain, leaves validation to others - continue; - } - maxval = approved; - if ( redeemed > maxval ) - maxval = redeemed; - if ( (opcode == 'I' && available < pax->fiatoshis) || (opcode == 'X' && pax->komodoshis > issued-maxval) ) + 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; } - if ( (opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue) ) + 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))) ) { if ( pax->marked != 0 && height >= 80820 ) { @@ -818,7 +787,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int32_t opretlen,uint256 txid,uint16_t vout,char *source) { - uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,kvheight,len,tokomodo,kmdheight,otherheights[64],kmdheights[64]; int8_t baseids[64]; char base[4],coinaddr[64],destaddr[64]; uint256 txids[64]; uint16_t vouts[64]; uint64_t convtoshis,seed; int64_t fee,fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax,*pax2; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; if ( ASSETCHAINS_SYMBOL[0] != 0 && komodo_baseid(ASSETCHAINS_SYMBOL) < 0 && opretbuf[0] != 'K' ) { @@ -852,9 +821,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( kmdheight > 195000 || kmdheight <= height ) { didstats = 0; - if ( 1 && strcmp("EUR",ASSETCHAINS_SYMBOL) == 0 && 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 paxcmp.%d\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,komodo_paxcmp(base,kmdheight,value,checktoshis,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++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); @@ -906,11 +875,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 basesp->issued += pax2->fiatoshis; pax2->didstats = 1; if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - { - char str[65]; bits256 tmp; - memcpy(&tmp,&pax2->txid,sizeof(tmp)); - printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d (%s)\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,bits256_str(str,tmp)); - } + printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight); } } } @@ -956,7 +921,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; pax->height = pax2->height; pax->otherheight = height; - if ( strcmp("USD",ASSETCHAINS_SYMBOL) == 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + if ( 0 && strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p issuedb %s += %.8f kmdheight.%d %.8f other.%d\n",basesp,CURRENCIES[baseids[i]],dstr(pax->fiatoshis),pax->height,dstr(pax->komodoshis),pax->otherheight); } } @@ -1094,7 +1059,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'x' ) + else if ( opretbuf[0] == 'X' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) @@ -1216,7 +1181,7 @@ void komodo_passport_iteration() isrealtime = 1; RTmask |= (1LL << baseid); memcpy(refsp->RTbufs[baseid+1],buf,sizeof(refsp->RTbufs[baseid+1])); - } else if ( 0 && (time(NULL)-buf[2]) > 1800 ) + } 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); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..7779eba6e 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,8 +73,6 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { - if ( minutes > 365 * 24 * 60 ) - minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -104,9 +102,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 300000 ) - interest = (numerator / denominator); - else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); + interest = (numerator / denominator); } else { @@ -117,9 +113,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) - interest = (numerator / denominator) / COIN; - else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; + interest = (numerator / denominator) / COIN; } //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } diff --git a/src/main.cpp b/src/main.cpp index c674a3766..455e6f78e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3293,7 +3293,7 @@ bool ContextualCheckBlock(const CBlock& block, CValidationState& state, CBlockIn CScript expect = CScript() << nHeight; if (block.vtx[0].vin[0].scriptSig.size() < expect.size() || !std::equal(expect.begin(), expect.end(), block.vtx[0].vin[0].scriptSig.begin())) { - return state.DoS(100, error("%s: block height mismatch in coinbase ht.%d", __func__,nHeight), REJECT_INVALID, "bad-cb-height"); + return state.DoS(100, error("%s: block height mismatch in coinbase", __func__), REJECT_INVALID, "bad-cb-height"); } } diff --git a/src/miner.cpp b/src/miner.cpp index 5140d3595..e9ab80741 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } @@ -145,7 +145,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) sleep(10); } KOMODO_ON_DEMAND = 0; - if ( 1 && deposits != 0 ) + if ( 0 && deposits != 0 ) printf("miner KOMODO_DEPOSIT %llu pblock->nHeight %d mempool.GetTotalTxSize(%d)\n",(long long)komodo_paxtotal(),(int32_t)chainActive.Tip()->nHeight,(int32_t)mempool.GetTotalTxSize()); } // -regtest only: allow overriding block.nVersion with @@ -383,7 +383,6 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) // Add fees txNew.vout[0].nValue += nFees; txNew.vin[0].scriptSig = CScript() << nHeight << OP_0; - //fprintf(stderr,"set coinbase height to %d\n",nHeight); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { int32_t i,opretlen; uint8_t opret[256],*ptr; @@ -630,15 +629,6 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; - if ( ASSETCHAINS_SYMBOL[0] != 0 ) - { - if ( 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); - continue; - } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); - } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -695,6 +685,12 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { + 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); + break; + } // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; diff --git a/src/pow.cpp b/src/pow.cpp index 9246d6838..cfdaea121 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -170,7 +170,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in for (i=0; i<66; i++) printf("%d ",mids[i]); printf(" minerids from ht.%d\n",height); - if ( notaryid >= 0 || height > 225065 ) + if ( notaryid >= 0 || height > 225000 ) return error("CheckProofOfWork(): hash doesn't match nBits"); } } diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index cc5aa132e..e68ccc9be 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,8 +496,6 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); -uint64_t komodo_maxallowed(int32_t baseid); -int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -629,23 +627,12 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) - errflag = 1; - minval = approved; - if ( withdrawn < minval ) - minval = withdrawn; - netliability = (deposited - minval); - maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > (maxallowed - netliability) ) - errflag = 1; - if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); - komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); @@ -672,7 +659,6 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; - throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From 16c7bf6bd741463d43caf1f6affc5a49468458a5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:02:28 +0200 Subject: [PATCH 072/121] Merge back most changes --- src/komodo.h | 2 +- src/komodo_gateway.h | 10 +++++++--- src/komodo_interest.h | 10 ++++++++-- src/miner.cpp | 17 +++++++++++++---- src/wallet/rpcwallet.cpp | 18 +++++++++++++++++- 5 files changed, 46 insertions(+), 11 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 94fb1347c..bdb692d09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,7 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } - if ( *isratificationp == 0 ) + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index cf7d01201..0441ce22c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -17,7 +17,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) { - int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed,maxval; *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { @@ -28,7 +28,10 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + maxval = sp->approved; + if ( sp->withdrawn > maxval ) + maxval = sp->withdrawn; + netliability = (sp->issued - maxval) - sp->shorted; maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); @@ -528,6 +531,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { 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); + pax->marked = pax->fiatoshis; continue; } if ( pax->ready == 0 ) @@ -571,7 +575,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to 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->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 7779eba6e..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -73,6 +73,8 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin { if ( (minutes= (tiptime - nLockTime) / 60) >= 60 ) { + if ( minutes > 365 * 24 * 60 ) + minutes = 365 * 24 * 60; denominator = (((uint64_t)365 * 24 * 60) / minutes); if ( denominator == 0 ) denominator = 1; // max KOMODO_INTEREST per transfer, do it at least annually! @@ -102,7 +104,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - interest = (numerator / denominator); + if ( txheight < 300000 ) + interest = (numerator / denominator); + else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } else { @@ -113,7 +117,9 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin else { numerator = (nValue * KOMODO_INTEREST); - interest = (numerator / denominator) / COIN; + if ( txheight < 300000 || numerator * minutes < 365 * 24 * 60 ) + interest = (numerator / denominator) / COIN; + else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } diff --git a/src/miner.cpp b/src/miner.cpp index e9ab80741..40226176d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -101,7 +101,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, #define ASSETCHAINS_MINHEIGHT 100 #define KOMODO_ELECTION_GAP 2000 #define ROUNDROBIN_DELAY 59 -extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE; +extern int32_t ASSETCHAINS_SEED,IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAIN_INIT,KOMODO_INITDONE,KOMODO_ON_DEMAND,KOMODO_INITDONE,KOMODO_PASSPORT_INITDONE; extern char ASSETCHAINS_SYMBOL[16]; extern std::string NOTARY_PUBKEY; extern uint8_t NOTARY_PUBKEY33[33]; @@ -133,7 +133,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) while ( KOMODO_ON_DEMAND == 0 && deposits == 0 && (int32_t)mempool.GetTotalTxSize() == 0 ) { deposits = komodo_paxtotal(); - if ( KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) + if ( KOMODO_PASSPORT_INITDONE == 0 || KOMODO_INITDONE == 0 || (komodo_baseid(ASSETCHAINS_SYMBOL) >= 0 && (isrealtime= komodo_isrealtime(&kmdheight)) == 0) ) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } @@ -629,6 +629,15 @@ void static BitcoinMiner(CWallet *pwallet) return; } CBlock *pblock = &pblocktemplate->block; + if ( ASSETCHAINS_SYMBOL[0] != 0 ) + { + if ( 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); + continue; + } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); + } IncrementExtraNonce(pblock, pindexPrev, nExtraNonce); LogPrintf("Running KomodoMiner.%s with %u transactions in block (%u bytes)\n",solver.c_str(),pblock->vtx.size(),::GetSerializeSize(*pblock,SER_NETWORK,PROTOCOL_VERSION)); // @@ -685,12 +694,12 @@ void static BitcoinMiner(CWallet *pwallet) } else Mining_start = 0; while (true) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 && pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) // skips when it shouldnt + /*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); break; - } + }*/ // Hash state KOMODO_CHOSEN_ONE = 0; crypto_generichash_blake2b_state state; diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e68ccc9be..53a2bfd03 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,6 +496,8 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); +uint64_t komodo_maxallowed(int32_t baseid); +int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -627,11 +629,24 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + baseid = komodo_baseid((char *)base.c_str()); if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + errflag = 1; + else + { + minval = approved; + if ( withdrawn < minval ) + minval = withdrawn; + netliability = (deposited - minval); + maxallowed = komodo_maxallowed(baseid); + if ( fiatoshis > (maxallowed - netliability) ) + errflag = 1; + } + if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); @@ -659,6 +674,7 @@ Value paxwithdraw(const Array& params, bool fHelp) return(0); if (!EnsureWalletIsAvailable(fHelp)) return 0; + throw runtime_error("paxwithdraw deprecated"); if (fHelp || params.size() != 2) throw runtime_error("paxwithdraw address fiatamount"); if ( komodo_isrealtime(&kmdheight) == 0 ) From 74d67d42d170884a0bf3b7d08f96347929b1a863 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:25:20 +0200 Subject: [PATCH 073/121] Prevent 'A' and 'X' events --- 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 0441ce22c..f8c20435c 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 else { opcode = 'X'; - if ( komodo_paxtotal() == 0 ) + if ( 1 || komodo_paxtotal() == 0 ) return(0); } HASH_ITER(hh,PAX,pax,tmp) @@ -684,6 +684,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above // printf("%02x",script[i]); //printf(" height.%d checkdeposit n.%d [%02x] [%c] %d vs %d\n",height,n,script[0],script[offset],script[offset],'X'); opcode = 'X'; + if ( height >= 235300 ) + return(-1); strcpy(symbol,(char *)"KMD"); } else @@ -984,7 +986,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } // else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); // need to allocate pax } - else if ( tokomodo != 0 && opretbuf[0] == 'A' ) + else if ( height < 236000 && tokomodo != 0 && opretbuf[0] == 'A' ) { tokomodo = 1; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -1063,7 +1065,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("n.%d from opreturns\n",n); //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( opretbuf[0] == 'X' ) + else if ( height < 236000 && opretbuf[0] == 'X' ) { tokomodo = 1; if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) From b24e2baaaa682e3bb4bad05c8e51ea4a069f8a22 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:31:21 +0200 Subject: [PATCH 074/121] Touch --- src/assetchains | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/assetchains b/src/assetchains index 9b0ddaaa6..23e00f362 100755 --- a/src/assetchains +++ b/src/assetchains @@ -1,4 +1,4 @@ -#!/bin/bash +#!/bin/bash set -x source pubkey.txt echo $pubkey From fbe307fd32cdd14b16f5b7394f1a545be7a07def Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:38:03 +0200 Subject: [PATCH 075/121] Test --- src/wallet/rpcwallet.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 53a2bfd03..5b69e20a7 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -629,7 +629,7 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,minval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int32_t baseid,errflag = 0; int64_t netliability,maxval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; @@ -638,13 +638,18 @@ Value paxdeposit(const Array& params, bool fHelp) errflag = 1; else { - minval = approved; - if ( withdrawn < minval ) - minval = withdrawn; - netliability = (deposited - minval); + maxval = approved; + if ( withdrawn > maxval ) + maxval = withdrawn; + if ( redeemed > maxval ) + maxval = redeemed; + netliability = (deposited - maxval); maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > (maxallowed - netliability) ) + if ( fiatoshis > netliability ) + { + fprintf(stderr,"fiatoshis %llu > (max %llu - net %llu)\n",(long long)fiatoshis,(long long)maxallowed,(long long)netliability); errflag = 1; + } } if ( errflag != 0 ) throw runtime_error("paxdeposit not enough available inventory"); From 83c54f308f427ce23318ac40c153e2fae95be757 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:40:37 +0200 Subject: [PATCH 076/121] Test --- src/komodo_gateway.h | 2 +- src/miner.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f8c20435c..6b2c7548f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,7 +941,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //else printf("opreturn none issued?\n"); } } - else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) + else if ( height < 236000 && opretbuf[0] == 'W' )//&& opretlen >= 38 ) { if ( komodo_baseid((char *)&opretbuf[opretlen-4]) >= 0 && strcmp(ASSETCHAINS_SYMBOL,(char *)&opretbuf[opretlen-4]) == 0 ) { diff --git a/src/miner.cpp b/src/miner.cpp index 40226176d..181b24a87 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -633,7 +633,9 @@ void static BitcoinMiner(CWallet *pwallet) { if ( pblock->vtx[0].vout.size() == 1 && Mining_height > ASSETCHAINS_MINHEIGHT ) { - fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); + static uint32_t counter; + if ( counter++ < 10 ) + fprintf(stderr,"skip generating %s on-demand block, no tx avail\n",ASSETCHAINS_SYMBOL); sleep(10); continue; } else fprintf(stderr,"vouts.%d mining.%d vs %d\n",(int32_t)pblock->vtx[0].vout.size(),Mining_height,ASSETCHAINS_MINHEIGHT); From d6cc943d622f2279fac56e1521db599f4a1579b4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:42:47 +0200 Subject: [PATCH 077/121] Test --- src/komodo_gateway.h | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6b2c7548f..c59a4ba67 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -887,8 +887,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - else if ( kmdheight > 238000 && (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 + { + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) + pax->marked = checktoshis; + if ( kmdheight > 238000 && (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 5e9f4470d1e7016f1cee91153121022ff4cdd8d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:43:16 +0200 Subject: [PATCH 078/121] 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 c59a4ba67..0c00efba1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -268,7 +268,7 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che if ( seed == 0 && checkvalue != 0 ) { ratio = ((value << 6) / checkvalue); - if ( ratio >= 63 && ratio <= 65 ) + if ( ratio >= 62 && ratio <= 66 ) return(0); else { From 1ecb85418874b322a2fb7e8d87289525a57f044d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:49:18 +0200 Subject: [PATCH 079/121] Test --- src/miner.cpp | 4 ++-- src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/miner.cpp b/src/miner.cpp index 181b24a87..27e892fe1 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -403,7 +403,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; @@ -612,7 +612,7 @@ void static BitcoinMiner(CWallet *pwallet) Mining_height = pindexPrev->nHeight+1; Mining_start = (uint32_t)time(NULL); } - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"%s create new block ht.%d\n",ASSETCHAINS_SYMBOL,Mining_height); CBlockTemplate *ptr = CreateNewBlockWithKey(reservekey); if ( ptr == 0 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 5b69e20a7..2fd394f22 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -634,7 +634,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; baseid = komodo_baseid((char *)base.c_str()); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) errflag = 1; else { From 8577cb287043a13f55bfa22dfc38870a1518c426 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 16:53:06 +0200 Subject: [PATCH 080/121] Test --- src/wallet/rpcwallet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 2fd394f22..46e0532c9 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -634,7 +634,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; baseid = komodo_baseid((char *)base.c_str()); - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) + /*if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) errflag = 1; else { @@ -652,7 +652,7 @@ Value paxdeposit(const Array& params, bool fHelp) } } if ( errflag != 0 ) - throw runtime_error("paxdeposit not enough available inventory"); + throw runtime_error("paxdeposit not enough available inventory");*/ komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From 7bf32ee2daefea890ac7a7144c6f51e398d10aeb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:05:15 +0200 Subject: [PATCH 081/121] Test --- src/komodo_gateway.h | 18 ++++++++++++++++-- 1 file changed, 16 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0c00efba1..858b7eeaf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -663,10 +663,24 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above script = (uint8_t *)block.vtx[0].vout[n-1].scriptPubKey.data(); if ( n <= 2 || script[0] != 0x6a ) { + int64_t val,prevtotal = 0; int32_t overflow = 0; total = 0; for (i=1; i COIN/10 ) + { + if ( (val= block.vtx[0].vout[i].nValue) < 0 || val >= MAX_MONEY ) + { + overflow = 1; + break; + } + total += val; + if ( total < prevtotal || (val != 0 && total == prevtotal) ) + { + overflow = 1; + break; + } + prevtotal = total; + } + if ( overflow != 0 || total > COIN/10 ) { //fprintf(stderr,">>>>>>>> <<<<<<<<<< ht.%d illegal nonz output %.8f n.%d\n",height,dstr(block.vtx[0].vout[1].nValue),n); if ( height >= 235300 ) From 82fd1939be4e8a6002dd9f5a6b39e7b1770082e9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:09:33 +0200 Subject: [PATCH 082/121] Test --- src/wallet/rpcwallet.cpp | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 46e0532c9..e931e96a4 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -496,8 +496,6 @@ uint256 komodo_kvsig(uint8_t *buf,int32_t len,uint256 privkey); int32_t komodo_kvduration(uint32_t flags); uint256 komodo_kvprivkey(uint256 *pubkeyp,char *passphrase); int32_t komodo_kvsigverify(uint8_t *buf,int32_t len,uint256 _pubkey,uint256 sig); -uint64_t komodo_maxallowed(int32_t baseid); -int32_t komodo_baseid(char *origbase); Value kvupdate(const Array& params, bool fHelp) { @@ -629,30 +627,12 @@ Value paxdeposit(const Array& params, bool fHelp) CBitcoinAddress address(params[0].get_str()); if (!address.IsValid()) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "Invalid Bitcoin address"); - int32_t baseid,errflag = 0; int64_t netliability,maxval,maxallowed,fiatoshis = atof(params[1].get_str().c_str()) * COIN; + int64_t fiatoshis = atof(params[1].get_str().c_str()) * COIN; std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - baseid = komodo_baseid((char *)base.c_str()); - /*if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 ) - errflag = 1; - else - { - maxval = approved; - if ( withdrawn > maxval ) - maxval = withdrawn; - if ( redeemed > maxval ) - maxval = redeemed; - netliability = (deposited - maxval); - maxallowed = komodo_maxallowed(baseid); - if ( fiatoshis > netliability ) - { - fprintf(stderr,"fiatoshis %llu > (max %llu - net %llu)\n",(long long)fiatoshis,(long long)maxallowed,(long long)netliability); - errflag = 1; - } - } - if ( errflag != 0 ) - throw runtime_error("paxdeposit not enough available inventory");*/ + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + throw runtime_error("paxdeposit not enough available inventory"); komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From ea73ef003b0569dff2e37cb092ec3c22f6aeb9d5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:16:45 +0200 Subject: [PATCH 083/121] Test --- src/komodo_gateway.h | 2 +- src/wallet/rpcwallet.cpp | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 858b7eeaf..8f0b0dd0d 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, maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); - //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,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); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index e931e96a4..b829d3474 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -632,7 +632,10 @@ Value paxdeposit(const Array& params, bool fHelp) std::string dest; height = chainActive.Tip()->nHeight; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) + { + fprintf("available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); throw runtime_error("paxdeposit not enough available inventory"); + } komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); dest.append(destaddr); CBitcoinAddress destaddress(CRYPTO777_KMDADDR); From f79f75befe0e9df6092255430773bb0502b77156 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 17:18:45 +0200 Subject: [PATCH 084/121] Test --- src/wallet/rpcwallet.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b829d3474..819b5a8ec 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -633,7 +633,7 @@ Value paxdeposit(const Array& params, bool fHelp) height = chainActive.Tip()->nHeight; if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) { - fprintf("available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); + fprintf(stderr,"available %llu vs fiatoshis %llu\n",(long long)available,(long long)fiatoshis); throw runtime_error("paxdeposit not enough available inventory"); } komodoshis = PAX_fiatdest(&seed,0,destaddr,pubkey37,(char *)params[0].get_str().c_str(),height,(char *)base.c_str(),fiatoshis); From 68025c1c832b02815b686edccc50553571dd5e4c Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:03:33 +0200 Subject: [PATCH 085/121] Remove print --- 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 8f0b0dd0d..bd7538d9b 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, maxallowed = komodo_maxallowed(baseid); if ( netliability < maxallowed ) *available = (maxallowed - netliability); - printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + //printf("%llu - %llu %s %.8f %.8f %.8f %.8f %.8f\n",(long long)maxallowed,(long long)netliability,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); From 8f3aa743bd8fbe0989bb69f54b2903b61ea6c3f3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:14:40 +0200 Subject: [PATCH 086/121] Touch --- src/komodo.h | 1 + src/komodo_gateway.h | 1 + src/komodo_interest.h | 1 + src/main.cpp | 1 - src/miner.cpp | 1 + 5 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index bdb692d09..33e4ea544 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -446,6 +446,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr printf("ISRATIFICATION (%s)\n",(char *)&scriptbuf[len+32*2+4]); } } + if ( *isratificationp == 0 && (signedmask != 0 || (scriptbuf[len] != 'X' && scriptbuf[len] != 'A' && scriptbuf[len] != 'I')) ) komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen,j); } diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index bd7538d9b..af3633a95 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -688,6 +688,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } return(0); } + //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || return(0); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 2aa745070..fa19319ef 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -99,6 +99,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } + //if ( nValue == 4000000000000LL ) // printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) diff --git a/src/main.cpp b/src/main.cpp index 455e6f78e..1a92bcd91 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -3258,7 +3258,6 @@ bool ContextualCheckBlockHeader(const CBlockHeader& block, CValidationState& sta else if ( komodo_checkpoint(¬arized_height,nHeight,hash) < 0 ) return state.DoS(100, error("%s: forked chain %d older than last notarized (height %d) vs %d", __func__,nHeight, notarized_height)); } - // Reject block.nVersion < 4 blocks if (block.nVersion < 4) return state.Invalid(error("%s : rejected nVersion<4 block", __func__), diff --git a/src/miner.cpp b/src/miner.cpp index 27e892fe1..33fe68327 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -406,6 +406,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if ( txNew.vout.size() > 1 ) fprintf(stderr,"%s txNew numvouts.%d\n",ASSETCHAINS_SYMBOL,(int32_t)txNew.vout.size()); } + pblock->vtx[0] = txNew; pblocktemplate->vTxFees[0] = -nFees; // Randomise nonce From 72475d0bf602a18174a3b35aff8014048379d129 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:15:37 +0200 Subject: [PATCH 087/121] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index fa19319ef..89e689b07 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -99,7 +99,6 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 || nValue == 4000000000000LL ) printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); } - //if ( nValue == 4000000000000LL ) // printf(">>>>>>>>>>>> exception.%d txheight.%d %.8f locktime %u vs tiptime %u <<<<<<<<<\n",exception,txheight,(double)nValue/COIN,nLockTime,tiptime); if ( exception == 0 ) @@ -122,6 +121,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin interest = (numerator / denominator) / COIN; else interest = ((numerator * minutes) / ((uint64_t)365 * 24 * 60)) / COIN; } + //fprintf(stderr,"komodo_interest %lld %.8f nLockTime.%u tiptime.%u minutes.%d interest %lld %.8f (%llu / %llu)\n",(long long)nValue,(double)nValue/COIN,nLockTime,tiptime,minutes,(long long)interest,(double)interest/COIN,(long long)numerator,(long long)denominator); } } From d1ceb5c250049de928576e6d957271a002cb0173 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:27:02 +0200 Subject: [PATCH 088/121] Test --- src/komodo_interest.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 551a31ec4..2aa745070 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -104,7 +104,7 @@ uint64_t komodo_interest(int32_t txheight,uint64_t nValue,uint32_t nLockTime,uin if ( exception == 0 ) { numerator = (nValue / 20); // assumes 5%! - if ( txheight < 30000 ) + if ( txheight < 300000 ) interest = (numerator / denominator); else interest = (numerator * minutes) / ((uint64_t)365 * 24 * 60); } From 4dabad2cf6dc6693291be463dee311937a5df827 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 17 Mar 2017 18:50:49 +0200 Subject: [PATCH 089/121] 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 af3633a95..8cf3c880c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -880,7 +880,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( 0 && strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p depositedB %s += %.8f/%.8f kmdheight.%d/%d %.8f/%.8f\n",basesp,base,dstr(fiatoshis),dstr(pax->fiatoshis),kmdheight,pax->height,dstr(value),dstr(pax->komodoshis)); } - } + } // if ( didstats != 0 ) pax->didstats = 1; if ( (pax2= komodo_paxfind(txid,vout,'I')) != 0 ) From 6401fd9fd1d6223888f4a6fbd4592092c44df6b2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 08:30:44 +0200 Subject: [PATCH 090/121] 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 8cf3c880c..995da7a0b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -695,9 +695,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - //for (i=0; i= 235300 ) return(-1); From f8413078852633764e6545af38069ee7210fb643 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 08:35:35 +0200 Subject: [PATCH 091/121] 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 995da7a0b..b84d63772 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -737,7 +737,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above 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))) ) + if ( ((opcode == 'I' && (pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) { if ( pax->marked != 0 && height >= 80820 ) { From 951bb1bbfb5e101a5eb22dd23314fe726afd833f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 08:41:09 +0200 Subject: [PATCH 092/121] 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 b84d63772..36b14168b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -735,9 +735,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above 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; + return(-1); } - if ( ((opcode == 'I' && (pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) + if ( pax->fiatoshis == block.vtx[0].vout[i].nValue ) { if ( pax->marked != 0 && height >= 80820 ) { From 4476ddfa8110305c6e706e244a765c4dbfa06c41 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 08:50:35 +0200 Subject: [PATCH 093/121] Test --- src/komodo_utils.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index d66eecaff..7c99aa4b2 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1464,7 +1464,9 @@ void komodo_args() } else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) - ; + { + printf("KOMODO_REWIND %d\n",KOMODO_REWIND); + } if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); From 25d3af9a82206be5a70511077c994d79905fcbaf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 08:55:20 +0200 Subject: [PATCH 094/121] 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 36b14168b..5cdf8548a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -690,8 +690,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } //fprintf(stderr,"ht.%d n.%d nValue %.8f (%d %d %d)\n",height,n,dstr(block.vtx[0].vout[1].nValue),KOMODO_PAX,komodo_isrealtime(&ht),KOMODO_PASSPORT_INITDONE); - if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || - return(0); offset += komodo_scriptitemlen(&opretlen,&script[offset]); if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -717,6 +715,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } } + if ( komodo_isrealtime(&ht) == 0 || KOMODO_PASSPORT_INITDONE == 0 ) //KOMODO_PAX == 0 || + return(0); if ( script[offset] == opcode && opretlen < block.vtx[0].vout[n-1].scriptPubKey.size() ) { if ( (num= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,&script[offset],opretlen,opcode == 'X')) > 0 ) From d21ce6a7460f65f14ac1d7f0cf4ee1fc2e186368 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:13:20 +0200 Subject: [PATCH 095/121] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1a92bcd91..bb6bc54d5 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2771,8 +2771,8 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND ) { - static int32_t didinit; - if ( didinit++ == 0 ) + //static int32_t didinit; + //if ( didinit++ == 0 ) { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) { From 67d2b8b9966de9c792e28d4008f855a1cf4edd2b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:18:23 +0200 Subject: [PATCH 096/121] Test --- src/main.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index bb6bc54d5..c4cb908cf 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2769,10 +2769,16 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight > KOMODO_REWIND ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { //static int32_t didinit; //if ( didinit++ == 0 ) + if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) + { + fprintf(stderr,"reached rewind.%d, ./komodo-cli stop now\n"); + sleep(3); + return(false); + } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) { From 4ce30f9076796dad5d6dfc3cb9dee75a423255a9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:19:54 +0200 Subject: [PATCH 097/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c4cb908cf..3b16b0da1 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2775,7 +2775,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo //if ( didinit++ == 0 ) if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { - fprintf(stderr,"reached rewind.%d, ./komodo-cli stop now\n"); + fprintf(stderr,"reached rewind.%d, ./komodo-cli stop now\n",KOMODO_REWIND); sleep(3); return(false); } From 4f7720b3928b847ed3ccadc804c2fc1c0e1bccdc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:22:37 +0200 Subject: [PATCH 098/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 3b16b0da1..d8fb9f35e 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2773,7 +2773,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { //static int32_t didinit; //if ( didinit++ == 0 ) - if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) + if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 ) { fprintf(stderr,"reached rewind.%d, ./komodo-cli stop now\n",KOMODO_REWIND); sleep(3); From 1e3c97ba6999ba6f82f4c94543e76ff8879a96be Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:31:54 +0200 Subject: [PATCH 099/121] Test --- src/main.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index d8fb9f35e..209437dec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2775,7 +2775,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo //if ( didinit++ == 0 ) if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 ) { - fprintf(stderr,"reached rewind.%d, ./komodo-cli stop now\n",KOMODO_REWIND); + fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); sleep(3); return(false); } @@ -2784,7 +2784,10 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); if ( !DisconnectTip(state) ) + { + InvalidateBlock(state,chainActive.Tip()) return false; + } } pindexOldTip = chainActive.Tip(); pindexFork = chainActive.FindFork(pindexMostWork); From 6cce41a5c27bd0eb5ca564f40cc19b705defe308 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:32:28 +0200 Subject: [PATCH 100/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 209437dec..825088d76 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2785,7 +2785,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); if ( !DisconnectTip(state) ) { - InvalidateBlock(state,chainActive.Tip()) + InvalidateBlock(state,chainActive.Tip()); return false; } } From 8f98af3629051d36fde0a82bb2bbf64da6eb2dee Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:53:23 +0200 Subject: [PATCH 101/121] Test --- src/main.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 825088d76..4dd841747 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2867,7 +2867,11 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - return false; + { + if ( KOMODO_REWIND == 0 ) + return false; + else return true; + } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From e513dc2a5fcede05379b6ac38f41f8612b24be9d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 09:59:29 +0200 Subject: [PATCH 102/121] Test --- src/main.cpp | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 4dd841747..b1177908c 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2773,11 +2773,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { //static int32_t didinit; //if ( didinit++ == 0 ) - if ( chainActive.Tip()->nHeight == KOMODO_REWIND+1 ) + if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { + pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - sleep(3); - return(false); + return(true); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) @@ -2867,11 +2867,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - { - if ( KOMODO_REWIND == 0 ) - return false; - else return true; - } + return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From 0364009ed95b2bf73d439388362bf0f3a1b02036 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:01:53 +0200 Subject: [PATCH 103/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index b1177908c..65a641cec 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2777,7 +2777,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo { pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - return(true); + return(false); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) From 2e245d5b305bec08e2005fb94114f39eba85b131 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:06:35 +0200 Subject: [PATCH 104/121] Test --- src/main.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 65a641cec..174893a1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2775,9 +2775,11 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo //if ( didinit++ == 0 ) if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { - pindexMostWork = chainActive.Tip(); + pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - return(false); + pindexFork = chainActive.FindFork(pindexMostWork); + sleep(3); + //return(false); } { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) From 503bab202930d2d2231bc93aaf4e89396b72775f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:11:15 +0200 Subject: [PATCH 105/121] Test --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index 174893a1a..84a7ce795 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2778,6 +2778,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); pindexFork = chainActive.FindFork(pindexMostWork); + KOMODO_REWIND = 0; sleep(3); //return(false); } From 5228ba8d86c0bd614f7630cd32baee6cf9a65cff Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:16:29 +0200 Subject: [PATCH 106/121] Test --- src/main.cpp | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 84a7ce795..1921df0ea 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2771,17 +2771,17 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { - //static int32_t didinit; - //if ( didinit++ == 0 ) + static int32_t didinit; if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); pindexFork = chainActive.FindFork(pindexMostWork); - KOMODO_REWIND = 0; sleep(3); - //return(false); + didinit++; + return(false); } + if ( didinit == 0 ) { while (chainActive.Tip()->nHeight > KOMODO_REWIND ) { @@ -2870,8 +2870,11 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - return false; - + { + if ( KOMODO_REWIND == 0 ) + return false; + fprintf(stderr,"ActivateBestChainStep rewind case\n"); + } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } From f40ac311977aebca5cf31aa2a4e8cbcd02331f13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:23:43 +0200 Subject: [PATCH 107/121] Test --- src/main.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 1921df0ea..d435d7afc 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2769,7 +2769,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND-1 ) { static int32_t didinit; if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) @@ -2783,7 +2783,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo } if ( didinit == 0 ) { - while (chainActive.Tip()->nHeight > KOMODO_REWIND ) + while (chainActive.Tip()->nHeight >= KOMODO_REWIND ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); if ( !DisconnectTip(state) ) From 120e6f4c4f23ddceec8d6ea794e59922a253b1eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:28:19 +0200 Subject: [PATCH 108/121] Test --- src/main.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/main.cpp b/src/main.cpp index d435d7afc..bd530461a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2874,6 +2874,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { if ( KOMODO_REWIND == 0 ) return false; fprintf(stderr,"ActivateBestChainStep rewind case\n"); + return true; } pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); From 9083591a3723f63ebf332789fbee883d9478ebc5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:34:00 +0200 Subject: [PATCH 109/121] Test --- src/init.cpp | 2 +- src/main.cpp | 7 +------ 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 2336a9101..e2df87ed1 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,7 +1464,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; - if (!ActivateBestChain(state)) + if (KOMODO_REWIND == 0 && !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; diff --git a/src/main.cpp b/src/main.cpp index bd530461a..e3ea9cab7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2870,12 +2870,7 @@ bool ActivateBestChain(CValidationState &state, CBlock *pblock) { return true; if (!ActivateBestChainStep(state, pindexMostWork, pblock && pblock->GetHash() == pindexMostWork->GetBlockHash() ? pblock : NULL)) - { - if ( KOMODO_REWIND == 0 ) - return false; - fprintf(stderr,"ActivateBestChainStep rewind case\n"); - return true; - } + return false; pindexNewTip = chainActive.Tip(); fInitialDownload = IsInitialBlockDownload(); } From d27148cf0cb242534cb2b4e54365755ffd87583a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:38:10 +0200 Subject: [PATCH 110/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index e3ea9cab7..06ef18e33 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2779,7 +2779,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo pindexFork = chainActive.FindFork(pindexMostWork); sleep(3); didinit++; - return(false); + return(true); } if ( didinit == 0 ) { From 3938336c6c420c11eeaf72cba78022f616ba725c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:45:40 +0200 Subject: [PATCH 111/121] Test --- src/init.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init.cpp b/src/init.cpp index e2df87ed1..d586108a4 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,7 +1464,12 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; - if (KOMODO_REWIND == 0 && !ActivateBestChain(state)) + if ( KOMODO_REWIND < 0 ) + { + KOMODO_REWIND = 0; + fprintf(stderr,"bypass ActivateBestChain\n"); + } + else if ( !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; From 373e276894c14bb180cbc813652f17344ddd3dfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 10:46:45 +0200 Subject: [PATCH 112/121] Test --- src/init.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/init.cpp b/src/init.cpp index d586108a4..95bff62d5 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1464,6 +1464,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; + extern int32_t KOMODO_REWIND; if ( KOMODO_REWIND < 0 ) { KOMODO_REWIND = 0; From 6856606faf3314ac24952cfe442a750e9ef3d94b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:42:32 +0200 Subject: [PATCH 113/121] 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 5cdf8548a..d2d41d685 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1127,7 +1127,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 = 17; + static long lastpos[34]; static char userpass[33][1024]; int32_t maxseconds = 1; 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; @@ -1176,7 +1176,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 < 10000 ) + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 && n < 1000 ) { if ( n == 999 ) { From f4b73908f18d312f177fce790208c08f71bae0ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:51:12 +0200 Subject: [PATCH 114/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index 06ef18e33..e308a2b08 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2781,7 +2781,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo didinit++; return(true); } - if ( didinit == 0 ) + //if ( didinit == 0 ) { while (chainActive.Tip()->nHeight >= KOMODO_REWIND ) { From 297a497832ad1c412ac64d502364341a69662acb Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 11:57:54 +0200 Subject: [PATCH 115/121] Test --- src/main.cpp | 30 +++++++++++++----------------- 1 file changed, 13 insertions(+), 17 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index e308a2b08..91e1ed721 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2769,32 +2769,28 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } - if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND-1 ) + if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { - static int32_t didinit; + fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); + while ( chainActive.Tip()->nHeight > KOMODO_REWIND ) + { + if ( !DisconnectTip(state) ) + { + //InvalidateBlock(state,chainActive.Tip()); + return false; + } + } + fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight); if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); pindexFork = chainActive.FindFork(pindexMostWork); sleep(3); - didinit++; return(true); } - //if ( didinit == 0 ) - { - while (chainActive.Tip()->nHeight >= KOMODO_REWIND ) - { - fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); - if ( !DisconnectTip(state) ) - { - InvalidateBlock(state,chainActive.Tip()); - return false; - } - } - pindexOldTip = chainActive.Tip(); - pindexFork = chainActive.FindFork(pindexMostWork); - } + pindexOldTip = chainActive.Tip(); + pindexFork = chainActive.FindFork(pindexMostWork); } // Build list of new blocks to connect. std::vector vpindexToConnect; From 6a877e46d5ca4fb32ed07bd0b38e54f7137c58dc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:23:35 +0200 Subject: [PATCH 116/121] Test --- src/init.cpp | 20 +++++--------------- src/komodo_globals.h | 2 +- src/komodo_utils.h | 4 ++-- src/main.cpp | 6 ++---- src/pow.cpp | 7 ++++--- src/wallet/wallet.cpp | 4 ++-- 6 files changed, 16 insertions(+), 27 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 95bff62d5..59dcc27b9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -1244,14 +1244,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) LogPrintf("Prune: pruned datadir may not have more than %d blocks; -checkblocks=%d may fail\n", MIN_BLOCKS_TO_KEEP, GetArg("-checkblocks", 288)); } - extern int32_t KOMODO_REWIND; - if ( KOMODO_REWIND == 0 ) - { - if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), - GetArg("-checkblocks", 288))) { - strLoadError = _("Corrupted block database detected"); - break; - } + if (!CVerifyDB().VerifyDB(pcoinsdbview, GetArg("-checklevel", 3), + GetArg("-checkblocks", 288))) { + strLoadError = _("Corrupted block database detected"); + break; } } catch (const std::exception& e) { if (fDebug) LogPrintf("%s\n", e.what()); @@ -1464,13 +1460,7 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) uiInterface.InitMessage(_("Activating best chain...")); // scan for better chains in the block chain database, that are not yet connected in the active best chain CValidationState state; - extern int32_t KOMODO_REWIND; - if ( KOMODO_REWIND < 0 ) - { - KOMODO_REWIND = 0; - fprintf(stderr,"bypass ActivateBestChain\n"); - } - else if ( !ActivateBestChain(state)) + if ( !ActivateBestChain(state)) strErrors << "Failed to connect best block"; std::vector vImportFiles; diff --git a/src/komodo_globals.h b/src/komodo_globals.h index 9af4d0b36..9b93ff57e 100644 --- a/src/komodo_globals.h +++ b/src/komodo_globals.h @@ -40,7 +40,7 @@ struct komodo_state KOMODO_STATES[34]; #define _COINBASE_MATURITY 100 int COINBASE_MATURITY = _COINBASE_MATURITY;//100; -int32_t IS_KOMODO_NOTARY,KOMODO_REWIND,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; +int32_t IS_KOMODO_NOTARY,USE_EXTERNAL_PUBKEY,KOMODO_CHOSEN_ONE,ASSETCHAINS_SEED,KOMODO_ON_DEMAND,KOMODO_EXTERNAL_NOTARIES,KOMODO_PASSPORT_INITDONE,KOMODO_PAX,KOMODO_EXCHANGEWALLET; int32_t KOMODO_LASTMINED,prevKOMODO_LASTMINED; std::string NOTARY_PUBKEY,ASSETCHAINS_NOTARIES; uint8_t NOTARY_PUBKEY33[33]; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 7c99aa4b2..1c32bb068 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1463,10 +1463,10 @@ void komodo_args() KOMODO_PAX = 1; } else KOMODO_PAX = GetArg("-pax",0); name = GetArg("-ac_name",""); - if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) + /*if ( (KOMODO_REWIND= GetArg("-rewind",0)) != 0 ) { printf("KOMODO_REWIND %d\n",KOMODO_REWIND); - } + }*/ if ( name.c_str()[0] != 0 ) { ASSETCHAINS_SUPPLY = GetArg("-ac_supply",10); diff --git a/src/main.cpp b/src/main.cpp index 91e1ed721..a45caae1a 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2758,7 +2758,6 @@ static void PruneBlockIndexCandidates() { * pblock is either NULL or a pointer to a CBlock corresponding to pindexMostWork. */ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMostWork, CBlock *pblock) { - extern int32_t KOMODO_REWIND; AssertLockHeld(cs_main); bool fInvalidFound = false; const CBlockIndex *pindexOldTip = chainActive.Tip(); @@ -2769,6 +2768,7 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo if (!DisconnectTip(state)) return false; } + /*fprintf(stderr,"chaintip %d vs rewind.%d\n",(int32_t)chainActive.Tip()->nHeight,KOMODO_REWIND); if ( KOMODO_REWIND != 0 && chainActive.Tip()->nHeight >= KOMODO_REWIND ) { fprintf(stderr,"rewind ht.%d\n",chainActive.Tip()->nHeight); @@ -2783,15 +2783,13 @@ static bool ActivateBestChainStep(CValidationState &state, CBlockIndex *pindexMo fprintf(stderr,"end rewind ht.%d\n",chainActive.Tip()->nHeight); if ( chainActive.Tip()->nHeight == KOMODO_REWIND ) { - pindexOldTip = pindexMostWork = chainActive.Tip(); fprintf(stderr,"reached rewind.%d, best to do: ./komodo-cli stop\n",KOMODO_REWIND); - pindexFork = chainActive.FindFork(pindexMostWork); sleep(3); return(true); } pindexOldTip = chainActive.Tip(); pindexFork = chainActive.FindFork(pindexMostWork); - } + }*/ // Build list of new blocks to connect. std::vector vpindexToConnect; bool fContinue = true; diff --git a/src/pow.cpp b/src/pow.cpp index cfdaea121..655a9dfad 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -119,7 +119,7 @@ extern std::string NOTARY_PUBKEY; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { - extern int32_t KOMODO_REWIND; + //extern int32_t KOMODO_REWIND; bool fNegative,fOverflow; int32_t i,nonzpkeys=0,nonz=0,special=0,special2=0,notaryid=-1,duplicate,flag = 0, mids[66]; arith_uint256 bnTarget; CBlockIndex *pindex; uint8_t pubkeys[66][33]; @@ -155,7 +155,8 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in // Check proof of work matches claimed amount if ( UintToArith256(hash) > bnTarget ) { - if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 && KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 + if ( (height < 235300 || height >= 236000) && KOMODO_LOADINGBLOCKS == 0 && height > 188000 ) + //&& KOMODO_REWIND == 0 )//186269, 182507&& komodo_chainactive(height) != 0 && nonzpkeys > 0 { int32_t i; for (i=31; i>=0; i--) @@ -163,7 +164,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in printf(" hash vs "); for (i=31; i>=0; i--) printf("%02x",((uint8_t *)&bnTarget)[i]); - printf(" ht.%d REWIND.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,KOMODO_REWIND,special,notaryid,height,(height % 35)); + printf(" ht.%d special.%d notaryid.%d ht.%d mod.%d error\n",height,special,notaryid,height,(height % 35)); for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" <- pubkey\n"); diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 091fb5e22..ac7f1f9f5 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -757,7 +757,7 @@ void CWallet::IncrementNoteWitnesses(const CBlockIndex* pindex, void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) { - extern int32_t KOMODO_REWIND; + //extern int32_t KOMODO_REWIND; { LOCK(cs_wallet); for (std::pair& wtxItem : mapWallet) { @@ -806,7 +806,7 @@ void CWallet::DecrementNoteWitnesses(const CBlockIndex* pindex) extern char ASSETCHAINS_SYMBOL[16]; fprintf(stderr,"%s nWitnessCacheSize.%d\n",ASSETCHAINS_SYMBOL,(int32_t)nWitnessCacheSize); } - if ( KOMODO_REWIND == 0 ) + //if ( KOMODO_REWIND == 0 ) assert(nWitnessCacheSize > 0); //if (fFileBacked) { // CWalletDB walletdb(strWalletFile); From 48e3b128542b92aee031d978448da573c1c38627 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:50:25 +0200 Subject: [PATCH 117/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index a45caae1a..8cd234095 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1551,7 +1551,7 @@ bool IsInitialBlockDownload() state = (chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()); else state = (chainActive.Height() < ptr->nHeight - 100); - //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); + fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); if (!state) { lockIBDState = true; From 3d3374839c7f481d6d1d4f4421afe3231e5fdae4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 12:54:07 +0200 Subject: [PATCH 118/121] Test --- src/main.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 8cd234095..c1d85af59 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,10 +1548,10 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = (chainActive.Height() < ptr->nHeight - 24*6) || - ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge()); + state = chainActive.Height() < 241777 && ((chainActive.Height() < ptr->nHeight - 24*6) || + ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); - fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); + //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); if (!state) { lockIBDState = true; From e9134f7f9ef1686197eeec5b45ab5a1d4637cc13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:16:33 +0200 Subject: [PATCH 119/121] 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 d2d41d685..556326102 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1207,7 +1207,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]) > 1800 ) + } else if ( (time(NULL)-buf[2]) > 1800 && ASSETCHAINS_SYMBOL[0] != 0 ) 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 4608ac92db5584148e528806432b5dc452995bc6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:23:02 +0200 Subject: [PATCH 120/121] Test --- src/main.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main.cpp b/src/main.cpp index c1d85af59..539aa92ae 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,7 +1548,7 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = chainActive.Height() < 241777 && ((chainActive.Height() < ptr->nHeight - 24*6) || + state = chainActive.Height() < 242000 && ((chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); From 269fe243671d3a4a5ad374137d999cc4dbdf720f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 18 Mar 2017 13:28:18 +0200 Subject: [PATCH 121/121] Test --- src/main.cpp | 2 +- src/miner.cpp | 2 +- src/rpcmining.cpp | 4 ++-- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/main.cpp b/src/main.cpp index 539aa92ae..37b024da7 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1548,7 +1548,7 @@ bool IsInitialBlockDownload() else if ( pindexBestHeader != 0 && pindexBestHeader->nHeight > ptr->nHeight ) ptr = pindexBestHeader; if ( ASSETCHAINS_SYMBOL[0] == 0 ) - state = chainActive.Height() < 242000 && ((chainActive.Height() < ptr->nHeight - 24*6) || + state = ((chainActive.Height() < ptr->nHeight - 24*6) || ptr->GetBlockTime() < (GetTime() - chainParams.MaxTipAge())); else state = (chainActive.Height() < ptr->nHeight - 100); //fprintf(stderr,"state.%d ht.%d vs %d, t.%u %u\n",state,(int32_t)chainActive.Height(),(uint32_t)ptr->nHeight,(int32_t)ptr->GetBlockTime(),(uint32_t)(GetTime() - chainParams.MaxTipAge())); diff --git a/src/miner.cpp b/src/miner.cpp index 33fe68327..37f96015d 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -590,7 +590,7 @@ void static BitcoinMiner(CWallet *pwallet) LOCK(cs_vNodes); fvNodesEmpty = vNodes.empty(); } - if (!fvNodesEmpty && !IsInitialBlockDownload()) + if (!fvNodesEmpty )//&& !IsInitialBlockDownload()) break; MilliSleep(5000); //fprintf(stderr,"fvNodesEmpty %d IsInitialBlockDownload(%s) %d\n",(int32_t)fvNodesEmpty,ASSETCHAINS_SYMBOL,(int32_t)IsInitialBlockDownload()); diff --git a/src/rpcmining.cpp b/src/rpcmining.cpp index 77d4de1b6..8dc4111a5 100644 --- a/src/rpcmining.cpp +++ b/src/rpcmining.cpp @@ -530,8 +530,8 @@ Value getblocktemplate(const Array& params, bool fHelp) if (vNodes.empty()) throw JSONRPCError(RPC_CLIENT_NOT_CONNECTED, "Zcash is not connected!"); - if (IsInitialBlockDownload()) - throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); + //if (IsInitialBlockDownload()) + // throw JSONRPCError(RPC_CLIENT_IN_INITIAL_DOWNLOAD, "Zcash is downloading blocks..."); static unsigned int nTransactionsUpdatedLast;