From f8b5c1642c3261a22a2ce489182a3c7a759de423 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Dec 2016 20:51:58 +0200 Subject: [PATCH 01/38] test --- src/komodo_utils.h | 4 ++-- src/main.cpp | 5 ++--- src/util.cpp | 3 ++- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 15562669d..3e53b79c9 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1317,9 +1317,9 @@ void komodo_configfile(char *symbol,uint16_t port) sprintf(buf,"%s.conf",symbol); BITCOIND_PORT = port; #ifdef WIN32 - sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf); + sprintf(fname,"%s\\assets\\%s",GetDataDir(false).string().c_str(),buf); #else - sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf); + sprintf(fname,"%s/assets/%s",GetDataDir(false).string().c_str(),buf); #endif if ( (fp= fopen(fname,"rb")) == 0 ) { diff --git a/src/main.cpp b/src/main.cpp index fe832ac0f..8e8223c1f 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -550,7 +550,6 @@ CBlockTreeDB *pblocktree = NULL; // Komodo globals -#define KOMODO_TESTNET_EXPIRATION 100000 #define KOMODO_PAX #define KOMODO_ZCASH #include "komodo.h" @@ -2155,8 +2154,8 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin } bool fScriptChecks = (!fCheckpointsEnabled || pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(chainparams.Checkpoints())); - if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" - return(false); + //if ( KOMODO_TESTNET_EXPIRATION != 0 && pindex->nHeight > KOMODO_TESTNET_EXPIRATION ) // "testnet" + // return(false); // Do not allow blocks that contain transactions which 'overwrite' older transactions, // unless those are already completely spent. BOOST_FOREACH(const CTransaction& tx, block.vtx) { diff --git a/src/util.cpp b/src/util.cpp index 4dfe13919..aec973cb6 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -526,7 +526,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path /= BaseParams().DataDir(); fs::create_directories(path); - + std::string assetpath = path + "/assets"; + boost::filesystem::create_directory(assetpath); return path; } From c1428363799ce275b810060e84fc7ac9cb5765ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 5 Dec 2016 20:58:45 +0200 Subject: [PATCH 02/38] test --- src/komodo_utils.h | 4 ++-- src/util.cpp | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 3e53b79c9..15562669d 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -1317,9 +1317,9 @@ void komodo_configfile(char *symbol,uint16_t port) sprintf(buf,"%s.conf",symbol); BITCOIND_PORT = port; #ifdef WIN32 - sprintf(fname,"%s\\assets\\%s",GetDataDir(false).string().c_str(),buf); + sprintf(fname,"%s\\%s",GetDataDir(false).string().c_str(),buf); #else - sprintf(fname,"%s/assets/%s",GetDataDir(false).string().c_str(),buf); + sprintf(fname,"%s/%s",GetDataDir(false).string().c_str(),buf); #endif if ( (fp= fopen(fname,"rb")) == 0 ) { diff --git a/src/util.cpp b/src/util.cpp index aec973cb6..86821ef0a 100644 --- a/src/util.cpp +++ b/src/util.cpp @@ -526,8 +526,8 @@ const boost::filesystem::path &GetDataDir(bool fNetSpecific) path /= BaseParams().DataDir(); fs::create_directories(path); - std::string assetpath = path + "/assets"; - boost::filesystem::create_directory(assetpath); + //std::string assetpath = path + "/assets"; + //boost::filesystem::create_directory(assetpath); return path; } From ef3e97f1fd8382f2ee51f8d0ef2e4d1efe8e05d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 11:36:20 +0200 Subject: [PATCH 03/38] 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 0fb8a74d7..0b7b2b6ae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -690,8 +690,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; pax->type = opretbuf[0]; pax->validated = komodoshis; - } - } + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("set validated W.%d %.8f\n",kmdheight,dstr(value)); + } else printf("cant paxfind W\n"); + } else printf("withdraw paxcmp error %.8f vs %.8f\n",dstr(komodoshis),dstr(checktoshis)); } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { From 431afba819e92ec1f9106c2a8de57d7135a1a86d Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 11:40:38 +0200 Subject: [PATCH 04/38] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 0b7b2b6ae..27e463b8a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -668,7 +668,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - //printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); + if ( strcmp(ASSETCHAINS_SYMBOL,"RUB") == 0 ) + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); didstats = 0; if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) { @@ -693,7 +694,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("set validated W.%d %.8f\n",kmdheight,dstr(value)); } else printf("cant paxfind W\n"); - } else printf("withdraw paxcmp error %.8f vs %.8f\n",dstr(komodoshis),dstr(checktoshis)); + } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { From a3608c899a04d0a7a08108a886612232b614ff84 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 11:45:47 +0200 Subject: [PATCH 05/38] 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 27e463b8a..4f2f09009 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -659,7 +659,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( strcmp(source,ASSETCHAINS_SYMBOL) == 0 ) printf("source.%s opreturn[I] matches %s\n",source,(char *)&opretbuf[opretlen-4]); } - else if ( opretbuf[0] == 'W' && opretlen >= 38 ) + else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) { tokomodo = 1; iguana_rwnum(0,&opretbuf[34],sizeof(kmdheight),&kmdheight); @@ -668,8 +668,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; - if ( strcmp(ASSETCHAINS_SYMBOL,"RUB") == 0 ) - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s)\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr); + if ( strcmp(base,"RUB") == 0 ) + printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); didstats = 0; if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) { From 4718923df5dad047a69c22c7f24843ce341bb536 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:00:35 +0200 Subject: [PATCH 06/38] test --- src/komodo_gateway.h | 5 +++-- src/miner.cpp | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f2f09009..323fd29e4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -669,7 +669,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 checktoshis = PAX_fiatdest(&seed,tokomodo,destaddr,pubkey33,coinaddr,kmdheight,base,value); typestr = "withdraw"; if ( strcmp(base,"RUB") == 0 ) - printf("%s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); + printf("RUB WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); didstats = 0; if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) { @@ -682,7 +682,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); } - //printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); + if ( strcmp(base,"RUB") == 0 ) + printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) diff --git a/src/miner.cpp b/src/miner.cpp index 1c7b477b0..7d60d1374 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -131,7 +131,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) { //fprintf(stderr,"INITDONE.%d RT.%d deposits %.8f ht.%d\n",KOMODO_INITDONE,isrealtime,(double)deposits/COIN,kmdheight); } - else if ( deposits != 0 ) + else if ( deposits != 0 || (int32_t)mempool.GetTotalTxSize() > 0 ) { fprintf(stderr,"start CreateNewBlock %s initdone.%d deposit %.8f mempool.%d RT.%u KOMODO_ON_DEMAND.%d\n",ASSETCHAINS_SYMBOL,KOMODO_INITDONE,(double)komodo_paxtotal()/COIN,(int32_t)mempool.GetTotalTxSize(),isrealtime,KOMODO_ON_DEMAND); break; From d34d6ce4c26a29fafd112c37a9a6107ad991fecd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:05:26 +0200 Subject: [PATCH 07/38] test --- src/komodo_gateway.h | 6 +++++- src/komodo_pax.h | 3 ++- src/miner.cpp | 2 +- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 323fd29e4..9a683125e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -688,8 +688,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) { - if ( didstats != 0 ) + if ( didstats != 0 && pax->didstats == 0 ) + { + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p withdrawn %s += %.8f kmdht.%d ht.%d\n",basesp,base,dstr(value),kmdheight,height); pax->didstats = 1; + } pax->type = opretbuf[0]; pax->validated = komodoshis; if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 1f7e23a03..d7c759248 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -527,7 +527,8 @@ uint64_t PAX_fiatdest(uint64_t *seedp,int32_t tokomodo,char *destaddr,uint8_t pu if ( fiatoshis < 0 ) shortflag = 1, fiatoshis = -fiatoshis; komodoshis = komodo_paxprice(seedp,height,base,(char *)"KMD",(uint64_t)fiatoshis); - //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); + if ( strcmp(base,"RUB") == 0 ) + printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f seed.%llx\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN,(long long)*seedp); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); diff --git a/src/miner.cpp b/src/miner.cpp index 7d60d1374..43d04e639 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -121,7 +121,7 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn) if(!pblocktemplate.get()) return NULL; CBlock *pblock = &pblocktemplate->block; // pointer for convenience - if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight > ASSETCHAINS_MINHEIGHT ) + if ( ASSETCHAINS_SYMBOL[0] != 0 && chainActive.Tip()->nHeight >= ASSETCHAINS_MINHEIGHT ) { isrealtime = komodo_isrealtime(&kmdheight); while ( KOMODO_ON_DEMAND == 0 ) From b75c9445c78daa27bc37482a1570711ea90d4b96 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:11:11 +0200 Subject: [PATCH 08/38] test --- src/komodo_gateway.h | 2 -- src/komodo_pax.h | 5 ++++- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9a683125e..9578fce8e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -656,8 +656,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } else printf("opreturn none issued?\n"); } - if ( strcmp(source,ASSETCHAINS_SYMBOL) == 0 ) - printf("source.%s opreturn[I] matches %s\n",source,(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'W' )//&& opretlen >= 38 ) { diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d7c759248..f131881a0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -473,7 +473,6 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,*seedp) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,*seedp) * 539; - //printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i> 1) ) + { + printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); + printf("komodo_paxprice nonz.%d of numvotes.%d\n",nonz,numvotes); return(0); + } return(komodo_paxcorrelation(votes,numvotes,*seedp) * basevolume / 100000); } From 5dd7d1d193eb4962084d7d68a6ed9e08702bbcbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:18:23 +0200 Subject: [PATCH 09/38] test --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f131881a0..c5af0fe47 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -481,7 +481,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) { - printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); + printf("NUM_PVALS.%d kmdbtc %llu btcusd %llu ",NUM_PRICES,(long long)kmdbtc,(long long)btcusd); printf("komodo_paxprice nonz.%d of numvotes.%d\n",nonz,numvotes); return(0); } From 16b911e0bf7ea2d0399c11321822b643c255cb10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:27:39 +0200 Subject: [PATCH 10/38] test --- src/komodo.h | 7 +++++-- src/komodo_gateway.h | 15 +++++++++++++-- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2d978d443..2c5cee2fc 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -200,8 +200,11 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) - ; + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + ; + } else fseek(fp,0,SEEK_END); } else fp = fopen(fname,"wb+"); printf("fname.(%s) fpos.%ld\n",fname,ftell(fp)); KOMODO_INITDONE = (uint32_t)time(NULL); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9578fce8e..186177f62 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -792,7 +792,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 void komodo_passport_iteration() { - static long lastpos[34]; static char userpass[33][1024]; + static long lastpos[34]; static char didinit,userpass[33][1024]; FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3]; cJSON *infoobj,*result; uint64_t RTmask = 0; while ( KOMODO_INITDONE == 0 ) { @@ -803,7 +803,7 @@ void komodo_passport_iteration() if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 - //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { sp = 0; @@ -847,6 +847,17 @@ void komodo_passport_iteration() } else { + if ( baseid < 32 && didinit == 0 ) + { + komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); + if ( (fp= fopen(fname,"rb+")) != 0 ) + { + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + ; + fclose(fp); + } + didinit = 1; + } komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"wb")) != 0 ) { From 2510135c3d0cf681ababf688e0abe906bed24d8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:35:12 +0200 Subject: [PATCH 11/38] test --- src/komodo_gateway.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 186177f62..47b91f1eb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -673,29 +673,24 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) - { - basesp->withdrawn += value; - didstats = 1; - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); - } if ( strcmp(base,"RUB") == 0 ) printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) { - if ( didstats != 0 && pax->didstats == 0 ) + if ( pax->didstats == 0 ) { - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p withdrawn %s += %.8f kmdht.%d ht.%d\n",basesp,base,dstr(value),kmdheight,height); - pax->didstats = 1; + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->withdrawn += value; + pax->didstats = 1; + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + } } pax->type = opretbuf[0]; pax->validated = komodoshis; - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("set validated W.%d %.8f\n",kmdheight,dstr(value)); } else printf("cant paxfind W\n"); } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); } @@ -803,7 +798,7 @@ void komodo_passport_iteration() if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 - printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { sp = 0; From 0126d891aad3b1e45c89fc01bc4f682b2b52ffdb Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:46:33 +0200 Subject: [PATCH 12/38] Revert "test" This reverts commit 2510135c3d0cf681ababf688e0abe906bed24d8c. --- src/komodo_gateway.h | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 47b91f1eb..186177f62 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -673,24 +673,29 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->withdrawn += value; + didstats = 1; + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + } if ( strcmp(base,"RUB") == 0 ) printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) { - if ( pax->didstats == 0 ) + if ( didstats != 0 && pax->didstats == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) - { - basesp->withdrawn += value; - pax->didstats = 1; - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); - } + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p withdrawn %s += %.8f kmdht.%d ht.%d\n",basesp,base,dstr(value),kmdheight,height); + pax->didstats = 1; } pax->type = opretbuf[0]; pax->validated = komodoshis; + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("set validated W.%d %.8f\n",kmdheight,dstr(value)); } else printf("cant paxfind W\n"); } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); } @@ -798,7 +803,7 @@ void komodo_passport_iteration() if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 - //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { sp = 0; From 368c61bccffa7bc307bd4cd92084161d90c0c623 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:46:39 +0200 Subject: [PATCH 13/38] Revert "test" This reverts commit 16b911e0bf7ea2d0399c11321822b643c255cb10. --- src/komodo.h | 7 ++----- src/komodo_gateway.h | 15 ++------------- 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 2c5cee2fc..2d978d443 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -200,11 +200,8 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); if ( (fp= fopen(fname,"rb+")) != 0 ) { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) - ; - } else fseek(fp,0,SEEK_END); + while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) + ; } else fp = fopen(fname,"wb+"); printf("fname.(%s) fpos.%ld\n",fname,ftell(fp)); KOMODO_INITDONE = (uint32_t)time(NULL); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 186177f62..9578fce8e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -792,7 +792,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 didinit,userpass[33][1024]; + static long lastpos[34]; static char userpass[33][1024]; FILE *fp; int32_t baseid,isrealtime,refid,blocks,longest; struct komodo_state *sp,*refsp; char *retstr,fname[512],*base,symbol[16],dest[16]; uint32_t buf[3]; cJSON *infoobj,*result; uint64_t RTmask = 0; while ( KOMODO_INITDONE == 0 ) { @@ -803,7 +803,7 @@ void komodo_passport_iteration() if ( ASSETCHAINS_SYMBOL[0] == 0 ) refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 - printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); + //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); for (baseid=32; baseid>=0; baseid--) { sp = 0; @@ -847,17 +847,6 @@ void komodo_passport_iteration() } else { - if ( baseid < 32 && didinit == 0 ) - { - komodo_statefname(fname,ASSETCHAINS_SYMBOL,(char *)"komodostate"); - if ( (fp= fopen(fname,"rb+")) != 0 ) - { - while ( komodo_parsestatefile(sp,fp,symbol,dest) >= 0 ) - ; - fclose(fp); - } - didinit = 1; - } komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"realtime"); if ( (fp= fopen(fname,"wb")) != 0 ) { From ba01ff1f0e4296f2ccfed49fb05bdf9aa7e8ae82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 12:46:58 +0200 Subject: [PATCH 14/38] Revert "test" This reverts commit 5dd7d1d193eb4962084d7d68a6ed9e08702bbcbd. --- src/komodo_pax.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c5af0fe47..f131881a0 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -481,7 +481,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) { - printf("NUM_PVALS.%d kmdbtc %llu btcusd %llu ",NUM_PRICES,(long long)kmdbtc,(long long)btcusd); + printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); printf("komodo_paxprice nonz.%d of numvotes.%d\n",nonz,numvotes); return(0); } From 115e6a5c869ce0d645c45c72d6a4bd80ab0d5315 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 15:55:48 +0200 Subject: [PATCH 15/38] test --- src/komodo_gateway.h | 35 +++++++++++++++-------------------- src/komodo_structs.h | 2 +- 2 files changed, 16 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9578fce8e..dc1d17007 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -251,9 +251,9 @@ uint64_t komodo_paxtotal() str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); - if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) + if ( basesp != 0 && pax->didstats == 0 ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) + if ( pax->type == 'I' && (pax2= komodo_paxfind(pax->txid,pax->vout,pax->type == 'I' ? 'D' : 'W')) != 0 ) { if ( pax2->fiatoshis != 0 ) { @@ -267,12 +267,17 @@ uint64_t komodo_paxtotal() pax->marked = pax->height; } } + else if ( pax->type == 'W' ) + { + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f\n",str,pax->height,pax->otherheight,dstr(pax->value)); + } } } } komodo_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { + pax->ready = 0; //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); if ( strcmp(symbol,pax->symbol) == 0 ) { @@ -292,10 +297,11 @@ uint64_t komodo_paxtotal() //printf(" v%d %.8f k.%d ht.%d\n",pax->vout,dstr(pax->komodoshis),pax->height,pax->otherheight); if ( seed != 0 ) { - if ( checktoshis >= pax->komodoshis ) + if ( checktoshis == pax->komodoshis ) { total += pax->komodoshis; pax->validated = pax->komodoshis; + pax->ready = 1; } else pax->marked = pax->height; } } @@ -485,7 +491,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d\n",symbol,height,opcode,matched,num); // can easily happen depending on order of loading - if ( height > 100000 ) //&& opcode == 'X' ) + if ( height > 110000 ) //&& opcode == 'X' ) { printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); @@ -683,20 +689,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( strcmp(base,"RUB") == 0 ) printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } - komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); + komodo_gateway_deposit(coinaddr,0,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) - { - if ( didstats != 0 && pax->didstats == 0 ) - { - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("########### %p withdrawn %s += %.8f kmdht.%d ht.%d\n",basesp,base,dstr(value),kmdheight,height); - pax->didstats = 1; - } - pax->type = opretbuf[0]; - pax->validated = komodoshis; - if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) - printf("set validated W.%d %.8f\n",kmdheight,dstr(value)); - } else printf("cant paxfind W\n"); + pax->type = opretbuf[0]; } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -718,9 +713,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 seed = 0; checktoshis = komodo_paxprice(&seed,kmdheights[i],CURRENCIES[baseids[i]],(char *)"KMD",(uint64_t)srcvalues[i]); /*printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&txids[i])[j]); - printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]);*/ + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&txids[i])[j]); + printf(" v%d %.8f k.%d ht.%d base.%d\n",vouts[i],dstr(values[i]),kmdheights[i],otherheights[i],baseids[i]);*/ if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); diff --git a/src/komodo_structs.h b/src/komodo_structs.h index b62a76d3c..f1fc81918 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -57,7 +57,7 @@ struct pax_transaction UT_hash_handle hh; uint256 txid; uint64_t komodoshis,fiatoshis,validated; - int32_t marked,height,otherheight,approved,didstats; + int32_t marked,height,otherheight,approved,didstats,ready; uint16_t vout; char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type,buf[35]; }; From 72e51f5130e87883910f024f118697144869d098 Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 15:58:07 +0200 Subject: [PATCH 16/38] 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 dc1d17007..f56e996e5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,7 +269,7 @@ uint64_t komodo_paxtotal() } else if ( pax->type == 'W' ) { - printf("got WITHDRAW.%s kmd.%d ht.%d %.8f\n",str,pax->height,pax->otherheight,dstr(pax->value)); + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f\n",str,pax->height,pax->otherheight,dstr(pax->fiatoshis)); } } } From a6a335124ec8c6276aa257651b3a986f3dd7d2dd Mon Sep 17 00:00:00 2001 From: jl777 Date: Wed, 7 Dec 2016 15:59:02 +0200 Subject: [PATCH 17/38] 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 f56e996e5..22289a39c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -638,7 +638,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 ) + if ( (pax2= komodo_paxfind(txids[i],vouts[i],'D')) != 0 && pax2->fiatoshis != 0 && pax2->komodoshis != 0 ) { // realtime path? pax->fiatoshis = pax2->fiatoshis; From 6e458bf3a07999cec9f70c56f4312fadd2f36d3a Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 8 Dec 2016 18:42:41 +0200 Subject: [PATCH 18/38] 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 22289a39c..9079ef3b4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -253,7 +253,7 @@ uint64_t komodo_paxtotal() basesp = komodo_stateptrget(str); if ( basesp != 0 && pax->didstats == 0 ) { - if ( pax->type == 'I' && (pax2= komodo_paxfind(pax->txid,pax->vout,pax->type == 'I' ? 'D' : 'W')) != 0 ) + if ( pax->type == 'I' && (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) { if ( pax2->fiatoshis != 0 ) { @@ -269,7 +269,8 @@ uint64_t komodo_paxtotal() } else if ( pax->type == 'W' ) { - printf("got WITHDRAW.%s kmd.%d ht.%d %.8f\n",str,pax->height,pax->otherheight,dstr(pax->fiatoshis)); + if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f\n",str,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis)); } } } @@ -295,7 +296,7 @@ uint64_t komodo_paxtotal() checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); //printf("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 ) + if ( seed != 0 && checktoshis != 0 ) { if ( checktoshis == pax->komodoshis ) { From b8d7170d1c327447f17f7523537e93f2302be018 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 8 Dec 2016 18:47:19 +0200 Subject: [PATCH 19/38] 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 9079ef3b4..f6f9168ce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -599,7 +599,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax2->fiatoshis = pax->fiatoshis; pax2->komodoshis = pax->komodoshis; pax->marked = pax2->marked = pax->height; - pax->otherheight = height; + pax2->otherheight = pax->otherheight = height; if ( pax2->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) From da02b3be0ce57a7a1c34b5efb76150787a5a050f Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 8 Dec 2016 18:50:21 +0200 Subject: [PATCH 20/38] 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 f6f9168ce..ebbceeeee 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -599,7 +599,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax2->fiatoshis = pax->fiatoshis; pax2->komodoshis = pax->komodoshis; pax->marked = pax2->marked = pax->height; - pax2->otherheight = pax->otherheight = height; + pax2->height = pax->height = height; if ( pax2->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) From 329e4359f386eebf9bec80281a2096fedf7880bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 8 Dec 2016 18:57:48 +0200 Subject: [PATCH 21/38] 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 ebbceeeee..a9d7534f3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,7 +269,7 @@ uint64_t komodo_paxtotal() } else if ( pax->type == 'W' ) { - if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) + //if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f\n",str,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis)); } } From daeecf95513e459147380d332297fcdd85be2163 Mon Sep 17 00:00:00 2001 From: jl777 Date: Thu, 8 Dec 2016 19:03:39 +0200 Subject: [PATCH 22/38] test --- src/komodo_gateway.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a9d7534f3..15c68bebd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -692,7 +692,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } komodo_gateway_deposit(coinaddr,0,(char *)"KMD",value,rmd160,txid,vout,'W',kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout,'W')) != 0 ) - pax->type = opretbuf[0]; + { + pax->type = opretbuf[0]; + strcpy(pax->symbol,base); + pax->height = kmdheight; + pax->otherheight = height; + } } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) From a39d7b21d79ab006fe4d5e78430b88037da8d4d9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 12:17:58 +0200 Subject: [PATCH 23/38] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 15c68bebd..1ea779461 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -676,7 +676,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( strcmp(base,"RUB") == 0 ) printf("RUB WITHDRAW %s.height.%d vs height.%d check %.8f/%.8f vs %.8f tokomodo.%d %d seed.%llx -> (%s) len.%d\n",ASSETCHAINS_SYMBOL,kmdheight,height,dstr(checktoshis),dstr(komodoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed,coinaddr,opretlen); didstats = 0; - if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) + //if ( komodo_paxcmp(base,kmdheight,komodoshis,checktoshis,seed) == 0 ) { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { @@ -698,7 +698,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->height = kmdheight; pax->otherheight = height; } - } else printf("withdraw %s paxcmp ht.%d %d error value %.8f -> %.8f vs %.8f\n",base,kmdheight,height,dstr(value),dstr(komodoshis),dstr(checktoshis)); + } // 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' ) { From 1e22f865633e48a105a2fe959eefe61fafc8d116 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 12:20:56 +0200 Subject: [PATCH 24/38] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ea779461..1aac68f76 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -697,6 +697,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 strcpy(pax->symbol,base); pax->height = kmdheight; pax->otherheight = height; + pax->komodoshis = komodoshis; } } // 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 From 250195b07f9e451d9c40654397a54f198fbaaf7e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 12:33:57 +0200 Subject: [PATCH 25/38] tes --- src/komodo_gateway.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1aac68f76..6a7b8f8e6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -270,7 +270,10 @@ uint64_t komodo_paxtotal() else if ( pax->type == 'W' ) { //if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) - printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f\n",str,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis)); + bitcoin_address(coinaddr,addrtype,rmd160,20); + checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); + + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshs)); } } } From aacc96f83e1cd1373aebfaf48a92375d6125702e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 12:35:25 +0200 Subject: [PATCH 26/38] 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 6a7b8f8e6..0b89ad0d8 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -273,7 +273,7 @@ uint64_t komodo_paxtotal() bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshs)); + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); } } } From 431af13e5f0d1050ea49faaa42639c1bc920c05d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 12:37:12 +0200 Subject: [PATCH 27/38] 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 0b89ad0d8..84e31b746 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -270,7 +270,7 @@ uint64_t komodo_paxtotal() else if ( pax->type == 'W' ) { //if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) - bitcoin_address(coinaddr,addrtype,rmd160,20); + //bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); From b8176b070c68095fbea48c19c5e75d851f934d2e Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 13:23:01 +0200 Subject: [PATCH 28/38] test --- src/komodo_gateway.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 84e31b746..33a6c45af 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,8 +272,9 @@ uint64_t komodo_paxtotal() //if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) //bitcoin_address(coinaddr,addrtype,rmd160,20); checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - - printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); + if ( checktoshis != pax->komodoshis ) + pax->marked = pax->height; + else printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); } } } From 1bc5fdf882ea5acd9bfdd8a1ecac198db05158cc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 14:02:03 +0200 Subject: [PATCH 29/38] test --- src/komodo_gateway.h | 30 +++++++++++++++++++++--------- 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 33a6c45af..b6e93778e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -271,10 +271,16 @@ uint64_t komodo_paxtotal() { //if ( strcmp(str,ASSETCHAINS_SYMBOL) == 0 ) //bitcoin_address(coinaddr,addrtype,rmd160,20); - checktoshis = komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis); - if ( checktoshis != pax->komodoshis ) - pax->marked = pax->height; - else printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); + if ( (checktoshis= komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis)) != 0 ) + { + if ( checktoshis != pax->komodoshis ) + pax->marked = pax->height; + else if ( pax->validated == 0 ) + { + pax->validated = pax->komodoshis; + printf("got WITHDRAW.%s kmd.%d ht.%d %.8f -> %.8f/%.8f\n",pax->source,pax->height,pax->otherheight,dstr(pax->fiatoshis),dstr(pax->komodoshis),dstr(checktoshis)); + } + } } } } @@ -289,7 +295,13 @@ uint64_t komodo_paxtotal() if ( pax->marked == 0 ) { if ( komodo_is_issuer() != 0 ) - total += pax->fiatoshis; + { + if ( pax->validated != 0 ) // but what to do with 'W' 'A' and 'X' variants? + { + total += pax->fiatoshis; + pax->ready = 1; + } + } else if ( pax->approved != 0 ) { if ( pax->validated != 0 ) @@ -326,7 +338,7 @@ int32_t komodo_pending_withdraws(char *opretstr) HASH_ITER(hh,PAX,pax,tmp) { //printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); - if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 ) + if ( pax->type == 'W' && pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 && pax->validated != 0 ) { // add 'A' opreturn entry if ( len == 0 ) @@ -460,7 +472,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; itype = opcode; if ( opcode == 'I' && pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) @@ -472,7 +484,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( pax->marked != 0 && height >= 80820 ) { - printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); + printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); errs++; } else matched++; } @@ -481,7 +493,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); printf(" cant paxfind %c txid\n",opcode); - printf("%c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); + printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); } } else From 65d74516bb119e353895c83ae8caf04b402cfe1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 14:59:04 +0200 Subject: [PATCH 30/38] test --- src/komodo_gateway.h | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b6e93778e..268a98a12 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -482,11 +482,19 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } 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 ) + if ( pax->marked != 0 ) { - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); - errs++; - } else matched++; + if ( pax->marked != height && height >= 80820 ) + { + printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); + errs++; + } else matched++; + } + else + { + matched++; + pax->marked = height; + } } else { From 02c36c15f4ea08b0801a261f9c2b9f4f54aa43a7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 15:04:42 +0200 Subject: [PATCH 31/38] test --- src/komodo_gateway.h | 23 +++++++++-------------- 1 file changed, 9 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 268a98a12..d482a64cd 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -305,7 +305,10 @@ uint64_t komodo_paxtotal() else if ( pax->approved != 0 ) { if ( pax->validated != 0 ) + { total += pax->komodoshis; + pax->ready = 1; + } else { seed = 0; @@ -338,7 +341,7 @@ int32_t komodo_pending_withdraws(char *opretstr) HASH_ITER(hh,PAX,pax,tmp) { //printf("pax %s marked.%u approved.%u\n",pax->symbol,pax->marked,pax->approved); - if ( pax->type == 'W' && pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 && pax->validated != 0 ) + if ( pax->marked == 0 && strcmp((char *)"KMD",pax->symbol) == 0 && pax->approved == 0 && pax->validated != 0 ) { // add 'A' opreturn entry if ( len == 0 ) @@ -384,7 +387,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to printf("miner: skip %s %.8f when avail %.8f\n",symbol,dstr(pax->fiatoshis),dstr(available)); continue; } - if ( pax->marked != 0 ) + if ( pax->marked != 0 || (pax->type != 'D' && pax->type != 'A') || pax->ready == 0 ) continue; if ( strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) { @@ -482,19 +485,11 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } 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 ) + if ( pax->marked != 0 && height >= 80820 ) { - if ( pax->marked != height && height >= 80820 ) - { - printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); - errs++; - } else matched++; - } - else - { - matched++; - pax->marked = height; - } + printf(">>>>>>>>>>> %c errs.%d i.%d match %.8f vs %.8f pax.%p\n",opcode,errs,i,dstr(opcode == 'I' ? pax->fiatoshis : pax->komodoshis),dstr(block.vtx[0].vout[i].nValue),pax); + errs++; + } else matched++; } else { From 8ae929129ad70cd87d2fc27dadb4fd40af8d862b Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 15:08:10 +0200 Subject: [PATCH 32/38] 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 d482a64cd..493b3b4da 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -394,7 +394,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to //printf("pax->symbol.%s != %s or null pax->validated %.8f\n",pax->symbol,symbol,dstr(pax->validated)); continue; } - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + //if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); txNew->vout.resize(numvouts+1); txNew->vout[numvouts].nValue = (opcode == 'I') ? pax->fiatoshis : pax->komodoshis; From 0449e3f0a5965c2a1275f5d01837738e9033dee7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 15:11:56 +0200 Subject: [PATCH 33/38] 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 493b3b4da..3902384d2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -296,7 +296,7 @@ uint64_t komodo_paxtotal() { if ( komodo_is_issuer() != 0 ) { - if ( pax->validated != 0 ) // but what to do with 'W' 'A' and 'X' variants? + if ( pax->validated != 0 && pax->type == 'D' ) { total += pax->fiatoshis; pax->ready = 1; From 9b570fb1f25842f4e2bb1260666395d1acb8d8bb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 16:05:21 +0200 Subject: [PATCH 34/38] test --- src/komodo_gateway.h | 2 +- src/komodo_interest.h | 16 ++++++++++++---- 2 files changed, 13 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3902384d2..794ea3727 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -511,7 +511,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { printf("WOULD REJECT %s: ht.%d (%c) matched.%d vs num.%d\n",symbol,height,opcode,matched,num); // can easily happen depending on order of loading - if ( height > 110000 ) //&& opcode == 'X' ) + if ( height > 150000 ) { printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); diff --git a/src/komodo_interest.h b/src/komodo_interest.h index bc9df3e3a..36b5e2f09 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -18,12 +18,20 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest) { static uint64_t *interests; static int32_t maxheight; - uint64_t total; int32_t ind,incr = 100000; + uint64_t total; int32_t ind,incr = 1000000; if ( height >= maxheight ) { - interests = (uint64_t *)realloc(interests,(maxheight + incr) * sizeof(*interests) * 2); - memset(&interests[maxheight << 1],0,incr * sizeof(*interests) * 2); - maxheight += incr; + if ( interests == 0 ) + { + interests = (uint64_t *)calloc(incr,sizeof(*interests) * 2); // fix before block 1 million + maxheight += incr; + } + else + { + interests = (uint64_t *)realloc(interests,(maxheight + incr) * sizeof(*interests) * 2); + memset(&interests[maxheight << 1],0,incr * sizeof(*interests) * 2); + maxheight += incr; + } } ind = (height << 1); if ( paidinterest < 0 ) // request From fa0d10cc5cd79a60117c543a87d6d3b0c8001575 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 16:06:50 +0200 Subject: [PATCH 35/38] test --- src/komodo_interest.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_interest.h b/src/komodo_interest.h index 36b5e2f09..def35d78c 100644 --- a/src/komodo_interest.h +++ b/src/komodo_interest.h @@ -18,13 +18,13 @@ uint64_t komodo_earned_interest(int32_t height,int64_t paidinterest) { static uint64_t *interests; static int32_t maxheight; - uint64_t total; int32_t ind,incr = 1000000; + uint64_t total; int32_t ind,incr = 100000; if ( height >= maxheight ) { if ( interests == 0 ) { - interests = (uint64_t *)calloc(incr,sizeof(*interests) * 2); // fix before block 1 million - maxheight += incr; + maxheight = height + incr; + interests = (uint64_t *)calloc(maxheight,sizeof(*interests) * 2); } else { From 206c579d09bea2d2b46525adc224cd3a3b89327d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 16:43:18 +0200 Subject: [PATCH 36/38] test --- src/pow.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/pow.cpp b/src/pow.cpp index ac2544cb2..ff871d97f 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -113,7 +113,7 @@ extern int32_t KOMODO_CHOSEN_ONE; bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned int nBits, const Consensus::Params& params) { extern int32_t KOMODO_REWIND; - bool fNegative,fOverflow; int32_t i,nonz=0,special,special2,notaryid=-1,flag = 0; + bool fNegative,fOverflow; int32_t i,nonz=0,special=0,special2=0,notaryid=-1,flag = 0; arith_uint256 bnTarget; bnTarget.SetCompact(nBits, &fNegative, &fOverflow); @@ -153,7 +153,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in 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)); - if ( height <= KOMODO_REWIND ) + if ( KOMODO_REWIND == 0 || height <= KOMODO_REWIND ) return error("CheckProofOfWork(): hash doesn't match nBits"); } return true; From a62cf5ce2d196231b692ff5647a0f54b200b8df1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 16:50:04 +0200 Subject: [PATCH 37/38] test --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index ff871d97f..6c91bb5bf 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -153,7 +153,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in 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)); - if ( KOMODO_REWIND == 0 || height <= KOMODO_REWIND ) + if ( (KOMODO_REWIND == 0 && height > 106000) || height <= KOMODO_REWIND ) return error("CheckProofOfWork(): hash doesn't match nBits"); } return true; From a7f87026bb2b666f926747f942229574b7d326eb Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 9 Dec 2016 17:10:12 +0200 Subject: [PATCH 38/38] mining fix, interests alloc fix, paxwithdraw mining --- src/pow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/pow.cpp b/src/pow.cpp index 6c91bb5bf..d597123bc 100644 --- a/src/pow.cpp +++ b/src/pow.cpp @@ -153,7 +153,7 @@ bool CheckProofOfWork(int32_t height,uint8_t *pubkey33,uint256 hash, unsigned in 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)); - if ( (KOMODO_REWIND == 0 && height > 106000) || height <= KOMODO_REWIND ) + if ( (KOMODO_REWIND == 0 && height > 108000) || height <= KOMODO_REWIND ) return error("CheckProofOfWork(): hash doesn't match nBits"); } return true;