From 8c6619bc82a681dc8fb328c268a94e4116f55f1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:05:25 -0300 Subject: [PATCH 001/142] 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 45c9963f4..c523ffec7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -380,7 +380,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - if ( 0 && opcode == 'X' ) + if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); //komodo_paxmark(height,txids[i-1],vouts[i-1],height); //if ( pax->marked == 0 ) From 3cbfd2b4b7be73cd3acdaa1922a8c8b71fc2e68d Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:56:00 -0300 Subject: [PATCH 002/142] test --- src/komodo_gateway.h | 56 ++++++++++++++++++++++++++++++------------- src/komodo_structs.h | 2 +- src/rpcblockchain.cpp | 22 ++++++++++++++++- 3 files changed, 61 insertions(+), 19 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c523ffec7..dc3a067ff 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,6 +15,24 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse +int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) +{ + int32_t baseid; struct komodo_state *sp; + if ( (baseid= komodo_baseid(base)) >= 0 ) + { + if ( (sp= komodo_stateptrget(base)) != 0 ) + { + *deposited = sp->deposited; + *issued = sp->issued; + *withdrawn = sp->withdrawn; + *approved = sp->approved; + *redeemed = sp->redeemed; + return(0); + } + } + return(-1); +} + struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout) { struct pax_transaction *pax; @@ -65,7 +83,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); - printf(" v.%d [%s] kht.%d ht.%d create pax.%p\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax); + printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%d\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); } } pthread_mutex_unlock(&komodo_mutex); @@ -92,8 +110,8 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; - else s = (char *)(ASSETCHAINS_SYMBOL[0]==0?"WITHDRAW":"DEPOSIT"); - printf("[%s] addflag.%d ADD %s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); @@ -282,7 +300,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; - //if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 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; @@ -297,24 +315,14 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to if ( tokomodo == 0 ) { for (i=0; i<32; i++) - { - //printf("%02x",((uint8_t *)&pax->txid)[i]); data[len++] = ((uint8_t *)&pax->txid)[i]; - } data[len++] = pax->vout & 0xff; data[len++] = (pax->vout >> 8) & 0xff; PENDING_KOMODO_TX += pax->fiatoshis; } else { - //[{"prev_hash":"5d5c9a49489b558de9e84f991f996dedaae6b9d0f157f82b2fec64662476d5cf","prev_vout":2,"EUR":0.10000000,"fiat":"EUR","kmdheight":57930,"height":153,"KMD":0.78329000,"address":"RDhEGYScNQYetCyG75Kf8Fg61UWPdwc1C5","rmd160":"306c507eea639e7220b3069ed9f49f3bc97eaca1"}] len += komodo_rwapproval(1,&data[len],pax); - /*len += iguana_rwnum(1,&data[len],sizeof(pax->fiatoshis),&pax->fiatoshis); - len += iguana_rwnum(1,&data[len],sizeof(pax->height),&pax->height); - len += iguana_rwnum(1,&data[len],sizeof(pax->otherheight),&pax->otherheight); - for (i=0; pax->symbol[i]!=0&&i<3; i++) // must be 3 letter currency - data[len++] = pax->symbol[i]; - data[len++] = 0;*/ PENDING_KOMODO_TX += pax->komodoshis; printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } @@ -382,7 +390,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); - //komodo_paxmark(height,txids[i-1],vouts[i-1],height); + //komodo_paxmark(height,txids[i-1],vouts[i-1],height); is called multiple times //if ( pax->marked == 0 ) // printf("unexpected unmarked %p\n",pax); } @@ -425,7 +433,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 i,j,n,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t i,j,n,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -459,6 +467,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( komodo_paxfind(txid,vout) == 0 ) { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->deposited += fiatoshis; komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); } @@ -479,6 +489,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->withdraw += value; 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,kmdheight,height,source,0); @@ -508,7 +520,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - printf(" i.%d (%s) <- %.8f\n",i,coinaddr,dstr(values[i])); + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + basesp->approved += srcvalues[i]; + printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { @@ -529,7 +543,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->issued += srcvalues[i]; komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); + } } } } @@ -544,7 +562,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + basesp->redeemed += srcvalues[i]; komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); + } } } else printf("komodo_issued_opreturn returned %d\n",n); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 2741fafb9..75483b9f3 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -62,7 +62,6 @@ struct pax_transaction char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; -//struct nutxo_entry { UT_hash_handle hh; uint256 txhash; uint64_t voutmask; int32_t notaryid,height; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; struct knotaries_entry { int32_t height,numnotaries; struct knotary_entry *Notaries; }; struct notarized_checkpoint { uint256 notarized_hash,notarized_desttxid; int32_t nHeight,notarized_height; }; @@ -72,6 +71,7 @@ struct komodo_state uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t SAVEDTIMESTAMP; + uint64_t deposited,issued,withdrawn,approved,redeemed; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 418fbc73e..9493f49f5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -481,16 +481,36 @@ Value notaries(const Array& params, bool fHelp) } int32_t komodo_pending_withdraws(char *opretstr); +int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); +extern char CURRENCIES[][32]; Value paxpending(const Array& params, bool fHelp) { - Object ret; char opretbuf[10000*2]; int32_t opretlen; + Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t deposited,issued,withdrawn,approved,redeemed; if ( fHelp || params.size() != 0 ) throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); if ( (opretlen= komodo_pending_withdraws(opretbuf)) > 0 ) ret.push_back(Pair("withdraws", opretbuf)); else ret.push_back(Pair("withdraws", (char *)"")); + for (baseid=0; baseid<32; baseid++) + { + Object item,obj; + if ( pax_fiatstatus(&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) + { + if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) + { + item.push_back(Pair("deposited", deposited)); + item.push_back(Pair("issued", issued)); + item.push_back(Pair("withdrawn", withdrawn)); + item.push_back(Pair("approved", approved)); + item.push_back(Pair("redeemed", redeemed)); + obj.push_back(Pair(CURRENCIES[baseid],item)); + a.push_back(obj); + } + } + } + ret.push_back(Pair("fiatstatus", a)); return ret; } From 5ce8bf22a17fa2d2f58bdb5c8a677102235970a3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 11:58:02 -0300 Subject: [PATCH 003/142] 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 dc3a067ff..da899c8a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -83,7 +83,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { int32_t i; for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); - printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%d\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); + printf(" v.%d [%s] kht.%d ht.%d create pax.%p symbol.%s source.%s\n",vout,ASSETCHAINS_SYMBOL,height,otherheight,pax,symbol,source); } } pthread_mutex_unlock(&komodo_mutex); @@ -490,7 +490,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) - basesp->withdraw += value; + basesp->withdrawn += value; 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,kmdheight,height,source,0); From bafc0147a10fd37ff698198c48ca165300f249de Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:03:22 -0300 Subject: [PATCH 004/142] test --- src/komodo_gateway.h | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index da899c8a0..92a8079aa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -109,8 +109,25 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( addflag != 0 ) { if ( (pax->approved= approved) != 0 ) + { s = (char *)"APPROVED"; - else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + basesp->approved += fiatoshis; + } + else + { + s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( (basesp= komodo_stateptrget(source)) != 0 ) + basesp->withdraw += fiatoshis; + } + else + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + basesp->deposited += fiatoshis; + } + } printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } From 04652b71f49e87205007aa2fe0d6d2c838aad542 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:06:52 -0300 Subject: [PATCH 005/142] 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 92a8079aa..18831b361 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -68,7 +68,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp,*basesp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); From 854aa9b356b529473e9b4a2d2e554576089b3573 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:07:42 -0300 Subject: [PATCH 006/142] 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 18831b361..ede1e03c1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -120,7 +120,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( (basesp= komodo_stateptrget(source)) != 0 ) - basesp->withdraw += fiatoshis; + basesp->withdrawn += fiatoshis; } else { From 0fa85cc34d96e8a6aeb36ccd0e0b735aab94babe Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:14:59 -0300 Subject: [PATCH 007/142] test --- src/komodo_gateway.h | 28 ++++++++++++++++++++++++++-- src/komodo_pax.h | 4 ++-- 2 files changed, 28 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ede1e03c1..d1e7a86fe 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -112,7 +112,10 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { s = (char *)"APPROVED"; if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { basesp->approved += fiatoshis; + printf("########### approved %s += %.8f\n",symbol,dstr(fiatoshis)); + } } else { @@ -120,12 +123,18 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( ASSETCHAINS_SYMBOL[0] == 0 ) { if ( (basesp= komodo_stateptrget(source)) != 0 ) + { basesp->withdrawn += fiatoshis; + printf("########### withdrawn %s += %.8f\n",source,dstr(fiatoshis)); + } } else { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { basesp->deposited += fiatoshis; + printf("########### deposited %s += %.8f\n",symbol,dstr(fiatoshis)); + } } } printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); @@ -254,8 +263,8 @@ uint64_t komodo_paxtotal() { seed = 0; 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); + //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 ( checktoshis >= pax->komodoshis ) @@ -485,7 +494,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxfind(txid,vout) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->deposited += fiatoshis; + printf("########### deposited %s += %.8f\n",base,dstr(fiatoshis)); + } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); } @@ -507,7 +519,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->withdrawn += value; + printf("########### withdrawn %s += %.8f\n",base,dstr(value)); + } 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,kmdheight,height,source,0); @@ -538,7 +553,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { basesp->approved += srcvalues[i]; + printf("########### approved %s += %.8f\n",CURRENCIES[baseids[i]],dstr(srcvalues[i])); + } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) @@ -562,7 +580,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->issued += srcvalues[i]; + printf("########### issued %s += %.8f\n",base,dstr(srcvalues[i])); + } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } } @@ -581,7 +602,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) + { basesp->redeemed += srcvalues[i]; + printf("########### redeemed %s += %.8f\n",base,dstr(srcvalues[i])); + } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e7db138b1..c415c2bbe 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -428,7 +428,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } sum /= densum; sum = (sum * basevolume) / 100000; - printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + //printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); break; } } @@ -473,7 +473,7 @@ 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\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); + //printf("PAX_fiatdest ht.%d price %s %.8f -> KMD %.8f\n",height,base,(double)fiatoshis/COIN,(double)komodoshis/COIN); if ( bitcoin_addr2rmd160(&addrtype,rmd160,coinaddr) == 20 ) { PAX_pubkey(1,pubkey33,&addrtype,rmd160,base,&shortflag,tokomodo != 0 ? &komodoshis : &fiatoshis); From ad16127c53ac9bbb77e7191179cdaaa286a71384 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:28:38 -0300 Subject: [PATCH 008/142] test --- src/komodo_gateway.h | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index d1e7a86fe..71f17d5ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,6 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,*deposited,*issued,*withdrawn,*approved,*redeemed); return(0); } } @@ -114,7 +115,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { basesp->approved += fiatoshis; - printf("########### approved %s += %.8f\n",symbol,dstr(fiatoshis)); + printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } else @@ -125,7 +126,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(source)) != 0 ) { basesp->withdrawn += fiatoshis; - printf("########### withdrawn %s += %.8f\n",source,dstr(fiatoshis)); + printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); } } else @@ -133,7 +134,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { basesp->deposited += fiatoshis; - printf("########### deposited %s += %.8f\n",symbol,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } } @@ -496,7 +497,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - printf("########### deposited %s += %.8f\n",base,dstr(fiatoshis)); + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } else printf("duplicate deposit\n"); @@ -521,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; - printf("########### withdrawn %s += %.8f\n",base,dstr(value)); + 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); } @@ -555,7 +556,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; - printf("########### approved %s += %.8f\n",CURRENCIES[baseids[i]],dstr(srcvalues[i])); + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); @@ -582,7 +583,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->issued += srcvalues[i]; - printf("########### issued %s += %.8f\n",base,dstr(srcvalues[i])); + printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } @@ -604,7 +605,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->redeemed += srcvalues[i]; - printf("########### redeemed %s += %.8f\n",base,dstr(srcvalues[i])); + printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } From f47488db92098e7d576d3557bd73b7c77fbbb0df Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:30:38 -0300 Subject: [PATCH 009/142] 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 71f17d5ac..517d540e4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,*deposited,*issued,*withdrawn,*approved,*redeemed); + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } } From ee5e5744f18c2272e788f504f939240417bd12ee Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:34:59 -0300 Subject: [PATCH 010/142] 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 517d540e4..b045199e9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -29,8 +29,8 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *redeemed = sp->redeemed; printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); - } - } + } else printf("pax_fiatstatus cant get basesp.%s\n",base); + } else printf("pax_fiatstatus illegal base.%s\n",base); return(-1); } From 700606cc2b259c347432257806d16853df7e1e61 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:39:29 -0300 Subject: [PATCH 011/142] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 9493f49f5..b6b8780a5 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -482,7 +482,7 @@ Value notaries(const Array& params, bool fHelp) int32_t komodo_pending_withdraws(char *opretstr); int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); -extern char CURRENCIES[][32]; +extern char CURRENCIES[][8]; Value paxpending(const Array& params, bool fHelp) { From 1db587b509e53c99ce668a4641d7cd5927086ed4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 12:52:00 -0300 Subject: [PATCH 012/142] test --- src/komodo_gateway.h | 61 +++++++++++++++++++++++-------------------- src/komodo_structs.h | 2 +- src/rpcblockchain.cpp | 10 +++---- 3 files changed, 39 insertions(+), 34 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b045199e9..2ed1623bc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); @@ -105,39 +105,44 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; + if ( pax->didstats == 0 && fiatoshis == 0 ) + { + if ( (pax->approved= approved) != 0 ) + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { + basesp->approved += fiatoshis; + printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); + } + } + else + { + if ( ASSETCHAINS_SYMBOL[0] == 0 ) + { + if ( (basesp= komodo_stateptrget(source)) != 0 ) + { + basesp->withdrawn += fiatoshis; + printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); + } + } + else + { + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) + { + basesp->deposited += fiatoshis; + printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); + } + } + } + pax->didstats = 1; + } if ( pax->marked == 0 ) { if ( addflag != 0 ) { if ( (pax->approved= approved) != 0 ) - { s = (char *)"APPROVED"; - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - basesp->approved += fiatoshis; - printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( (basesp= komodo_stateptrget(source)) != 0 ) - { - basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); - } - } - else - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - } + else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 75483b9f3..402d6a859 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; + int32_t marked,height,otherheight,approved,didstats; uint16_t vout; char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; }; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index b6b8780a5..4b1102005 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -500,11 +500,11 @@ Value paxpending(const Array& params, bool fHelp) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { - item.push_back(Pair("deposited", deposited)); - item.push_back(Pair("issued", issued)); - item.push_back(Pair("withdrawn", withdrawn)); - item.push_back(Pair("approved", approved)); - item.push_back(Pair("redeemed", redeemed)); + item.push_back(Pair("deposited", ValueFromAmount(deposited))); + item.push_back(Pair("issued", ValueFromAmount(issued))); + item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); + item.push_back(Pair("approved", ValueFromAmount(approved))); + item.push_back(Pair("redeemed", ValueFromAmount(redeemed))); obj.push_back(Pair(CURRENCIES[baseid],item)); a.push_back(obj); } From 1c6e217d21b77c17ad31905d7e5c1baf253325f6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 13:07:38 -0300 Subject: [PATCH 013/142] 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 2ed1623bc..9c905f9d4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -484,7 +484,7 @@ 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,fiatoshis); typestr = "deposit"; - printf("%s kmdheight.%d vs height.%d check %.8f vs %.8f tokomodo.%d %d seed.%llx\n",ASSETCHAINS_SYMBOL,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\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) From c98b3a088d244d77547ad2951bb58beb27b65ffc Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 13:18:52 -0300 Subject: [PATCH 014/142] test --- src/komodo_gateway.h | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 9c905f9d4..38bf6cf79 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -487,26 +487,24 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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); if ( kmdheight <= height ) { - if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&txid)[i]); + printf(" <- txid.v%u ",vout); + for (i=0; i<33; i++) + printf("%02x",pubkey33[i]); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + if ( value >= checktoshis-(checktoshis >> 10) ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&txid)[i]); - printf(" <- txid.v%u ",vout); - for (i=0; i<33; i++) - printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis-(checktoshis >> 10) ) + if ( komodo_paxfind(txid,vout) == 0 ) { - if ( komodo_paxfind(txid,vout) == 0 ) + if ( (basesp= komodo_stateptrget(base)) != 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) - { - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); - } + basesp->deposited += fiatoshis; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } + if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); - } else printf("duplicate deposit\n"); - } + } else printf("duplicate deposit\n"); } } } From d61cc4794aace9422c5dc59c4f581907f41f0d29 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:08:57 -0300 Subject: [PATCH 015/142] 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 38bf6cf79..5ffb5952f 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -574,7 +574,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { - if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + //if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { @@ -583,7 +583,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 bitcoin_address(coinaddr,60,&rmd160s[i*20],20); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 && baseids[i] >= 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); @@ -605,7 +605,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); From f5e3cdfa8ad771f4e0c78b882f264198c28e8e2a Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:22:08 -0300 Subject: [PATCH 016/142] test --- src/komodo_gateway.h | 44 ++++++++++++++++++++++++++++++++++++-------- 1 file changed, 36 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 5ffb5952f..3eaffddc2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -422,9 +422,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above else matched++; if ( opcode == 'X' ) printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); - //komodo_paxmark(height,txids[i-1],vouts[i-1],height); is called multiple times - //if ( pax->marked == 0 ) - // printf("unexpected unmarked %p\n",pax); } else { @@ -465,7 +462,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 i,j,n,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -493,17 +490,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; i<33; i++) printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); - if ( value >= checktoshis-(checktoshis >> 10) ) + didstats = 0; + if ( value >= checktoshis-(checktoshis >> 8) ) { if ( komodo_paxfind(txid,vout) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; + } } else printf("duplicate deposit\n"); } } @@ -518,6 +521,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"; 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 ( checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) @@ -525,11 +529,14 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; + didstats = 1; 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); } komodo_gateway_deposit(coinaddr,komodoshis,(char *)"KMD",value,rmd160,txid,vout,kmdheight,height,source,0); + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -546,6 +553,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( baseids[i] < 0 ) continue; + didstats = 0; 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); @@ -559,6 +567,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; + didstats = 1; printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); @@ -566,6 +575,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -574,22 +585,31 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo == 0 && opretbuf[0] == 'I' ) { - //if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) + if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,0)) > 0 ) { for (i=0; i= 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } + didstats = 1; + } + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } + if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + pax->didstats = 1; } } } @@ -601,17 +621,25 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i %s\n",i,n,dstr(values[i]),coinaddr); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) { if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; + didstats = 1; printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); } + didstats = 1; + } + if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); } + if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + pax->didstats = 1; } } else printf("komodo_issued_opreturn returned %d\n",n); } From 3f9cad6dac5f08d7b5f5aa26dfd15bbf458734a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:34:00 -0300 Subject: [PATCH 017/142] test --- src/komodo_gateway.h | 43 +++++++++++++++++++++++++++++++------------ src/miner.cpp | 4 ++-- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3eaffddc2..54ab9eed6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -493,7 +493,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( value >= checktoshis-(checktoshis >> 8) ) { - if ( komodo_paxfind(txid,vout) == 0 ) + if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -504,10 +504,19 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) - pax->didstats = 1; } - } else printf("duplicate deposit\n"); + } + else if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->deposited += fiatoshis; + didstats = 1; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } + } + if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + pax->didstats = 1; } } } @@ -524,7 +533,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( checktoshis <= komodoshis+(komodoshis >> 10) ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 ) + if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -571,7 +580,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); - } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + } + else if ( pax->didstats == 0 ) + { + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + { + basesp->approved += srcvalues[i]; + didstats = 1; + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + } + } + else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->approved = kmdheights[i]; @@ -595,7 +614,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -621,23 +640,23 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { for (i=0; i %s\n",i,n,dstr(values[i]),coinaddr); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { - if ( baseids[i] >= 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; didstats = 1; - printf("########### %p redeemed %s += %.8f\n",basesp,base,dstr(srcvalues[i])); + printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) - { komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - } if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; } diff --git a/src/miner.cpp b/src/miner.cpp index 737af64f5..939e60371 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 59 +#define ROUNDROBIN_DELAY 60 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; @@ -647,7 +647,7 @@ void static BitcoinMiner(CWallet *pwallet) int32_t nseconds = Mining_start+ROUNDROBIN_DELAY-time(NULL); if ( nseconds > 0 ) sleep(nseconds); - MilliSleep((rand() % 2000) + 1); + MilliSleep((rand() % 5000) + 1); KOMODO_CHOSEN_ONE = 1; } // Found a solution From e97061cb0ff1ee2c65fac4e36ef2a8ebc7ddcc92 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:43:42 -0300 Subject: [PATCH 018/142] test --- src/komodo_gateway.h | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 54ab9eed6..442eea667 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -460,9 +460,19 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } +int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) +{ + if ( seed == 0 ) + { + value >>= 7; + checkvalue >>= 7; + } + return(value != checkvalue); +} + 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,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; + uint8_t rmd160[20],rmd160s[64*20],addrtype,shortflag,pubkey33[33]; int32_t didstats,i,j,n,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 fiatoshis,komodoshis,checktoshis,values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *basesp; double diff; const char *typestr = "unknown"; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); @@ -491,7 +501,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; - if ( value >= checktoshis-(checktoshis >> 8) ) + if ( komodo_paxcmp(value,checktoshis,seed) == 0 )//value >= checktoshis-(checktoshis >> 8) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { @@ -531,7 +541,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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); didstats = 0; - if ( checktoshis <= komodoshis+(komodoshis >> 10) ) + if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) { From e5e64f55f5ea0030526de9291e3a82ed34163ce8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:48:34 -0300 Subject: [PATCH 019/142] 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 442eea667..15469d6ed 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -462,10 +462,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) { + int32_t ratio; if ( seed == 0 ) { - value >>= 7; - checkvalue >>= 7; + value <<= 10; + ratio = (checkvalue / value); + if ( ratio >= 1023 && ratio <= 1025 ) + return(0); + else return(-1); } return(value != checkvalue); } From 85586b43cf23134f41e15fabb557c587abc5cf68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:50:54 -0300 Subject: [PATCH 020/142] 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 15469d6ed..6f2385990 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -466,7 +466,7 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) if ( seed == 0 ) { value <<= 10; - ratio = (checkvalue / value); + ratio = (value / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); else return(-1); From 02862b723560e1021141d10f9f20776b67c1b796 Mon Sep 17 00:00:00 2001 From: jl777 Date: Fri, 25 Nov 2016 14:57:45 -0300 Subject: [PATCH 021/142] 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 6f2385990..d385996a6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -105,7 +105,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; - if ( pax->didstats == 0 && fiatoshis == 0 ) + if ( pax->didstats == 0 && fiatoshis != 0 ) { if ( (pax->approved= approved) != 0 ) { @@ -465,11 +465,14 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - value <<= 10; - ratio = (value / checkvalue); + ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); - else return(-1); + else + { + printf("value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + return(-1); + } } return(value != checkvalue); } From c1bc18049c47489618990d091f3ffca782a62c67 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:03:42 -0300 Subject: [PATCH 022/142] 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 d385996a6..035d766a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -647,7 +647,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; } - } + } else printf("opreturn none issued?\n"); } } else if ( opretbuf[0] == 'X' ) @@ -701,6 +701,8 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; +if ( strcmp("EUR",base) != 0 && baseid < 32 ) + continue; if ( baseid+1 != refid ) { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); From 20e098469562284af6bb0f3559531fdc55f0e388 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:18:30 -0300 Subject: [PATCH 023/142] 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 035d766a0..d02a117df 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -619,7 +619,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } - else if ( tokomodo == 0 && opretbuf[0] == 'I' ) + else if ( opretbuf[0] == 'I' ) { if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { @@ -642,7 +642,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); + if ( tokomodo == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) pax->didstats = 1; From b971ca89331f1a12a7185c6ddeb97e4ea6acfe1d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:25:56 -0300 Subject: [PATCH 024/142] test --- 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 d02a117df..fff8beb47 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -628,7 +628,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 for (i=0; ididstats == 0 ) @@ -649,7 +652,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 pax->didstats = 1; } } else printf("opreturn none issued?\n"); - } + } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { From 0e1af8ed0051bad3883f6d2acae9249c8ffee93e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 12:33:08 -0300 Subject: [PATCH 025/142] 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 fff8beb47..105dfa2b6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -200,8 +200,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - //for (i=0; i Date: Sat, 26 Nov 2016 12:55:36 -0300 Subject: [PATCH 026/142] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 105dfa2b6..1ff88ad5a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -240,6 +240,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t } vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; + baseids[n] = komodo_baseid(base); } //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } From 54661780d87674258ceb243aaa156b710cc467c7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 13:12:38 -0300 Subject: [PATCH 027/142] test --- src/komodo_gateway.h | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ff88ad5a..da854eccb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -196,7 +196,7 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t *values,int64_t *srcvalues,int32_t *kmdheights,int32_t *otherheights,int8_t *baseids,uint8_t *rmd160s,uint8_t *opretbuf,int32_t opretlen,int32_t iskomodo) { - struct pax_transaction p; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[16]; + struct pax_transaction p,*pax; int32_t i,n=0,j,len=0,incr,height,otherheight; uint8_t type,rmd160[20]; uint64_t fiatoshis; char symbol[16]; incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; @@ -241,6 +241,14 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t vouts[n] = opretbuf[len++]; vouts[n] = (opretbuf[len++] << 8) | vouts[n]; baseids[n] = komodo_baseid(base); + if ( (pax= komodo_paxfind(txids[n],vouts[n])) != 0 ) + { + values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->komodoshis : pax->fiatoshis; + srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; + kmdheights[n] = pax->height; + otherheights[n] = pax->otherheight; + memcpy(&rmd160s[n * 20],pax->rmd160,20); + } } //printf(" komodo_issued_opreturn issuedtxid v%d i.%d opretlen.%d\n",vouts[n],n,opretlen); } @@ -325,8 +333,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to opcode = 'I'; if ( komodo_isrealtime(&ht) == 0 ) return(0); - } - else opcode = 'X'; + } else opcode = 'X'; HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); From ca75995d16e1da8ad57522435d5619f1dc02df52 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:13:02 -0300 Subject: [PATCH 028/142] test --- src/komodo_gateway.h | 74 ++++++++++++++++++++++++++++++++++++-------- src/komodo_structs.h | 2 +- 2 files changed, 62 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index da854eccb..c00558719 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,9 +258,36 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*tmp; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); + else + { + HASH_ITER(hh,PAX,pax,tmp) + { + if ( pax->didstats == 0 && pax->type == 'I' ) + { + HASH_ITER(hh,PAX,pax2,tmp2) + { + if ( pax != pax2 && pax->txid == pax2->txid ) + { + if ( pax2->fiatoshis != 0 ) + { + pax->fiatoshis = pax2->fiatoshis; + pax->komodoshis = pax2->komodoshis; + memcpy(pax->rmd160,pax2->rmd160,20); + if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) + { + basep->issued += pax->fiatoshis; + pax->didstats = 1; + printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); + } else printf("paxtotal cant find.(%s)\n",pax->source); + } + } + } + } + } + } komodo_stateptr(symbol,dest); HASH_ITER(hh,PAX,pax,tmp) { @@ -424,6 +451,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { if ( (pax= komodo_paxfind(txids[i-1],vouts[i-1])) != 0 ) { + pax->type = opcode; 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 ) @@ -532,17 +560,24 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } } - else if ( pax->didstats == 0 ) + else { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + pax->type = opretbuf[0]; + if ( pax->didstats == 0 ) { - basesp->deposited += fiatoshis; - didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( (basesp= komodo_stateptrget(base)) != 0 ) + { + basesp->deposited += fiatoshis; + didstats = 1; + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + } } } if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + { pax->didstats = 1; + pax->type = opretbuf[0]; + } } } } @@ -570,8 +605,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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,kmdheight,height,source,0); - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + { + if ( didstats != 0 ) + pax->didstats = 1; + pax->type = opretbuf[0]; + } } } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) @@ -619,6 +658,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { + pax->type = opretbuf[0]; pax->approved = kmdheights[i]; if ( didstats != 0 ) pax->didstats = 1; @@ -643,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -657,8 +697,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( tokomodo == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } - if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + { + pax->type = opretbuf[0]; + if ( didstats != 0 ) + pax->didstats = 1; + } } } else printf("opreturn none issued?\n"); } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); @@ -687,8 +731,12 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - if ( didstats != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) - pax->didstats = 1; + if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + { + pax->type = opretbuf[0]; + if ( didstats != 0 ) + pax->didstats = 1; + } } } else printf("komodo_issued_opreturn returned %d\n",n); } diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 402d6a859..f3ef90172 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -59,7 +59,7 @@ struct pax_transaction uint64_t komodoshis,fiatoshis,validated; int32_t marked,height,otherheight,approved,didstats; uint16_t vout; - char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],shortflag; + char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; From 0a8db1a89e17d017d214270fe85913e73fb2ea00 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:13:52 -0300 Subject: [PATCH 029/142] 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 c00558719..b39c11c66 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -278,7 +278,7 @@ uint64_t komodo_paxtotal() memcpy(pax->rmd160,pax2->rmd160,20); if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) { - basep->issued += pax->fiatoshis; + basesp->issued += pax->fiatoshis; pax->didstats = 1; printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); } else printf("paxtotal cant find.(%s)\n",pax->source); From 610030d012204de1d56a14aea2602777aa25b3df Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:19:25 -0300 Subject: [PATCH 030/142] 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 b39c11c66..2dbec9001 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -683,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( srcvalues[i] != 0 && (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { From 34f0c3a4d94fac620965ea1867cffd94ecaa962d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:47:37 -0300 Subject: [PATCH 031/142] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2dbec9001..7ca78591e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -267,6 +267,7 @@ uint64_t komodo_paxtotal() { if ( pax->didstats == 0 && pax->type == 'I' ) { + printf("pax.%p didstats.0 type.%c\n",pax,pax->type); HASH_ITER(hh,PAX,pax2,tmp2) { if ( pax != pax2 && pax->txid == pax2->txid ) From ecc5c3598a5c7ae940b7c3912f3484da6cef5f66 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 14:59:14 -0300 Subject: [PATCH 032/142] 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 7ca78591e..f51b2f5e7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,6 +272,7 @@ uint64_t komodo_paxtotal() { if ( pax != pax2 && pax->txid == pax2->txid ) { + printf("matched txid\n"); if ( pax2->fiatoshis != 0 ) { pax->fiatoshis = pax2->fiatoshis; @@ -283,7 +284,7 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); } else printf("paxtotal cant find.(%s)\n",pax->source); - } + } else printf("null fiatoshis\n"); } } } From 36bb53ce26cb9da3f3ab30d31d653bb2c6883fca Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:02:05 -0300 Subject: [PATCH 033/142] 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 f51b2f5e7..0e7b455c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,7 +258,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); else @@ -267,9 +267,14 @@ uint64_t komodo_paxtotal() { if ( pax->didstats == 0 && pax->type == 'I' ) { - printf("pax.%p didstats.0 type.%c\n",pax,pax->type); + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[i]); + printf(" pax.%p didstats.0 type.%c\n",pax,pax->type); HASH_ITER(hh,PAX,pax2,tmp2) { + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax2->txid)[i]); + printf(" pax2.%p\n",pax2); if ( pax != pax2 && pax->txid == pax2->txid ) { printf("matched txid\n"); From e69107f81df7d161dbaad53477b9abaf5600a715 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:13:06 -0300 Subject: [PATCH 034/142] 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 0e7b455c4..a206fb8f4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,8 +269,8 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - printf(" pax.%p didstats.0 type.%c\n",pax,pax->type); - HASH_ITER(hh,PAX,pax2,tmp2) + printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,pax->symbol,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + /*HASH_ITER(hh,PAX,pax2,tmp2) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax2->txid)[i]); @@ -291,7 +291,7 @@ uint64_t komodo_paxtotal() } else printf("paxtotal cant find.(%s)\n",pax->source); } else printf("null fiatoshis\n"); } - } + }*/ } } } @@ -552,7 +552,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); didstats = 0; - if ( komodo_paxcmp(value,checktoshis,seed) == 0 )//value >= checktoshis-(checktoshis >> 8) ) + if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout)) == 0 ) { From 16e7ab0f88f4d4ceeacd858b65010357ee32a523 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:16:47 -0300 Subject: [PATCH 035/142] 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 a206fb8f4..31eb68645 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -265,7 +265,7 @@ uint64_t komodo_paxtotal() { HASH_ITER(hh,PAX,pax,tmp) { - if ( pax->didstats == 0 && pax->type == 'I' ) + //if ( pax->didstats == 0 && pax->type == 'I' ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From a73709a30b8865bc8b77329d3926c2af831cbe5b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:27:00 -0300 Subject: [PATCH 036/142] test --- src/komodo_gateway.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 31eb68645..dd5f8fa6b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -258,7 +258,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t uint64_t komodo_paxtotal() { - struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16]; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; + struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; if ( komodo_isrealtime(&ht) == 0 ) return(0); else @@ -269,7 +269,10 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,pax->symbol,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + if ( pax->type == 'X' || pax->type == 'A' ) + str = pax->symbol; + else str = pax->source; + printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); /*HASH_ITER(hh,PAX,pax2,tmp2) { for (i=0; i<32; i++) @@ -567,7 +570,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } } - else + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { pax->type = opretbuf[0]; if ( pax->didstats == 0 ) From 069953a4fd9d722126845bae808297ea75f2ff73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:30:23 -0300 Subject: [PATCH 037/142] 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 dd5f8fa6b..bfa984d19 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -565,7 +565,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - if ( tokomodo == 0 && strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } From 645ecdd51eb9bc9c01c0fc8354622f5eb2b43c0e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:33:04 -0300 Subject: [PATCH 038/142] 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 bfa984d19..646f082b5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -565,7 +565,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && + //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); } @@ -704,7 +704,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - if ( tokomodo == 0 ) + //if ( tokomodo == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From ceabe3dffb23bcaf537ef88daa1aab3bd6cc08a4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:36:43 -0300 Subject: [PATCH 039/142] 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 646f082b5..35f8368f5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -269,7 +269,7 @@ uint64_t komodo_paxtotal() { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'X' || pax->type == 'A' ) + if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); From 3f2d5618b6038e7018cfd65bfd7decba43c54ff9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:41:38 -0300 Subject: [PATCH 040/142] test --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 35f8368f5..a41bca553 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -705,11 +705,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) + printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; + strcpy(pax->source,(char *)&opretbuf[opretlen-4]); if ( didstats != 0 ) pax->didstats = 1; } From fa81b5ae2aee17b28b132a9503f54459ec374f1a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 15:59:03 -0300 Subject: [PATCH 041/142] test --- src/komodo_gateway.h | 33 ++++++++++++--------------------- 1 file changed, 12 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a41bca553..33ef81089 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,29 +272,20 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; - printf(" pax.%p didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); - /*HASH_ITER(hh,PAX,pax2,tmp2) + if ( pax->didstats == 0 && pax->fiatoshis != 0 ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax2->txid)[i]); - printf(" pax2.%p\n",pax2); - if ( pax != pax2 && pax->txid == pax2->txid ) + if ( pax->type == 'I' ) { - printf("matched txid\n"); - if ( pax2->fiatoshis != 0 ) - { - pax->fiatoshis = pax2->fiatoshis; - pax->komodoshis = pax2->komodoshis; - memcpy(pax->rmd160,pax2->rmd160,20); - if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) - { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("found match for %s %.8f\n",pax->symbol,dstr(pax->fiatoshis)); - } else printf("paxtotal cant find.(%s)\n",pax->source); - } else printf("null fiatoshis\n"); + basesp->issued += pax->fiatoshis; + pax->didstats = 1; } - }*/ + else if ( pax->type == 'X' ) + { + basesp->redeemed += pax->fiatoshis; + pax->didstats = 1; + } + } + printf(" didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } @@ -705,7 +696,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) - printf("I: %s\n",CURRENCIES[baseids[i]]); + //printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From c5f534f4449b4e0a4e4463ddec7b4fe74c901b5e Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:05:55 -0300 Subject: [PATCH 042/142] test --- src/komodo_gateway.h | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 33ef81089..1663496ba 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,20 +272,23 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; - if ( pax->didstats == 0 && pax->fiatoshis != 0 ) + if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) { - if ( pax->type == 'I' ) + if ( (basesp= komodo_stateptrget(str)) != 0 ) { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - } - else if ( pax->type == 'X' ) - { - basesp->redeemed += pax->fiatoshis; - pax->didstats = 1; + if ( pax->type == 'I' ) + { + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + } + else if ( pax->type == 'X' ) + { + basesp->redeemed += pax->fiatoshis; + pax->didstats = 1; + } } } - printf(" didstats.0 type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } From 042e3b9fc445b5577118df8ec8a79caaa4f4f969 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:15:41 -0300 Subject: [PATCH 043/142] test --- src/komodo_gateway.h | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1663496ba..df27805fa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,6 +111,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { + pax->didstats = 1; basesp->approved += fiatoshis; printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -121,6 +122,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(source)) != 0 ) { + pax->didstats = 1; basesp->withdrawn += fiatoshis; printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); } @@ -129,12 +131,12 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { + pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } } - pax->didstats = 1; } if ( pax->marked == 0 ) { @@ -267,8 +269,8 @@ uint64_t komodo_paxtotal() { //if ( pax->didstats == 0 && pax->type == 'I' ) { - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[i]); + //for (i=0; i<32; i++) + // printf("%02x",((uint8_t *)&pax->txid)[i]); if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; @@ -287,8 +289,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; } } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis)); } } } @@ -598,7 +600,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0 ) + if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -642,7 +644,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) + if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; didstats = 1; @@ -650,7 +652,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } - else if ( pax->didstats == 0 ) + else if ( pax->didstats == 0 && srcvalues[i] != 0 ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -725,7 +727,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0 ) + if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { From 4adf625a85e0ac2b37f9b4e49300dc4bd6642796 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:20:53 -0300 Subject: [PATCH 044/142] 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 df27805fa..d24071417 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -289,8 +289,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; } } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } @@ -602,11 +602,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(base)) != 0 ) + if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + printf("########### %p withdrawn %s += %.8f\n",basesp,pax->source,dstr(value)); } printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); } @@ -694,7 +694,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->issued += srcvalues[i]; - printf("########### %p issued %s += %.8f\n",basesp,base,dstr(srcvalues[i])); + printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; } From 33319f82fac851af3706f056c3a52c9d6573ea73 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:26:18 -0300 Subject: [PATCH 045/142] 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 d24071417..32cce25ad 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -120,11 +120,11 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( ASSETCHAINS_SYMBOL[0] == 0 ) { - if ( (basesp= komodo_stateptrget(source)) != 0 ) + if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { pax->didstats = 1; basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,source,dstr(fiatoshis)); + printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } } else @@ -602,11 +602,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { - if ( (basesp= komodo_stateptrget(pax->source)) != 0 ) + if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,pax->source,dstr(value)); + 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); } From 1113e57b498d6eee15a9d5a55af15a4f5d3c8600 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:30:26 -0300 Subject: [PATCH 046/142] 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 32cce25ad..ffe3f3faa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -274,9 +274,10 @@ uint64_t komodo_paxtotal() if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; + basesp = komodo_stateptrget(str); if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) { - if ( (basesp= komodo_stateptrget(str)) != 0 ) + if ( basesp != 0 ) { if ( pax->type == 'I' ) { From 19cba879d39d2171fded109ca2b050ff1262d9f4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:34:00 -0300 Subject: [PATCH 047/142] 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 ffe3f3faa..2bdf2fff9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -690,7 +690,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) + /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -698,7 +698,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; - } + }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) @@ -727,8 +727,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) + printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { @@ -737,7 +737,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } didstats = 1; - } + }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) From 28231c88146430a4703f68fd0972f65544737f10 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:38:53 -0300 Subject: [PATCH 048/142] test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 2bdf2fff9..990917d23 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -283,11 +283,13 @@ uint64_t komodo_paxtotal() { basesp->issued += pax->fiatoshis; pax->didstats = 1; + printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } else if ( pax->type == 'X' ) { basesp->redeemed += pax->fiatoshis; pax->didstats = 1; + printf("Xset dstats %.8f += %.8f\n",dstr(basesp->redeemed),dstr(pax->fiatoshis)); } } } @@ -688,7 +690,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%d of %d illegal baseid.%d\n",i,n,baseids[i]); continue; } - didstats = 0; + //didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) { @@ -709,8 +711,8 @@ 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 ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; } } } else printf("opreturn none issued?\n"); From d506f4ec6c9fe3547728072081c9788fb2321312 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:53:23 -0300 Subject: [PATCH 049/142] test --- src/komodo_gateway.h | 46 ++++++++++---------------------------------- 1 file changed, 10 insertions(+), 36 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 990917d23..ec597bae6 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -111,7 +111,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->approved += fiatoshis; printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -122,7 +122,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->withdrawn += fiatoshis; printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -131,7 +131,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -584,7 +584,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) { - pax->didstats = 1; + //pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -601,9 +601,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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); didstats = 0; - if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) //checktoshis <= komodoshis+(komodoshis >> 10) ) + if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) { - if ( value != 0 & ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) + if ( value != 0 && ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -616,8 +616,8 @@ 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,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -669,8 +669,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -690,29 +690,16 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%d of %d illegal baseid.%d\n",i,n,baseids[i]); continue; } - //didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) - { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) - { - basesp->issued += srcvalues[i]; - printf("########### %p issued %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); - } - didstats = 1; - }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { //if ( tokomodo == 0 ) - //printf("I: %s\n",CURRENCIES[baseids[i]]); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); - //if ( didstats != 0 ) - // pax->didstats = 1; } } } else printf("opreturn none issued?\n"); @@ -727,26 +714,13 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { if ( baseids[i] < 0 ) continue; - didstats = 0; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - /*if ( srcvalues[i] != 0 && ((pax= komodo_paxfind(txids[i],vouts[i])) == 0 || pax->didstats == 0) ) - { - if ( (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) - { - basesp->redeemed += srcvalues[i]; - didstats = 1; - printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); - } - didstats = 1; - }*/ if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; - if ( didstats != 0 ) - pax->didstats = 1; } } } else printf("komodo_issued_opreturn returned %d\n",n); From bad52cb2c441c097aed433891d6077511a88560c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 16:57:23 -0300 Subject: [PATCH 050/142] 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 ec597bae6..4f63e8737 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -131,7 +131,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (basesp= komodo_stateptrget(symbol)) != 0 ) { - //pax->didstats = 1; + pax->didstats = 1; basesp->deposited += fiatoshis; printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); } @@ -582,9 +582,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - if ( didstats != 0 && (pax= komodo_paxfind(txid,vout)) != 0 ) + if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - //pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } From a6ef924b745c296c33a5187e508fa8fbe33a3e59 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:01:54 -0300 Subject: [PATCH 051/142] test --- src/komodo_gateway.h | 43 +++++-------------------------------------- 1 file changed, 5 insertions(+), 38 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 4f63e8737..e5fba5d85 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -69,7 +69,7 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp,*basesp; char str[16],dest[16],*s; + struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); @@ -105,39 +105,6 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->height = height; if ( otherheight != 0 ) pax->otherheight = otherheight; - if ( pax->didstats == 0 && fiatoshis != 0 ) - { - if ( (pax->approved= approved) != 0 ) - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - //pax->didstats = 1; - basesp->approved += fiatoshis; - printf("########### %p approved %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - if ( ASSETCHAINS_SYMBOL[0] == 0 ) - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - //pax->didstats = 1; - basesp->withdrawn += fiatoshis; - printf("########### %p withdrawn %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - else - { - if ( (basesp= komodo_stateptrget(symbol)) != 0 ) - { - pax->didstats = 1; - basesp->deposited += fiatoshis; - printf("########### %p deposited %s += %.8f\n",basesp,symbol,dstr(fiatoshis)); - } - } - } - } if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -617,8 +584,8 @@ 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,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -670,8 +637,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } From c6eca1572064248303a37025d4ab451e1f0a1edf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:11:31 -0300 Subject: [PATCH 052/142] test --- src/komodo_gateway.h | 28 +++++++++++----------------- 1 file changed, 11 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e5fba5d85..a28ebe347 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -252,12 +252,6 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } - else if ( pax->type == 'X' ) - { - basesp->redeemed += pax->fiatoshis; - pax->didstats = 1; - printf("Xset dstats %.8f += %.8f\n",dstr(basesp->redeemed),dstr(pax->fiatoshis)); - } } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); @@ -528,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - didstats = 1; + pax->didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && @@ -544,17 +538,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - didstats = 1; + pax->didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } } - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) - { - if ( didstats != 0 ) - pax->didstats = 1; - pax->type = opretbuf[0]; - } } } } @@ -659,10 +647,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); + printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) { - //if ( tokomodo == 0 ) - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); } if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { @@ -684,11 +672,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); + ; if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; + if ( srcvalues[i] != 0 ) + { + pax->redeemed += srcvalues[i]; + pax->didstats = 1; + } } } } else printf("komodo_issued_opreturn returned %d\n",n); From e649b292fbf885241820975a83a821557a37d141 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:12:59 -0300 Subject: [PATCH 053/142] 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 a28ebe347..f49ab58aa 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -678,9 +678,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) { pax->type = opretbuf[0]; - if ( srcvalues[i] != 0 ) + if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { - pax->redeemed += srcvalues[i]; + basesp->redeemed += srcvalues[i]; pax->didstats = 1; } } From 22a31d52aa1a4da4ebdd2bcbb9bdef0c799c5bce Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:15:36 -0300 Subject: [PATCH 054/142] test --- src/komodo_gateway.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f49ab58aa..43653acbc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - pax->didstats = 1; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && @@ -533,15 +533,17 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { pax->type = opretbuf[0]; - if ( pax->didstats == 0 ) + if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { basesp->deposited += fiatoshis; - pax->didstats = 1; + didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } + if ( didstats != 0 ) + pax->didstats = 1; } } } From 14941d4ca6a37ea770059596722887ea7b74f4e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:21:21 -0300 Subject: [PATCH 055/142] 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 43653acbc..e7f7c51cf 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -542,8 +542,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; } } } @@ -574,8 +574,8 @@ 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,kmdheight,height,source,0); if ( (pax= komodo_paxfind(txid,vout)) != 0 ) { - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -627,8 +627,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - if ( didstats != 0 ) - pax->didstats = 1; + //if ( didstats != 0 ) + // pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -683,7 +683,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; - pax->didstats = 1; + //pax->didstats = 1; } } } From 51e5d952cdf1333fed3b1daccc1634b8427f1237 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:32:20 -0300 Subject: [PATCH 056/142] test --- src/komodo_gateway.h | 69 ++++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 28 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e7f7c51cf..f30e90ab5 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -34,26 +34,37 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, return(-1); } -struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout) +void pax_keyset(uint8_t *buf,uint256 txid,uint16_t vout,uint8_t type) { - struct pax_transaction *pax; + memcpy(buf,&txid,32); + memcpy(&buf[32],&vout,2); + buf[34] = type; +} + +struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) +{ + struct pax_transaction *pax; uint8_t buf[35]; pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); pthread_mutex_unlock(&komodo_mutex); return(pax); } -struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,int32_t mark) +struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout,uint8_t type,int32_t mark) { - struct pax_transaction *pax; + struct pax_transaction *pax; uint8_t buf[35]; pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) { pax = (struct pax_transaction *)calloc(1,sizeof(*pax)); pax->txid = txid; pax->vout = vout; - HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + pax->type = type; + memcpy(pax->buf,buf,sizeof(pax->buf)); + HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); //printf("ht.%d create pax.%p mark.%d\n",height,pax,mark); } if ( pax != 0 ) @@ -67,18 +78,21 @@ struct pax_transaction *komodo_paxmark(int32_t height,uint256 txid,uint16_t vout return(pax); } -void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context +void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t fiatoshis,uint8_t *rmd160,uint256 txid,uint16_t vout,uint8_t type,int32_t height,int32_t otherheight,char *source,int32_t approved) // assetchain context { - struct pax_transaction *pax; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; + struct pax_transaction *pax; uint8_t buf[35]; int32_t addflag = 0; struct komodo_state *sp; char str[16],dest[16],*s; sp = komodo_stateptr(str,dest); pthread_mutex_lock(&komodo_mutex); - HASH_FIND(hh,PAX,&txid,sizeof(txid),pax); + pax_keyset(buf,txid,vout,type); + HASH_FIND(hh,PAX,buf,sizeof(buf),pax); if ( pax == 0 ) { pax = (struct pax_transaction *)calloc(1,sizeof(*pax)); pax->txid = txid; pax->vout = vout; - HASH_ADD_KEYPTR(hh,PAX,&pax->txid,sizeof(pax->txid),pax); + pax->type = type; + memcpy(pax->buf,buf,sizeof(pax->buf)); + HASH_ADD_KEYPTR(hh,PAX,pax->buf,sizeof(pax->buf),pax); addflag = 1; if ( ASSETCHAINS_SYMBOL[0] == 0 ) { @@ -527,12 +541,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,kmdheight,height,(char *)"KMD",0); + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } } - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { - pax->type = opretbuf[0]; if ( didstats == 0 && pax->didstats == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) @@ -542,8 +555,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; } } } @@ -561,7 +574,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) { - if ( value != 0 && ((pax= komodo_paxfind(txid,vout)) == 0 || pax->didstats == 0) ) + if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { @@ -571,8 +584,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } 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,kmdheight,height,source,0); - if ( (pax= komodo_paxfind(txid,vout)) != 0 ) + 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 = 1; @@ -601,10 +614,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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])) == 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) == 0 ) { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); + komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; @@ -623,7 +636,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 ) { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; @@ -650,11 +663,11 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,CURRENCIES[baseids[i]],0); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); + if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) { } - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 ) { pax->type = opretbuf[0]; strcpy(pax->source,(char *)&opretbuf[opretlen-4]); @@ -674,10 +687,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); - komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],height,0,(char *)"KMD",0); - if ( komodo_paxmark(height,txids[i],vouts[i],height) == 0 ) + komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); + if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; - if ( (pax= komodo_paxfind(txids[i],vouts[i])) != 0 ) + if ( (pax= komodo_paxfind(txids[i],vouts[i],'X')) != 0 ) { pax->type = opretbuf[0]; if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) From c5c0e52706ffa466a4027e6728ef0ec098383b14 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:38:08 -0300 Subject: [PATCH 057/142] test --- src/komodo_gateway.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f30e90ab5..d8be42f38 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -51,6 +51,15 @@ 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) +{ + uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + for (i=0; ikomodoshis : pax->fiatoshis; srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; From b915be35e6147c5ea4397a29c2612277608d92e3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:42:47 -0300 Subject: [PATCH 058/142] 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 d8be42f38..ea51fcd56 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -442,7 +442,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { for (i=1; itype = opcode; if ( ((opcode == 'I' && pax->fiatoshis == block.vtx[0].vout[i].nValue) || (opcode == 'X' && pax->komodoshis == block.vtx[0].vout[i].nValue)) ) @@ -540,7 +540,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 0; if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { - if ( (pax= komodo_paxfind(txid,vout)) == 0 ) + if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { if ( (basesp= komodo_stateptrget(base)) != 0 ) { From afa0d2b9ca5986f5fb3379d62aea5264b1eb8f8c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:44:01 -0300 Subject: [PATCH 059/142] test --- src/komodo_structs.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_structs.h b/src/komodo_structs.h index f3ef90172..bbca9c25f 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -59,7 +59,7 @@ struct pax_transaction uint64_t komodoshis,fiatoshis,validated; int32_t marked,height,otherheight,approved,didstats; uint16_t vout; - char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type; + char symbol[16],source[16],coinaddr[64]; uint8_t rmd160[20],type,buf[35]; }; struct knotary_entry { UT_hash_handle hh; uint8_t pubkey[33],notaryid; }; From 095dce5832967937d83fc5f28dfe6e286c335732 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 17:44:56 -0300 Subject: [PATCH 060/142] 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 ea51fcd56..510d99188 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -54,7 +54,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; - for (i=0; i Date: Sat, 26 Nov 2016 17:45:37 -0300 Subject: [PATCH 061/142] 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 510d99188..f0878477e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -53,7 +53,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { - uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + struct pax_transaction *pax; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; for (i=0; i Date: Sat, 26 Nov 2016 17:46:21 -0300 Subject: [PATCH 062/142] 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 f0878477e..3881de127 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -53,7 +53,7 @@ struct pax_transaction *komodo_paxfind(uint256 txid,uint16_t vout,uint8_t type) struct pax_transaction *komodo_paxfinds(uint256 txid,uint16_t vout) { - struct pax_transaction *pax; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; + struct pax_transaction *pax; int32_t i; uint8_t types[] = { 'D', 'I', 'W', 'A', 'X' }; for (i=0; i Date: Sat, 26 Nov 2016 17:51:41 -0300 Subject: [PATCH 063/142] 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 3881de127..604a98c91 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -596,8 +596,8 @@ 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 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; pax->type = opretbuf[0]; } } @@ -649,8 +649,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; - //if ( didstats != 0 ) - // pax->didstats = 1; + if ( didstats != 0 ) + pax->didstats = 1; printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } @@ -705,7 +705,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] >= 0 && srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->redeemed += srcvalues[i]; - //pax->didstats = 1; + pax->didstats = 1; } } } From 929b383db3bff241865043ee00af7edd2b136449 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:09:58 -0300 Subject: [PATCH 064/142] test --- src/komodo_gateway.h | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 604a98c91..9d90b6160 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -265,16 +265,15 @@ uint64_t komodo_paxtotal() str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); - if ( komodo_baseid(str) >= 0 && pax->didstats == 0 && pax->fiatoshis != 0 ) + if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - if ( basesp != 0 ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) { - if ( pax->type == 'I' ) - { - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); - } + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); From b69651118afaff9337beaeeb2255b4d5886e6216 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:16:26 -0300 Subject: [PATCH 065/142] 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 9d90b6160..5c1745b7a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'X' || pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); @@ -273,7 +273,7 @@ uint64_t komodo_paxtotal() pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; - printf("Iset dstats %.8f += %.8f\n",dstr(basesp->issued),dstr(pax->fiatoshis)); + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); From f7183b2bee796849c09ee30682ec19446ece638d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:19:41 -0300 Subject: [PATCH 066/142] 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 5c1745b7a..c96750fce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); From 7572a37183da042eb66eba07714ac22940517bd0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:27:34 -0300 Subject: [PATCH 067/142] 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 c96750fce..196b5cc51 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -261,7 +261,7 @@ uint64_t komodo_paxtotal() { //for (i=0; i<32; i++) // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) str = pax->symbol; else str = pax->source; basesp = komodo_stateptrget(str); @@ -275,8 +275,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } @@ -694,7 +694,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( baseids[i] < 0 ) continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("X i.%d of %d: %.8f -> %s\n",i,n,dstr(values[i]),coinaddr); + printf("%s X i.%d of %d: %.8f -> %s\n",CURRENCIES[baseids[i]],i,n,dstr(values[i]),coinaddr); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; From ab689bb647b880fbee6759305ddd301561379fbd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:35:07 -0300 Subject: [PATCH 068/142] 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 196b5cc51..b60f9a9b2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -275,7 +275,8 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); + if ( strcmp(str,"HRK") == 0 ) + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } } From 161abb4b10547be320444572c6212a7fd947b73c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:43:39 -0300 Subject: [PATCH 069/142] 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 b60f9a9b2..97c381f78 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -134,7 +134,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; - else s = (char *)((ASSETCHAINS_SYMBOL[0] == 0) ? "WITHDRAW" : "DEPOSIT"); + else s = (char *)((strcmp(pax->symbol,"KMD") == 0) ? "WITHDRAW" : "DEPOSIT"); printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } @@ -275,10 +275,10 @@ uint64_t komodo_paxtotal() pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } - if ( strcmp(str,"HRK") == 0 ) - printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } + if ( strcmp(str,"HRK") == 0 ) + printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); } } komodo_stateptr(symbol,dest); From 8577908727ff8c82f133026222cc597672c6cf9a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:49:44 -0300 Subject: [PATCH 070/142] test --- src/komodo_gateway.h | 33 ++++++++++++++++----------------- 1 file changed, 16 insertions(+), 17 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 97c381f78..5fb14682d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -257,28 +257,27 @@ uint64_t komodo_paxtotal() { HASH_ITER(hh,PAX,pax,tmp) { - //if ( pax->didstats == 0 && pax->type == 'I' ) + if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) + str = pax->symbol; + else str = pax->source; + basesp = komodo_stateptrget(str); + if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - //for (i=0; i<32; i++) - // printf("%02x",((uint8_t *)&pax->txid)[i]); - if ( pax->type == 'A' || pax->type == 'D' || pax->type == 'X' ) - str = pax->symbol; - else str = pax->source; - basesp = komodo_stateptrget(str); - if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) - { - pax->komodoshis = pax2->komodoshis; - pax->fiatoshis = pax2->fiatoshis; - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); - } + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } - if ( strcmp(str,"HRK") == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + { + for (i=0; i<32; i++) + printf("%02x",((uint8_t *)&pax->txid)[i]); printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); + } } } komodo_stateptr(symbol,dest); From b9dec008d7875f9d510aad5d08baafb2d9d5132d Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 18:58:40 -0300 Subject: [PATCH 071/142] 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 5fb14682d..8d97c6068 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,7 +272,7 @@ uint64_t komodo_paxtotal() printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( pax->type == 'D' || strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From 3cfd48376de175e6cb4337f90871ef3647d2cbef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:06:41 -0300 Subject: [PATCH 072/142] test --- src/komodo_gateway.h | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 8d97c6068..1609ada83 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -263,16 +263,20 @@ uint64_t komodo_paxtotal() basesp = komodo_stateptrget(str); if ( basesp != 0 && pax->didstats == 0 && pax->type == 'I' ) { - if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 && pax2->fiatoshis != 0 ) + if ( (pax2= komodo_paxfind(pax->txid,pax->vout,'D')) != 0 ) { - pax->komodoshis = pax2->komodoshis; - pax->fiatoshis = pax2->fiatoshis; - basesp->issued += pax->fiatoshis; - pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + printf("%.8f pax2.%p vs pax.%p\n",dstr(pax2->fiatoshis),pax2,pax); + if ( pax2->fiatoshis != 0 ) + { + pax->komodoshis = pax2->komodoshis; + pax->fiatoshis = pax2->fiatoshis; + basesp->issued += pax->fiatoshis; + pax->didstats = 1; + printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + } } } - if ( pax->type == 'D' || strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); From ea0bce0fd6d6d28d7f86536fb9bafd5205372c23 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:09:56 -0300 Subject: [PATCH 073/142] 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 1609ada83..ab9d6e31b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,7 +736,7 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; -if ( strcmp("EUR",base) != 0 && baseid < 32 ) +if ( strcmp("HRK",base) != 0 && baseid < 32 ) continue; if ( baseid+1 != refid ) { From ff80d273017cab2db9dbe937a212004c5b8c1010 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:13:08 -0300 Subject: [PATCH 074/142] test --- src/komodo_gateway.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ab9d6e31b..3b418b1c4 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -736,8 +736,6 @@ void komodo_passport_iteration() sp = 0; isrealtime = 0; base = (char *)CURRENCIES[baseid]; -if ( strcmp("HRK",base) != 0 && baseid < 32 ) - continue; if ( baseid+1 != refid ) { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); From 9a6744f2440744159fcc5ec2292554dacae51076 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:35:06 -0300 Subject: [PATCH 075/142] test --- src/komodo_gateway.h | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 3b418b1c4..37c76be40 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -685,8 +685,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 strcpy(pax->source,(char *)&opretbuf[opretlen-4]); } } - } else printf("opreturn none issued?\n"); - } else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); + } //else printf("opreturn none issued?\n"); + } //else printf("opreturn matches KMD? %s\n",(char *)&opretbuf[opretlen-4]); } else if ( opretbuf[0] == 'X' ) { @@ -740,18 +740,19 @@ void komodo_passport_iteration() { komodo_statefname(fname,baseid<32?base:(char *)"",(char *)"komodostate"); komodo_nameset(symbol,dest,base); - //port = komodo_port(base,10,&magic) + 1; if ( (fp= fopen(fname,"rb")) != 0 && (sp= komodo_stateptrget(symbol)) != 0 ) { fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - //printf("passport refid.%d %s fname.(%s) base.%s\n",refid,symbol,fname,base); + if ( 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 ) ; lastpos[baseid] = ftell(fp); - //printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); + if ( strcmp(symbol,"KMD") == 0 ) + printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); } From c3152c23d952f5b62f6a535f14d7f746e6b2a559 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:42:22 -0300 Subject: [PATCH 076/142] 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 37c76be40..328069bf2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -196,7 +196,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t printf("%02x",opretbuf[i]); printf(" opretlen.%d (%s)\n",opretlen,base); //printf(" opretlen.%d vs %d incr.%d\n",opretlen,(int32_t)(2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4),incr); - if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) + //if ( ASSETCHAINS_SYMBOL[0] == 0 || strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) { type = opretbuf[0]; opretbuf++, opretlen--; @@ -210,8 +210,8 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t { txids[n] = p.txid; vouts[n] = p.vout; - values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.komodoshis : p.fiatoshis; - srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? p.fiatoshis : p.komodoshis; + values[n] = (strcmp("KMD",base) == 0) ? p.komodoshis : p.fiatoshis; + srcvalues[n] = (strcmp("KMD",base) == 0) ? p.fiatoshis : p.komodoshis; kmdheights[n] = p.height; otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); @@ -235,8 +235,8 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t baseids[n] = komodo_baseid(base); if ( (pax= komodo_paxfinds(txids[n],vouts[n])) != 0 ) { - values[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->komodoshis : pax->fiatoshis; - srcvalues[n] = (ASSETCHAINS_SYMBOL[0] == 0) ? pax->fiatoshis : pax->komodoshis; + values[n] = (strcmp("KMD",base) == 0) ? pax->komodoshis : pax->fiatoshis; + srcvalues[n] = (strcmp("KMD",base) == 0) ? pax->fiatoshis : pax->komodoshis; kmdheights[n] = pax->height; otherheights[n] = pax->otherheight; memcpy(&rmd160s[n * 20],pax->rmd160,20); From 4d4194d3acad88c48c0b8586489134c689389b13 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 19:57:52 -0300 Subject: [PATCH 077/142] test --- src/komodo_gateway.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 328069bf2..6b061146c 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -135,7 +135,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; else s = (char *)((strcmp(pax->symbol,"KMD") == 0) ? "WITHDRAW" : "DEPOSIT"); - printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(ASSETCHAINS_SYMBOL[0]==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); + printf("[%s] addflag.%d ADD %s/%s %s %.8f -> %s TO PAX ht.%d otherht.%d total %.8f\n",ASSETCHAINS_SYMBOL,addflag,s,symbol,source,dstr(strcmp(pax->symbol,"KMD")==0?pax->komodoshis:pax->fiatoshis),pax->coinaddr,pax->height,pax->otherheight,dstr(komodo_paxtotal())); } } //else printf("%p MARKED.%d DEPOSIT %s %.8f -> %s TO PAX ht.%d otherht.%d\n",pax,pax->marked,symbol,dstr(fiatoshis),coinaddr,height,otherheight); @@ -520,7 +520,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 memset(rmd160s,0,sizeof(rmd160s)); memset(kmdheights,0,sizeof(kmdheights)); memset(otherheights,0,sizeof(otherheights)); - tokomodo = (komodo_is_issuer() == 0); + tokomodo = (komodo_baseid(source) >= 0 && komodo_baseid(source) != 32); //(komodo_is_issuer() == 0); if ( opretbuf[0] == 'D' ) { if ( opretlen == 38 ) // any KMD tx @@ -551,10 +551,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 didstats = 1; printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } - //if ( strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0 ) //tokomodo == 0 && - { - komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); - } + komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } if ( (pax= komodo_paxfind(txid,vout,'D')) != 0 ) { From 5b1fa6614534cb1b688ee5da981303ef70118d82 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:05:25 -0300 Subject: [PATCH 078/142] test --- src/komodo_gateway.h | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6b061146c..b9d2c7191 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -276,7 +276,7 @@ uint64_t komodo_paxtotal() } } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + //if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); @@ -671,7 +671,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); - printf("ISSUE %s %.8f %.8f\n",CURRENCIES[baseids[i]],dstr(values[i]),dstr(srcvalues[i])); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) { @@ -687,7 +686,6 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( opretbuf[0] == 'X' ) { - printf("got X opreturn height.%d\n",height); if ( (n= komodo_issued_opreturn(base,txids,vouts,values,srcvalues,kmdheights,otherheights,baseids,rmd160s,opretbuf,opretlen,1)) > 0 ) { for (i=0; i %s\n",CURRENCIES[baseids[i]],i,n,dstr(values[i]),coinaddr); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) ; @@ -742,13 +739,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( strcmp(symbol,"KMD") == 0 ) + if ( 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 ) ; lastpos[baseid] = ftell(fp); - if ( strcmp(symbol,"KMD") == 0 ) + if ( 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); From 4508aa2f00209fe39e5d76e64d4cdb1d9672277f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:08:24 -0300 Subject: [PATCH 079/142] 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 b9d2c7191..87f4af839 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -27,7 +27,7 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - //printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); From 959782f9b1c81a7016d4057057f733cc1285dea0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:15:04 -0300 Subject: [PATCH 080/142] 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 87f4af839..560101ddc 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -725,7 +725,7 @@ void komodo_passport_iteration() refid = 33; else refid = komodo_baseid(ASSETCHAINS_SYMBOL)+1; // illegal base -> baseid.-1 -> 0 //printf("PASSPORT %s refid.%d\n",ASSETCHAINS_SYMBOL,refid); - for (baseid=0; baseid<=32; baseid++) + for (baseid=32; baseid>=0; baseid--) { sp = 0; isrealtime = 0; From 79ba59762dd4faa61f2868dfc4c7e7e20dc7645a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:18:25 -0300 Subject: [PATCH 081/142] 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 560101ddc..1cdf7c2bb 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -276,7 +276,7 @@ uint64_t komodo_paxtotal() } } } - //if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); @@ -739,13 +739,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( 0 && strcmp(symbol,"KMD") == 0 ) + if ( 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 ) ; lastpos[baseid] = ftell(fp); - if ( 0 && strcmp(symbol,"KMD") == 0 ) + if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); From 1d19bf5dded6024db3b84b839248ea324d3c836c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:26:28 -0300 Subject: [PATCH 082/142] 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 1cdf7c2bb..44c15101b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -498,8 +498,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - ratio = ((value << 10) / checkvalue); - if ( ratio >= 1023 && ratio <= 1025 ) + ratio = ((value << 8) / checkvalue); + if ( ratio >= 255 && ratio <= 257 ) return(0); else { From bc2b6b691a563c10a893df4073409b28750b77d2 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:35:56 -0300 Subject: [PATCH 083/142] 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 44c15101b..1ee234451 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -498,8 +498,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) int32_t ratio; if ( seed == 0 ) { - ratio = ((value << 8) / checkvalue); - if ( ratio >= 255 && ratio <= 257 ) + ratio = ((value << 6) / checkvalue); + if ( ratio >= 63 && ratio <= 65 ) return(0); else { From 3fe781e1318fc346358362d9650c100ef2161537 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:48:46 -0300 Subject: [PATCH 084/142] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 939e60371..84d188432 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } From dcdcccaad51a90892ccc2827a3f893acb4e5c09b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:50:15 -0300 Subject: [PATCH 085/142] test --- src/miner.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/miner.cpp b/src/miner.cpp index 84d188432..e01161ed0 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } From b3183e3e195628c641ecfd27b3b6d2d1806166ef Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 20:59:21 -0300 Subject: [PATCH 086/142] test --- src/komodo_gateway.h | 14 +++++++------- src/miner.cpp | 4 ++-- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 1ee234451..ffbe81bf7 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -192,9 +192,9 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t incr = 34 + (iskomodo * (2*sizeof(fiatoshis) + 2*sizeof(height) + 20 + 4)); for (i=0; i<4; i++) base[i] = opretbuf[opretlen-4+i]; - for (i=0; itxid,pax->vout,'D')) != 0 ) { - printf("%.8f pax2.%p vs pax.%p\n",dstr(pax2->fiatoshis),pax2,pax); if ( pax2->fiatoshis != 0 ) { pax->komodoshis = pax2->komodoshis; @@ -276,12 +275,12 @@ uint64_t komodo_paxtotal() } } } - if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) + /*if ( strcmp(str,"HRK") == 0 || strcmp("HRK",pax->symbol) == 0 || strcmp("HRK",pax->source) == 0 ) { for (i=0; i<32; i++) printf("%02x",((uint8_t *)&pax->txid)[i]); printf(" stats.%d type.%c (%s) k.%d %.8f h.%d %.8f I.%.8f X.%.8f\n",pax->didstats,pax->type,str,pax->height,dstr(pax->komodoshis),pax->otherheight,dstr(pax->fiatoshis),dstr(basesp->issued),dstr(basesp->redeemed)); - } + }*/ } } komodo_stateptr(symbol,dest); @@ -480,8 +479,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above } if ( matched != num ) { + printf("WOULD REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); // can easily happen depending on order of loading - if ( height > 100000 && opcode == 'X' ) + if ( height > 100000 ) //&& opcode == 'X' ) { printf("REJECT: ht.%d (%c) matched.%d vs num.%d\n",height,opcode,matched,num); return(-1); diff --git a/src/miner.cpp b/src/miner.cpp index e01161ed0..2879561c4 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -637,7 +637,7 @@ void static BitcoinMiner(CWallet *pwallet) solutionTargetChecks.increment(); if ( UintToArith256(pblock->GetHash()) > hashTarget ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) fprintf(stderr,"missed target\n"); return false; } @@ -648,8 +648,8 @@ void static BitcoinMiner(CWallet *pwallet) if ( nseconds > 0 ) sleep(nseconds); MilliSleep((rand() % 5000) + 1); - KOMODO_CHOSEN_ONE = 1; } + KOMODO_CHOSEN_ONE = 1; // Found a solution SetThreadPriority(THREAD_PRIORITY_NORMAL); LogPrintf("KomodoMiner:\n"); From eeac75281d49b3fb663f0526d32e846e08116b68 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:05:42 -0300 Subject: [PATCH 087/142] 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 ffbe81bf7..fc7d8d38d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -363,7 +363,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to continue; if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) continue; - if ( 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; @@ -789,6 +789,7 @@ void komodo_passport_iteration() if ( sp != 0 && isrealtime == 0 ) refsp->RTbufs[0][2] = 0; } + komodo_paxtotal(); refsp->RTmask = RTmask; KOMODO_PASSPORT_INITDONE = 1; } From d683083dd38c60d5198ac6add972105e6dccd884 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:09:55 -0300 Subject: [PATCH 088/142] 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 fc7d8d38d..065e04ff1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -452,29 +452,29 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - if ( opcode == 'X' ) - printf("errs.%d i.%d match %.8f == %.8f pax.%p\n",errs,i,dstr(pax != 0 ? pax->komodoshis:-1),dstr(block.vtx[0].vout[i].nValue),pax); + //if ( opcode == 'X' ) + 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 { - if ( opcode == 'X' ) + //if ( opcode == 'X' ) { for (j=0; j<32; j++) printf("%02x",((uint8_t *)&txids[i-1])[j]); - printf(" cant paxfind X txid\n"); + printf(" cant paxfind %c txid\n".opcode); } } } else { - if ( opcode == 'X' ) + //if ( opcode == 'X' ) { hash = block.GetHash(); for (j=0; j<32; j++) printf("%02x",((uint8_t *)&hash)[j]); printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); - } else if ( opcode == 'I' ) - matched++; + } //else if ( opcode == 'I' ) + // matched++; } } if ( matched != num ) From f37822dc9fad13d66427f0c8450951de6661312f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:10:44 -0300 Subject: [PATCH 089/142] 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 065e04ff1..23a23b110 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -461,7 +461,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(" cant paxfind %c txid\n",opcode); } } } From 916a36c93e3fdfed1df3930fa7781d29fac0eb74 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:12:39 -0300 Subject: [PATCH 090/142] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 23a23b110..eadc2780b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -462,6 +462,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); } } } From 784c01124964058bd61cbe3feb2d1f3af14a56e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:15:26 -0300 Subject: [PATCH 091/142] 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 eadc2780b..682067e71 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -447,7 +447,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) { pax->type = opcode; - 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 ) errs++; From c3111e7be4103ff8cad0aa2f3edcd183fd0d6eda Mon Sep 17 00:00:00 2001 From: jl777 Date: Sat, 26 Nov 2016 21:18:54 -0300 Subject: [PATCH 092/142] test --- src/komodo_gateway.h | 1 + 1 file changed, 1 insertion(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 682067e71..254d88815 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -272,6 +272,7 @@ uint64_t komodo_paxtotal() basesp->issued += pax->fiatoshis; pax->didstats = 1; printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + pax2->marked = pax->height; } } } From f4fd24268931215bd55416b44a8f626b62eaff1b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 06:43:50 -0300 Subject: [PATCH 093/142] dns seeds --- src/chainparams.cpp | 1 + src/komodo.h | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 991cc1333..34b042749 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -95,6 +95,7 @@ public: assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); vFixedSeeds.clear(); vSeeds.clear(); + vSeeds.push_back(CDNSSeedData("komodo.mewhub.com", "seeds.komodo.mewhub.com")); // @kolo // TODO: set up bootstrapping for mainnet base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,60); base58Prefixes[SCRIPT_ADDRESS] = std::vector(1,85); diff --git a/src/komodo.h b/src/komodo.h index 970ef50b9..b0b64b16d 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,7 +17,7 @@ #define H_KOMODO_H // Todo: -// 1. net balance limiter +// 1. net balance limiter, wait for notarized // 2. verify: reorgs // non komodod (non-hardfork) todo: From aa114a60954bd5d7b4ee6221d27b891867804256 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:34:23 -0300 Subject: [PATCH 094/142] test --- src/komodo.h | 9 +++++---- src/komodo_gateway.h | 35 +++++++++++++++++++++++++---------- src/komodo_pax.h | 3 ++- src/komodo_structs.h | 4 ++-- src/komodo_utils.h | 11 +++++++++++ src/miner.cpp | 2 +- src/rpcblockchain.cpp | 5 +++-- src/wallet/rpcwallet.cpp | 3 +++ 8 files changed, 52 insertions(+), 20 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index b0b64b16d..d9c45fa9c 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -17,13 +17,14 @@ #define H_KOMODO_H // Todo: -// 1. net balance limiter, wait for notarized -// 2. verify: reorgs +// verify: reorgs // non komodod (non-hardfork) todo: // a. automate notarization fee payouts // b. automated distribution of test REVS snapshot +#define KOMODO_ASSETCHAINS_WAITNOTARIZE + #include #include #include @@ -512,7 +513,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) numvalid = bitweight(signedmask); if ( height == 79633 ) notarized = 1; - if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries>>1)) ) + if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); notarized = 1; @@ -563,7 +564,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } } - if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1) ) + if ( ((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries/3) ) { memset(&txhash,0,sizeof(txhash)); komodo_stateupdate(height,pubkeys,numvalid,0,txhash,0,0,0,0,0,0,0,0,0,0); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 254d88815..e15460837 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -15,9 +15,10 @@ // paxdeposit equivalent in reverse makes opreturn and KMD does the same in reverse -int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base) +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; + int32_t baseid; struct komodo_state *sp; int64_t netliability,maxallowed; + *available = *deposited = *issued = *withdrawn = *approved = *redeemed = 0; if ( (baseid= komodo_baseid(base)) >= 0 ) { if ( (sp= komodo_stateptrget(base)) != 0 ) @@ -27,7 +28,11 @@ int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn, *withdrawn = sp->withdrawn; *approved = sp->approved; *redeemed = sp->redeemed; - printf("%p %s %.8f %.8f %.8f %.8f %.8f\n",sp,base,dstr(*deposited),dstr(*issued),dstr(*withdrawn),dstr(*approved),dstr(*redeemed)); + netliability = (sp->deposited - sp->withdrawn) - sp->shorted; + 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)); return(0); } else printf("pax_fiatstatus cant get basesp.%s\n",base); } else printf("pax_fiatstatus illegal base.%s\n",base); @@ -360,9 +365,17 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to HASH_ITER(hh,PAX,pax,tmp) { //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); - if ( strcmp(symbol,"KMD") == 0 && (pax->approved == 0 || pax->validated == 0) ) + if ( strcmp(symbol,"KMD") == 0 && pax->approved == 0 ) continue; - if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 ) + else if ( strcmp(symbol,"KMD") != 0 ) + { +#ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE + struct komodo_state *kmdsp = komodo_stateptrget("KMD"); + if ( kmdsp != 0 && kmdsp->notarized_height >= pax->height ) // assumes same chain as notarize + pax->validated = kmdsp->notarized_height; +#endif + } + if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) continue; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) printf("pax.%s marked.%d %.8f -> %.8f\n",ASSETCHAINS_SYMBOL,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); @@ -629,6 +642,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,values[i],CURRENCIES[baseids[i]],srcvalues[i],&rmd160s[i*20],txids[i],vouts[i],'A',kmdheights[i],otherheights[i],CURRENCIES[baseids[i]],kmdheights[i]); + komodo_paxmark(height,txids[i],vouts[i],'W',height); + komodo_paxmark(height,txids[i],vouts[i],'A',height); if ( srcvalues[i] != 0 && (basesp= komodo_stateptrget(CURRENCIES[baseids[i]])) != 0 ) { basesp->approved += srcvalues[i]; @@ -674,9 +689,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'I',height,0,CURRENCIES[baseids[i]],0); - if ( komodo_paxmark(height,txids[i],vouts[i],'I',height) == 0 ) - { - } + komodo_paxmark(height,txids[i],vouts[i],'D',height); + komodo_paxmark(height,txids[i],vouts[i],'I',height); if ( (pax= komodo_paxfind(txids[i],vouts[i],'I')) != 0 ) { pax->type = opretbuf[0]; @@ -696,8 +710,9 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 continue; bitcoin_address(coinaddr,60,&rmd160s[i*20],20); komodo_gateway_deposit(coinaddr,0,0,0,0,txids[i],vouts[i],'X',height,0,(char *)"KMD",0); - if ( komodo_paxmark(height,txids[i],vouts[i],'X',height) == 0 ) - ; + komodo_paxmark(height,txids[i],vouts[i],'W',height); + komodo_paxmark(height,txids[i],vouts[i],'A',height); + komodo_paxmark(height,txids[i],vouts[i],'X',height); if ( (pax= komodo_paxfind(txids[i],vouts[i],'X')) != 0 ) { pax->type = opretbuf[0]; diff --git a/src/komodo_pax.h b/src/komodo_pax.h index c415c2bbe..2bcab56de 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -309,7 +309,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { if ( relid == MAX_CURRENCIES ) { - kmdbtc = pvals[MAX_CURRENCIES]; + if ( (kmdbtc= pvals[MAX_CURRENCIES]) < 25000 ) + kmdbtc = 25000; btcusd = pvals[MAX_CURRENCIES + 1]; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { diff --git a/src/komodo_structs.h b/src/komodo_structs.h index bbca9c25f..b62a76d3c 100644 --- a/src/komodo_structs.h +++ b/src/komodo_structs.h @@ -23,7 +23,7 @@ #endif*/ #define GENESIS_NBITS 0x1f00ffff -#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 13) +#define KOMODO_MINRATIFY ((height < 90000) ? 7 : 11) #define KOMODO_MAXBLOCKS 5000000 #define KOMODO_EVENT_RATIFY 'P' @@ -71,7 +71,7 @@ struct komodo_state uint256 NOTARIZED_HASH,NOTARIZED_DESTTXID; int32_t SAVEDHEIGHT,CURRENT_HEIGHT,NOTARIZED_HEIGHT; uint32_t SAVEDTIMESTAMP; - uint64_t deposited,issued,withdrawn,approved,redeemed; + uint64_t deposited,issued,withdrawn,approved,redeemed,shorted; struct notarized_checkpoint *NPOINTS; int32_t NUM_NPOINTS; struct komodo_event **Komodo_events; int32_t Komodo_numevents; uint32_t RTbufs[64][3]; uint64_t RTmask; diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 5602292a5..98cccdf0c 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -785,6 +785,17 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "KMD" }; +uint64_t komodo_maxallowed(int32_t baseid) +{ + uint64_t mult,val = (uint64_t)10000 * COIN; + if ( baseid < 0 || baseid >= 32 ) + return(0); + if ( baseid < 10 ) + val *= 10; + mult = MINDENOMS[baseid] / MIND; + return(mult * val); +} + int32_t komodo_baseid(char *origbase) { int32_t i; char base[64]; diff --git a/src/miner.cpp b/src/miner.cpp index 2879561c4..6201e21dd 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -99,7 +99,7 @@ void UpdateTime(CBlockHeader* pblock, const Consensus::Params& consensusParams, } #define ASSETCHAINS_MINHEIGHT 100 -#define ROUNDROBIN_DELAY 60 +#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; diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index 4b1102005..f5140de1b 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -481,12 +481,12 @@ Value notaries(const Array& params, bool fHelp) } int32_t komodo_pending_withdraws(char *opretstr); -int32_t pax_fiatstatus(uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); +int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); extern char CURRENCIES[][8]; Value paxpending(const Array& params, bool fHelp) { - Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t deposited,issued,withdrawn,approved,redeemed; + Object ret; Array a; char opretbuf[10000*2]; int32_t opretlen,baseid; uint64_t available,deposited,issued,withdrawn,approved,redeemed; if ( fHelp || params.size() != 0 ) throw runtime_error("paxpending needs no args\n"); LOCK(cs_main); @@ -500,6 +500,7 @@ Value paxpending(const Array& params, bool fHelp) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { + item.push_back(Pair("available", ValueFromAmount(available))); item.push_back(Pair("deposited", ValueFromAmount(deposited))); item.push_back(Pair("issued", ValueFromAmount(issued))); item.push_back(Pair("withdrawn", ValueFromAmount(withdrawn))); diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index b96b0a48a..261d52959 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -482,6 +482,7 @@ extern char ASSETCHAINS_SYMBOL[16]; int32_t komodo_is_issuer(); int32_t iguana_rwnum(int32_t rwflag,uint8_t *serialized,int32_t len,void *endianedp); int32_t komodo_isrealtime(int32_t *kmdheightp); +int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued,uint64_t *withdrawn,uint64_t *approved,uint64_t *redeemed,char *base); Value paxdeposit(const Array& params, bool fHelp) { @@ -501,6 +502,8 @@ Value paxdeposit(const Array& params, bool fHelp) std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) != 0 || available < fiatoshis ) + throw runtime_error("paxdeposit no 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 5334d5ad70b312c7a163d91fed253b6f7a9e9651 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:36:51 -0300 Subject: [PATCH 095/142] test --- src/komodo_gateway.h | 6 +++--- src/komodo_pax.h | 11 +++++++++++ src/komodo_utils.h | 11 ----------- 3 files changed, 14 insertions(+), 14 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index e15460837..b386f2393 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -370,9 +370,9 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to else if ( strcmp(symbol,"KMD") != 0 ) { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE - struct komodo_state *kmdsp = komodo_stateptrget("KMD"); - if ( kmdsp != 0 && kmdsp->notarized_height >= pax->height ) // assumes same chain as notarize - pax->validated = kmdsp->notarized_height; + struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); + if ( kmdsp != 0 && kmdsp->NOTARIZED_HEIGHT >= pax->height ) // assumes same chain as notarize + pax->validated = kmdsp->NOTARIZED_HEIGHT; #endif } if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2bcab56de..d9236b7b5 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -94,6 +94,17 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri 1, 1, 1, 1, 1, 1, 0, 0, // isum 100000000000 }; +uint64_t komodo_maxallowed(int32_t baseid) +{ + uint64_t mult,val = (uint64_t)10000 * COIN; + if ( baseid < 0 || baseid >= 32 ) + return(0); + if ( baseid < 10 ) + val *= 10; + mult = MINDENOMS[baseid] / MIND; + return(mult * val); +} + uint64_t komodo_paxvol(uint64_t volume,uint64_t price) { if ( volume < 10000000000 ) diff --git a/src/komodo_utils.h b/src/komodo_utils.h index 98cccdf0c..5602292a5 100644 --- a/src/komodo_utils.h +++ b/src/komodo_utils.h @@ -785,17 +785,6 @@ char CURRENCIES[][8] = { "USD", "EUR", "JPY", "GBP", "AUD", "CAD", "CHF", "NZD", "CNY", "RUB", "MXN", "BRL", "INR", "HKD", "TRY", "ZAR", "PLN", "NOK", "SEK", "DKK", "CZK", "HUF", "ILS", "KRW", "MYR", "PHP", "RON", "SGD", "THB", "BGN", "IDR", "HRK", "KMD" }; -uint64_t komodo_maxallowed(int32_t baseid) -{ - uint64_t mult,val = (uint64_t)10000 * COIN; - if ( baseid < 0 || baseid >= 32 ) - return(0); - if ( baseid < 10 ) - val *= 10; - mult = MINDENOMS[baseid] / MIND; - return(mult * val); -} - int32_t komodo_baseid(char *origbase) { int32_t i; char base[64]; From 1c05f0b501013f5c53363372d8b3e56ac835b587 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:45:54 -0300 Subject: [PATCH 096/142] test --- src/komodo_gateway.h | 38 ++++++++++++++++++++------------------ src/komodo_pax.h | 2 +- src/wallet/rpcwallet.cpp | 4 ++-- 3 files changed, 23 insertions(+), 21 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index b386f2393..f2fd7e3af 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -352,7 +352,7 @@ int32_t komodo_pending_withdraws(char *opretstr) 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 mask; + 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; sp = komodo_stateptr(symbol,dest); strcpy(symbol,base); PENDING_KOMODO_TX = 0; @@ -375,6 +375,11 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to pax->validated = kmdsp->NOTARIZED_HEIGHT; #endif } + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) + { + printf("miner: skip %s %.8f when avail %.8f\n",symbol,dstr(pax->fiatoshis),dstr(available)); + continue; + } if ( pax->marked != 0 || strcmp(pax->symbol,symbol) != 0 || pax->validated == 0 ) continue; if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) @@ -427,7 +432,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { - int32_t i,j,n,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]; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; + int32_t i,j,n,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; memset(baseids,0xff,sizeof(baseids)); memset(values,0,sizeof(values)); memset(srcvalues,0,sizeof(srcvalues)); @@ -461,35 +466,32 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( (pax= komodo_paxfinds(txids[i-1],vouts[i-1])) != 0 ) { pax->type = opcode; + if ( opcode == 'I' && pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,symbol) != 0 || available < pax->fiatoshis ) + { + printf("checkdeposit: skip %s %.8f when avail %.8f\n",pax->symbol,dstr(pax->fiatoshis),dstr(available)); + 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 ( pax->marked != 0 && height >= 80820 ) errs++; else matched++; - //if ( opcode == 'X' ) 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 { - //if ( opcode == 'X' ) - { - 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); - } + 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); } } else { - //if ( opcode == 'X' ) - { - hash = block.GetHash(); - for (j=0; j<32; j++) - printf("%02x",((uint8_t *)&hash)[j]); - printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); - } //else if ( opcode == 'I' ) - // matched++; + hash = block.GetHash(); + for (j=0; j<32; j++) + printf("%02x",((uint8_t *)&hash)[j]); + printf(" ht.%d blockhash X couldnt find vout.[%d]\n",height,i); } } if ( matched != num ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d9236b7b5..a8a8727de 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -96,7 +96,7 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri uint64_t komodo_maxallowed(int32_t baseid) { - uint64_t mult,val = (uint64_t)10000 * COIN; + uint64_t mult,val = COIN; // * (uint64_t)10000; if ( baseid < 0 || baseid >= 32 ) return(0); if ( baseid < 10 ) diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 261d52959..87fc11a35 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -486,7 +486,7 @@ int32_t pax_fiatstatus(uint64_t *available,uint64_t *deposited,uint64_t *issued, Value paxdeposit(const Array& params, bool fHelp) { - uint64_t seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; + uint64_t available,deposited,issued,withdrawn,approved,redeemed,seed,komodoshis = 0; int32_t height; char destaddr[64]; uint8_t i,pubkey37[33]; bool fSubtractFeeFromAmount = false; if ( komodo_is_issuer() != 0 ) throw JSONRPCError(RPC_INVALID_ADDRESS_OR_KEY, "paxdeposit only from KMD"); @@ -502,7 +502,7 @@ Value paxdeposit(const Array& params, bool fHelp) std::string base = params[2].get_str(); std::string dest; height = chainActive.Tip()->nHeight; - if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) != 0 || available < fiatoshis ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,(char *)base.c_str()) != 0 || available < fiatoshis ) throw runtime_error("paxdeposit no 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); From 51ee9373f1bb4e8543f98ab3a711e63299a713ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 09:47:38 -0300 Subject: [PATCH 097/142] test --- src/rpcblockchain.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/rpcblockchain.cpp b/src/rpcblockchain.cpp index f5140de1b..b87eaf942 100644 --- a/src/rpcblockchain.cpp +++ b/src/rpcblockchain.cpp @@ -496,7 +496,7 @@ Value paxpending(const Array& params, bool fHelp) for (baseid=0; baseid<32; baseid++) { Object item,obj; - if ( pax_fiatstatus(&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) + if ( pax_fiatstatus(&available,&deposited,&issued,&withdrawn,&approved,&redeemed,CURRENCIES[baseid]) == 0 ) { if ( deposited != 0 || issued != 0 || withdrawn != 0 || approved != 0 || redeemed != 0 ) { From bff51d678814c2cbd47a741b8da3a03fd7d233f8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:02:45 -0300 Subject: [PATCH 098/142] test --- src/komodo_gateway.h | 70 ++++++++++++++++++++++------------------ src/wallet/rpcwallet.cpp | 2 +- 2 files changed, 40 insertions(+), 32 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index f2fd7e3af..9a3a76647 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -108,7 +108,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 ( 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]); @@ -135,7 +135,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t pax->otherheight = otherheight; if ( pax->marked == 0 ) { - if ( addflag != 0 ) + if ( 0 && addflag != 0 ) { if ( (pax->approved= approved) != 0 ) s = (char *)"APPROVED"; @@ -148,7 +148,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t else { pax->marked = height; - printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight); + //printf("pax.%p MARK DEPOSIT ht.%d other.%d\n",pax,height,otherheight); } } @@ -166,11 +166,11 @@ int32_t komodo_rwapproval(int32_t rwflag,uint8_t *opretbuf,struct pax_transactio { for (i=0; i<32; i++) ((uint8_t *)&pax->txid)[i] = opretbuf[len++]; - for (i=0; i<32; i++) - printf("%02x",((uint8_t *)&pax->txid)[31-i]); + //for (i=0; i<32; i++) + // printf("%02x",((uint8_t *)&pax->txid)[31-i]); pax->vout = opretbuf[len++]; pax->vout += ((uint32_t)opretbuf[len++] << 8); - printf(" txid v.%d\n",pax->vout); + //printf(" txid v.%d\n",pax->vout); } len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->komodoshis),&pax->komodoshis); len += iguana_rwnum(rwflag,&opretbuf[len],sizeof(pax->fiatoshis),&pax->fiatoshis); @@ -221,6 +221,7 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t otherheights[n] = p.otherheight; memcpy(&rmd160s[n * 20],p.rmd160,20); baseids[n] = komodo_baseid(p.source); + if ( 0 ) { char coinaddr[64]; bitcoin_address(coinaddr,60,&rmd160s[n * 20],20); @@ -276,7 +277,7 @@ uint64_t komodo_paxtotal() pax->fiatoshis = pax2->fiatoshis; basesp->issued += pax->fiatoshis; pax->didstats = 1; - printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); + //printf("Iset %s dstats %.8f += %.8f\n",str,dstr(basesp->issued),dstr(pax->fiatoshis)); pax2->marked = pax->height; } } @@ -340,13 +341,13 @@ int32_t komodo_pending_withdraws(char *opretstr) if ( len == 0 ) opretbuf[len++] = 'A'; len += komodo_rwapproval(1,&opretbuf[len],pax); - printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); + //printf("%s.(marked.%u approved.%d) %p\n",pax->source,pax->marked,pax->approved,pax); } } if ( len > 0 ) init_hexbytes_noT(opretstr,opretbuf,len); else opretstr[0] = 0; - printf("komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); + fprintf(stderr,"komodo_pending_withdraws len.%d PAXTOTAL %.8f\n",len,dstr(komodo_paxtotal())); return(len); } @@ -406,7 +407,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to { len += komodo_rwapproval(1,&data[len],pax); PENDING_KOMODO_TX += pax->komodoshis; - printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); + //printf(" vout.%u DEPOSIT %.8f <- pax.%s pending %.8f | ",pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,dstr(PENDING_KOMODO_TX)); } if ( numvouts++ >= 64 ) break; @@ -548,15 +549,15 @@ 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,fiatoshis); typestr = "deposit"; - 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\n",ASSETCHAINS_SYMBOL,base,kmdheight,height,dstr(checktoshis),dstr(value),komodo_is_issuer(),strncmp(ASSETCHAINS_SYMBOL,base,strlen(base)) == 0,(long long)seed); if ( kmdheight <= height ) { - for (i=0; i<32; i++) + /*for (i=0; i<32; i++) printf("%02x",((uint8_t *)&txid)[i]); printf(" <- txid.v%u ",vout); for (i=0; i<33; i++) printf("%02x",pubkey33[i]); - printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height); + printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ didstats = 0; if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) { @@ -566,7 +567,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } komodo_gateway_deposit(coinaddr,value,base,fiatoshis,rmd160,txid,vout,'D',kmdheight,height,(char *)"KMD",0); } @@ -578,7 +580,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->deposited += fiatoshis; didstats = 1; - printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); + if ( strcmp(base,ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p deposited %s += %.8f\n",basesp,base,dstr(fiatoshis)); } } if ( didstats != 0 ) @@ -596,7 +599,7 @@ 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); + //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(komodoshis,checktoshis,seed) == 0 ) { @@ -606,9 +609,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->withdrawn += value; didstats = 1; - printf("########### %p withdrawn %s += %.8f\n",basesp,base,dstr(value)); + 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); + //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 ) @@ -621,7 +625,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( ASSETCHAINS_SYMBOL[0] != 0 ) + if ( 0 && ASSETCHAINS_SYMBOL[0] != 0 ) { for (i=0; i KMD %.8f vs %.8f\n",kmdheights[i],CURRENCIES[baseids[i]],(double)srcvalues[i]/COIN,(double)values[i]/COIN,(double)checktoshis/COIN); + /*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]); + 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); @@ -650,9 +654,10 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->approved += srcvalues[i]; didstats = 1; - printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } - printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); + //printf(" i.%d (%s) <- %.8f ADDFLAG APPROVED\n",i,coinaddr,dstr(values[i])); } else if ( pax->didstats == 0 && srcvalues[i] != 0 ) { @@ -660,21 +665,22 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->approved += srcvalues[i]; didstats = 1; - printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p approved %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } - } - else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); + } //else printf(" i.%d of n.%d pax.%p baseids[] %d\n",i,n,pax,baseids[i]); if ( (pax= komodo_paxfind(txids[i],vouts[i],'A')) != 0 ) { pax->type = opretbuf[0]; pax->approved = kmdheights[i]; if ( didstats != 0 ) pax->didstats = 1; - printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf(" i.%d approved.%d <<<<<<<<<<<<< APPROVED %p\n",i,kmdheights[i],pax); } } } - printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); + //printf("extra.[%d] after %.8f\n",n,dstr(komodo_paxtotal())); } else if ( opretbuf[0] == 'I' ) { @@ -722,6 +728,8 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->redeemed += srcvalues[i]; pax->didstats = 1; + if ( strcmp(CURRENCIES[baseids[i]],ASSETCHAINS_SYMBOL) == 0 ) + printf("########### %p redeemed %s += %.8f\n",basesp,CURRENCIES[baseids[i]],dstr(srcvalues[i])); } } } @@ -758,13 +766,13 @@ void komodo_passport_iteration() fseek(fp,0,SEEK_END); if ( ftell(fp) > lastpos[baseid] ) { - if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) + 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 ) ; lastpos[baseid] = ftell(fp); - if ( lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) + if ( 0 && lastpos[baseid] == 0 && strcmp(symbol,"KMD") == 0 ) printf("from.(%s) lastpos[%s] %ld\n",ASSETCHAINS_SYMBOL,CURRENCIES[baseid],lastpos[baseid]); } //else fprintf(stderr,"%s.%ld ",CURRENCIES[baseid],ftell(fp)); fclose(fp); @@ -783,7 +791,7 @@ void komodo_passport_iteration() } //else fprintf(stderr,"%s not RT\n",base); } //else fprintf(stderr,"%s size error RT\n",base); fclose(fp); - } else fprintf(stderr,"%s open error RT\n",base); + } //else fprintf(stderr,"%s open error RT\n",base); } else { diff --git a/src/wallet/rpcwallet.cpp b/src/wallet/rpcwallet.cpp index 87fc11a35..61b287512 100644 --- a/src/wallet/rpcwallet.cpp +++ b/src/wallet/rpcwallet.cpp @@ -503,7 +503,7 @@ 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 ) - throw runtime_error("paxdeposit no 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 dff4ef45760fc23e814c9aeb443796011f92d835 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:10:06 -0300 Subject: [PATCH 099/142] test --- src/komodo.h | 2 +- src/komodo_gateway.h | 4 ++-- src/komodo_pax.h | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index d9c45fa9c..75e682c8b 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -164,7 +164,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char int32_t i; for (i=0; i ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -733,7 +733,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 } } } - } else printf("komodo_issued_opreturn returned %d\n",n); + } //else printf("komodo_issued_opreturn returned %d\n",n); } return(typestr); } diff --git a/src/komodo_pax.h b/src/komodo_pax.h index a8a8727de..d50583470 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -96,11 +96,11 @@ uint64_t peggy_smooth_coeffs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)] = // numpri uint64_t komodo_maxallowed(int32_t baseid) { - uint64_t mult,val = COIN; // * (uint64_t)10000; + uint64_t mult,val = COIN * (uint64_t)10000; if ( baseid < 0 || baseid >= 32 ) return(0); if ( baseid < 10 ) - val *= 10; + val *= 4; mult = MINDENOMS[baseid] / MIND; return(mult * val); } From 73585700ff081923ccb5aa29d05310aaf890faa5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:14:18 -0300 Subject: [PATCH 100/142] test --- src/komodo_bitcoind.h | 2 +- src/komodo_gateway.h | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/komodo_bitcoind.h b/src/komodo_bitcoind.h index db1ea8319..5e3e228ea 100644 --- a/src/komodo_bitcoind.h +++ b/src/komodo_bitcoind.h @@ -366,7 +366,7 @@ uint256 komodo_getblockhash(int32_t height) } free_json(result); } - printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); + //printf("KMD hash.%d (%s) %x\n",height,jsonstr,*(uint32_t *)&hash); free(jsonstr); } return(hash); diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 854dec9d9..c539b63ce 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -475,9 +475,10 @@ 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 ) + { + 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++; - 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 matched++; } else { From 83b0138266d82147bf2192f8528edab136444abd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:18:00 -0300 Subject: [PATCH 101/142] test --- src/komodo_notary.h | 2 +- src/miner.cpp | 4 ++-- src/wallet/db.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_notary.h b/src/komodo_notary.h index cbfca6563..6cf292ccc 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -108,7 +108,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) memcpy(kp->pubkey,pubkeys[k],33); kp->notaryid = k; HASH_ADD_KEYPTR(hh,N.Notaries,kp->pubkey,33,kp); - if ( height > 10000 ) + if ( 0 && height > 10000 ) { for (i=0; i<33; i++) printf("%02x",pubkeys[k][i]); diff --git a/src/miner.cpp b/src/miner.cpp index 6201e21dd..2567539f3 100644 --- a/src/miner.cpp +++ b/src/miner.cpp @@ -534,7 +534,7 @@ void static BitcoinMiner(CWallet *pwallet) else solver = "default"; assert(solver == "tromp" || solver == "default"); LogPrint("pow", "Using Equihash solver \"%s\" with n = %u, k = %u\n", solver, n, k); - fprintf(stderr,"Mining with %s\n",solver.c_str()); + //fprintf(stderr,"Mining with %s\n",solver.c_str()); std::mutex m_cs; bool cancelSolver = false; boost::signals2::connection c = uiInterface.NotifyBlockTip.connect( @@ -584,7 +584,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); unique_ptr pblocktemplate(CreateNewBlockWithKey(reservekey)); diff --git a/src/wallet/db.cpp b/src/wallet/db.cpp index b103f0ce7..766e2afda 100644 --- a/src/wallet/db.cpp +++ b/src/wallet/db.cpp @@ -83,7 +83,7 @@ bool CDBEnv::Open(const boost::filesystem::path& pathIn) TryCreateDirectory(pathLogDir); boost::filesystem::path pathErrorFile = pathIn / "db.log"; LogPrintf("CDBEnv::Open: LogDir=%s ErrorFile=%s pathIn.(%s)\n", pathLogDir.string(), pathErrorFile.string(),pathIn.string()); - fprintf(stderr,"strPath.(%s)\n",strPath.c_str()); + //fprintf(stderr,"strPath.(%s)\n",strPath.c_str()); unsigned int nEnvFlags = 0; if (GetBoolArg("-privdb", true)) From 3f8696e5768a12edf54b6dbb69359fa094e4dc0f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 10:25:02 -0300 Subject: [PATCH 102/142] test --- src/komodo_events.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo_events.h b/src/komodo_events.h index e38708918..0d77b0148 100644 --- a/src/komodo_events.h +++ b/src/komodo_events.h @@ -52,7 +52,7 @@ void komodo_eventadd_notarized(struct komodo_state *sp,char *symbol,int32_t heig void komodo_eventadd_pubkeys(struct komodo_state *sp,char *symbol,int32_t height,uint8_t num,uint8_t pubkeys[64][33]) { struct komodo_event_pubkeys P; - printf("eventadd pubkeys ht.%d\n",height); + //printf("eventadd pubkeys ht.%d\n",height); memset(&P,0,sizeof(P)); P.num = num; memcpy(P.pubkeys,pubkeys,33 * num); From 295e677f203d3a3f64d9fc8a9a5c9f6dc355745c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:10:13 -0300 Subject: [PATCH 103/142] test --- src/komodo_pax.h | 155 +++++++++++++++++++++++++++-------------------- 1 file changed, 89 insertions(+), 66 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index d50583470..eb84f0231 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -308,9 +308,67 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) } } -uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume) +uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed,uint64_t basevolume) { - uint32_t pvalb,pvalr,kmdbtc,btcusd; uint64_t usdvol,baseusd,usdkmd,baserel,ranked[32]; + int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; + for (sum=i=zeroes=nonz=0; i (numvotes >> 1) ) + break; + } + } + } + } + if ( wt > (numvotes >> 1) ) + { + ind = i; + for (densum=sum=j=0; j 10000*COIN ) { printf("paxcalc overflow %.8f\n",dstr(basevolume)); @@ -320,16 +378,19 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { if ( relid == MAX_CURRENCIES ) { - if ( (kmdbtc= pvals[MAX_CURRENCIES]) < 25000 ) + if ( kmdbtc == 0 ) + kmdbtc = pvals[MAX_CURRENCIES]; + if ( btcusd == 0 ) + btcusd = pvals[MAX_CURRENCIES + 1]; + if ( kmdbtc < 25000 ) kmdbtc = 25000; - btcusd = pvals[MAX_CURRENCIES + 1]; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - //printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); - //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); + printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } @@ -357,7 +418,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba return(0); } -uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolume) +uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,char *base,char *rel,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd) { int32_t baseid=-1,relid=-1,i; uint32_t *ptr; if ( height > 10 ) @@ -368,7 +429,13 @@ uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolum { ptr = &PVALS[36 * i]; if ( *ptr < height ) - return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume)); + { + *kmdbtcp = pvals[MAX_CURRENCIES + 1]; + *btcusdp = pvals[MAX_CURRENCIES + 2]; + if ( kmdbtc != 0 && btcusd != 0 ) + return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); + else return(0); + } } } else printf("paxprice invalid base.%s %d, rel.%s %d\n",base,baseid,rel,relid); return(0); @@ -376,7 +443,7 @@ uint64_t _komodo_paxprice(int32_t height,char *base,char *rel,uint64_t basevolum uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { - int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[539]; + int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[539],btcusds[539],kmdbtcs[539],kmdbtc,btcusd; if ( basevolume > 10000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -384,67 +451,23 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); - for (sum=i=zeroes=nonz=0; i> 1) ) return(0); - sum /= nonz; - lastprice = sum; - for (i=0; i (numvotes >> 1) ) - break; - } - } - } - } - if ( wt > (numvotes >> 1) ) - { - ind = i; - for (densum=sum=j=0; j= max ) return(num); From 9e838b49de0347c3419d00ebc9bef9f58402aef6 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:12:15 -0300 Subject: [PATCH 104/142] test --- src/komodo_pax.h | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index eb84f0231..f4b0843ba 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -430,8 +430,11 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha ptr = &PVALS[36 * i]; if ( *ptr < height ) { - *kmdbtcp = pvals[MAX_CURRENCIES + 1]; - *btcusdp = pvals[MAX_CURRENCIES + 2]; + if ( kmdbtcp != 0 && btcusdp != 0 ) + { + *kmdbtcp = pvals[MAX_CURRENCIES + 1]; + *btcusdp = pvals[MAX_CURRENCIES + 2]; + } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); else return(0); @@ -461,7 +464,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 11:14:36 -0300 Subject: [PATCH 105/142] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f4b0843ba..e6787c0cd 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -389,7 +389,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("base -> USD %llu, BTC %llu KMDUSD %llu\n",(long long)baseusd,(long long)btcusd,(long long)kmdusd); + printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); @@ -432,8 +432,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = pvals[MAX_CURRENCIES + 1]; - *btcusdp = pvals[MAX_CURRENCIES + 2]; + *kmdbtcp = ptr[MAX_CURRENCIES + 1]; + *btcusdp = ptr[MAX_CURRENCIES + 2]; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); From a6cd9b2813c40e1be8852527299b033016c0f20b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:31:30 -0300 Subject: [PATCH 106/142] test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index c539b63ce..51dcbcbb3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -515,7 +515,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; - if ( seed == 0 ) + if ( seed == 0 && checkvalue != 0 ) { ratio = ((value << 6) / checkvalue); if ( ratio >= 63 && ratio <= 65 ) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index e6787c0cd..e95c95149 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -308,7 +308,7 @@ void komodo_pvals(int32_t height,uint32_t *pvals,uint8_t numpvals) } } -uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed,uint64_t basevolume) +uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) { int32_t i,j,k,ind,zeroes,wt,nonz; int64_t delta; uint64_t lastprice,tolerance,den,densum,sum=0; for (sum=i=zeroes=nonz=0; i 10000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); @@ -457,10 +457,13 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin memset(btcusds,0,sizeof(btcusds)); memset(kmdbtcs,0,sizeof(kmdbtcs)); for (i=0; i Date: Sun, 27 Nov 2016 11:32:36 -0300 Subject: [PATCH 107/142] 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 e95c95149..4209f4422 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -473,7 +473,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed,basevolume) / 100000); + return(komodo_paxcorrelation(votes,numvotes,seed)); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From 8e4f2263708125a7e198dcb8a09cc7b9bcd398db Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:38:40 -0300 Subject: [PATCH 108/142] test --- src/komodo_pax.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 4209f4422..343d281f9 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,10 +356,11 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); + printf("%.8f ",(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); - //printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); break; } } From 96a5ff2ef95ba8d9abe32d7ab49ba5b52abdf98c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:39:37 -0300 Subject: [PATCH 109/142] 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 343d281f9..9bc2efc54 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f basevol %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),dstr(basevolume),height); + printf("paxprice seed.%llx sum %.8f densum %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),height); break; } } From 39681154892ebccada51404a3bab76f9e34920b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:40:45 -0300 Subject: [PATCH 110/142] 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 9bc2efc54..d6e780a9f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f height.%d\n",(long long)seed,dstr(sum),dstr(densum),height); + printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); break; } } From f56ade04edd6e72fc91e51dd2ca3e325a1870ef1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:46:01 -0300 Subject: [PATCH 111/142] 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 d6e780a9f..6ee3f1c80 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,7 +356,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); - printf("%.8f ",(double)sum/densum); + printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); From 406d463f0bdbc5566d3bfc2baa02fc5d8af455bc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:51:02 -0300 Subject: [PATCH 112/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 6ee3f1c80..44b9ed5bd 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1]; - *btcusdp = ptr[MAX_CURRENCIES + 2]; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 10; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 10; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); From 48dbd80fbd9cf361b455f71b96405f6428727566 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 11:58:53 -0300 Subject: [PATCH 113/142] test --- src/komodo_pax.h | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 44b9ed5bd..b914c71a7 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -390,8 +390,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); - printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + //printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); + //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 10; - *btcusdp = ptr[MAX_CURRENCIES + 2] / 10; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 128; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 128; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); @@ -460,11 +460,11 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin for (i=0; i Date: Sun, 27 Nov 2016 11:59:16 -0300 Subject: [PATCH 114/142] test --- src/komodo_pax.h | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index b914c71a7..0a96adc95 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -433,8 +433,8 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha { if ( kmdbtcp != 0 && btcusdp != 0 ) { - *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 128; - *btcusdp = ptr[MAX_CURRENCIES + 2] / 128; + *kmdbtcp = ptr[MAX_CURRENCIES + 1] / 539; + *btcusdp = ptr[MAX_CURRENCIES + 2] / 539; } if ( kmdbtc != 0 && btcusd != 0 ) return(komodo_paxcalc(&ptr[1],baseid,relid,basevolume,kmdbtc,btcusd)); @@ -463,8 +463,8 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin //printf("(%llu %llu) ",(long long)kmdbtcs[numvotes-1-i],(long long)btcusds[numvotes-1-i]); } *seedp = seed = komodo_seed(height); - kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 128; - btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 128; + kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; + btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 12:07:58 -0300 Subject: [PATCH 115/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 0a96adc95..91044f3bb 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -356,7 +356,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) den = peggy_smooth_coeffs[j]; densum += den; sum += (den * votes[(ind + j) % numvotes]); - printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); + //printf("(%llu/%llu %.8f) ",(long long)sum,(long long)densum,(double)sum/densum); } sum /= densum; //sum = (sum * basevolume); @@ -468,7 +468,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 12:10:58 -0300 Subject: [PATCH 116/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 91044f3bb..34c791a80 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -468,13 +468,13 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed)); + return(komodo_paxcorrelation(votes,numvotes,seed) * 1000); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From a5fcacd775f40ee91359ef2ca3a04f2c2e96d989 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 12:17:13 -0300 Subject: [PATCH 117/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 34c791a80..d7741a226 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -360,7 +360,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) } sum /= densum; //sum = (sum * basevolume); - printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); + //printf("paxprice seed.%llx sum %.8f densum %.8f\n",(long long)seed,dstr(sum),dstr(densum)); break; } } @@ -474,7 +474,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed) * 1000); + return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From c753065bb0e465bd733c1c0e8e187ef34f5351d0 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 12:19:48 -0300 Subject: [PATCH 118/142] 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 d7741a226..77c9e97d6 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -474,7 +474,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin } if ( nonz <= (numvotes >> 1) ) return(0); - return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume); + return(komodo_paxcorrelation(votes,numvotes,seed) * basevolume / 100000); } int32_t komodo_paxprices(int32_t *heights,uint64_t *prices,int32_t max,char *base,char *rel) From 61230ce13c4d0244b06af91eb1d5ac2608aa2aa4 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 13:58:18 -0300 Subject: [PATCH 119/142] test --- src/komodo_gateway.h | 2 +- src/komodo_pax.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51dcbcbb3..358ae20d1 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -368,7 +368,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to //printf("pax.%s marked.%d %.8f -> %.8f\n",pax->symbol,pax->marked,dstr(pax->komodoshis),dstr(pax->fiatoshis)); if ( strcmp(symbol,"KMD") == 0 && pax->approved == 0 ) continue; - else if ( strcmp(symbol,"KMD") != 0 ) + //else if ( strcmp(symbol,"KMD") != 0 ) { #ifdef KOMODO_ASSETCHAINS_WAITNOTARIZE struct komodo_state *kmdsp = komodo_stateptrget((char *)"KMD"); diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 77c9e97d6..f83170ff2 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -465,7 +465,7 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin *seedp = seed = komodo_seed(height); kmdbtc = komodo_paxcorrelation(kmdbtcs,numvotes,seed) * 539; btcusd = komodo_paxcorrelation(btcusds,numvotes,seed) * 539; - printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); + //printf("kmdbtc %llu btcusd %llu\n",(long long)kmdbtc,(long long)btcusd); for (i=nonz=0; i Date: Sun, 27 Nov 2016 14:23:40 -0300 Subject: [PATCH 120/142] test --- src/komodo.h | 2 +- src/komodo_notary.h | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 75e682c8b..0b1199c09 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -85,7 +85,7 @@ int32_t komodo_parsestatefile(struct komodo_state *sp,FILE *fp,char *symbol,char errs++; else { - printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht); + //printf("updated %d pubkeys at %s ht.%d\n",num,symbol,ht); if ( (KOMODO_EXTERNAL_NOTARIES != 0 && matched != 0) || (strcmp(symbol,"KMD") == 0 && KOMODO_EXTERNAL_NOTARIES == 0) ) komodo_eventadd_pubkeys(sp,symbol,ht,num,pubkeys); } diff --git a/src/komodo_notary.h b/src/komodo_notary.h index 6cf292ccc..6415b9d94 100644 --- a/src/komodo_notary.h +++ b/src/komodo_notary.h @@ -99,7 +99,7 @@ void komodo_notarysinit(int32_t origheight,uint8_t pubkeys[64][33],int32_t num) height /= KOMODO_ELECTION_GAP; height = ((height + 1) * KOMODO_ELECTION_GAP); htind = (height / KOMODO_ELECTION_GAP); - printf("htind.%d activation %d from %d vs %d | hwmheight.%d\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight); + printf("htind.%d activation %d from %d vs %d | hwmheight.%d %s\n",htind,height,origheight,(((origheight+KOMODO_ELECTION_GAP/2)/KOMODO_ELECTION_GAP)+1)*KOMODO_ELECTION_GAP,hwmheight,ASSETCHAINS_SYMBOL); } else htind = 0; pthread_mutex_lock(&komodo_mutex); for (k=0; k Date: Sun, 27 Nov 2016 14:26:53 -0300 Subject: [PATCH 121/142] test --- src/chainparams.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 34b042749..b0a0f28a0 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -95,6 +95,7 @@ public: assert(genesis.hashMerkleRoot == uint256S("0x4a5e1e4baab89f3a32518a88c31bc87f618f76673e2cc77ab2127b7afdeda33b")); vFixedSeeds.clear(); vSeeds.clear(); + vSeeds.push_back(CDNSSeedData("komodoplatform.com", "seeds.komodoplatform.com")); // @kolo vSeeds.push_back(CDNSSeedData("komodo.mewhub.com", "seeds.komodo.mewhub.com")); // @kolo // TODO: set up bootstrapping for mainnet base58Prefixes[PUBKEY_ADDRESS] = std::vector(1,60); From 061bbda40508c2f97f09f029be8e3e9b8a55ebfc Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 14:51:13 -0300 Subject: [PATCH 122/142] 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 f83170ff2..6f65f95e2 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -448,7 +448,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; - if ( basevolume > 10000*COIN ) + if ( basevolume > 100000*COIN ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); From ac606ad4d518a42a710c21f0cea0fa2ccce6a22c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 14:57:04 -0300 Subject: [PATCH 123/142] test --- src/komodo.h | 1 + src/komodo_pax.h | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 0b1199c09..aea264253 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -24,6 +24,7 @@ // b. automated distribution of test REVS snapshot #define KOMODO_ASSETCHAINS_WAITNOTARIZE +#define KOMODO_PAXMAX (100000 * COIN) #include #include diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 6f65f95e2..2e5ae40db 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -370,7 +370,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t basevolume,uint64_t kmdbtc,uint64_t btcusd) { uint32_t pvalb,pvalr; uint64_t usdvol,baseusd,usdkmd,baserel,ranked[32]; - if ( basevolume > 10000*COIN ) + if ( basevolume > KOMODO_PAXMAX ) { printf("paxcalc overflow %.8f\n",dstr(basevolume)); return(0); @@ -448,7 +448,7 @@ uint64_t _komodo_paxprice(uint64_t *kmdbtcp,uint64_t *btcusdp,int32_t height,cha uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uint64_t basevolume) { int32_t i,j,k,ind,zeroes,numvotes,wt,nonz; int64_t delta; uint64_t lastprice,seed,tolerance,den,densum,sum=0,votes[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],btcusds[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtcs[sizeof(Peggy_inds)/sizeof(*Peggy_inds)],kmdbtc,btcusd; - if ( basevolume > 100000*COIN ) + if ( basevolume > KOMODO_PAXMAX ) { printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); From fa8d44fc9cbea077096eda8ac8c15a48dce402b3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:06:47 -0300 Subject: [PATCH 124/142] test --- src/komodo.h | 2 +- src/komodo_pax.h | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index aea264253..a7c38399a 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -24,7 +24,7 @@ // b. automated distribution of test REVS snapshot #define KOMODO_ASSETCHAINS_WAITNOTARIZE -#define KOMODO_PAXMAX (100000 * COIN) +#define KOMODO_PAXMAX (10000 * COIN) #include #include diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2e5ae40db..105a55743 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,11 +388,15 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd); + if ( MINDENOMS[baseid] > MINDENOMS[USD] ) + usdvol /= (MINDENOMS[baseid] / MINDENOMS[USD]); usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - //printf("base -> USD %llu, BTC %llu ",(long long)baseusd,(long long)btcusd); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu ",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + if ( MINDENOMS[baseid] < MINDENOMS[USD] ) + return((MINDENOMS[USD]/MINDENOMS[baseid]) * komodo_paxvol(usdvol,usdkmd)); + else return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 5fe8a65f7fd1a9243eda52f994ad63aa526c1eaf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:12:49 -0300 Subject: [PATCH 125/142] test --- src/komodo_pax.h | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 105a55743..2cd0ee377 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -383,20 +383,16 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = pvals[MAX_CURRENCIES]; if ( btcusd == 0 ) btcusd = pvals[MAX_CURRENCIES + 1]; - if ( kmdbtc < 25000 ) - kmdbtc = 25000; + if ( kmdbtc < 25000000 ) + kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + baseusd = ((uint64_t)pvalb * (1000000000*MINDENOMS[USD]/MINDENOMS[baseid])) / pvals[USD]; usdvol = komodo_paxvol(basevolume,baseusd); - if ( MINDENOMS[baseid] > MINDENOMS[USD] ) - usdvol /= (MINDENOMS[baseid] / MINDENOMS[USD]); usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu ",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - if ( MINDENOMS[baseid] < MINDENOMS[USD] ) - return((MINDENOMS[USD]/MINDENOMS[baseid]) * komodo_paxvol(usdvol,usdkmd)); - else return(komodo_paxvol(usdvol,usdkmd)); + return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 1aefb8595926d2bdcd788129c1cf63ffa1870809 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:19:06 -0300 Subject: [PATCH 126/142] test --- src/komodo_pax.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 2cd0ee377..edf2568aa 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,12 +387,13 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * (1000000000*MINDENOMS[USD]/MINDENOMS[baseid])) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd); + baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); + //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd)); + return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From ec2ad5bb0e8334c3be243c4039419bb54dcde9ea Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:20:50 -0300 Subject: [PATCH 127/142] 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 edf2568aa..13f60aad6 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -391,7 +391,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); From 9703af06df45a42747758f9b6ec8ffd0ab6f7ed5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:25:32 -0300 Subject: [PATCH 128/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 13f60aad6..41da46a05 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd); + usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + return(komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 3309b67c281074f017c30c639106c92068a7d185 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:32:13 -0300 Subject: [PATCH 129/142] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 41da46a05..cfed4085f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = MINDENOMS[USD] * komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(komodo_paxvol(usdvol,usdkmd)); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 445e9606fb6d14cfad54e2c3f10980f4c4fd51c3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:37:07 -0300 Subject: [PATCH 130/142] test --- src/komodo_pax.h | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index cfed4085f..af761e54e 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -388,12 +388,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; - usdvol = komodo_paxvol(basevolume,baseusd) / MINDENOMS[baseid]; + usdvol = komodo_paxvol(basevolume,baseusd); //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd)); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) From 5929269abd59fddab22258fc77af100aa0a7ca0a Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 15:39:36 -0300 Subject: [PATCH 131/142] test --- src/komodo_pax.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index af761e54e..f90b3da0f 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,9 +387,8 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = ((uint64_t)pvalb * 1000000000) / pvals[USD]; + baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); - //usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); From ca6d4ab7df50ef801035657d2bb31bdc39c7c311 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:03:16 -0300 Subject: [PATCH 132/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index f90b3da0f..48e0b5a2c 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -389,7 +389,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba { baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); - usdkmd = ((uint64_t)btcusd * 1000000000) / kmdbtc; + usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); @@ -407,7 +407,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba else if ( (pvalr= pvals[relid]) != 0 ) { baserel = ((uint64_t)pvalb * 1000000000) / pvalr; - //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); + printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); if ( MINDENOMS[baseid] > MINDENOMS[relid] ) basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]); else if ( MINDENOMS[baseid] < MINDENOMS[relid] ) From b0c7fb04559be1beb36d4a5683c58e67bc439637 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:10:17 -0300 Subject: [PATCH 133/142] test --- src/komodo_pax.h | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 48e0b5a2c..8ba2b0076 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -387,12 +387,12 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba kmdbtc = 25000000; if ( pvals[USD] != 0 && kmdbtc != 0 && btcusd != 0 ) { - baseusd = 1000 * (((uint64_t)pvalb * 1000000) / pvals[USD]); + baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid])); + printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); - return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / MINDENOMS[baseid]); + return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); } else if ( baseid == relid ) @@ -453,6 +453,11 @@ uint64_t komodo_paxprice(uint64_t *seedp,int32_t height,char *base,char *rel,uin printf("komodo_paxprice overflow %.8f\n",dstr(basevolume)); return(0); } + if ( strcmp(base,"KMD") == 0 || strcmp(base,"kmd") == 0 ) + { + printf("kmd cannot be base currency\n"); + return(0); + } numvotes = (int32_t)(sizeof(Peggy_inds)/sizeof(*Peggy_inds)); memset(votes,0,sizeof(votes)); memset(btcusds,0,sizeof(btcusds)); From 4077bfb068e35a6faca5d87d3ebb42b8a4157f1f Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:14:13 -0300 Subject: [PATCH 134/142] test --- src/komodo_pax.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 8ba2b0076..7ee964f23 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -390,7 +390,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba baseusd = (((uint64_t)pvalb * 1000000000) / pvals[USD]); usdvol = komodo_paxvol(basevolume,baseusd); usdkmd = ((uint64_t)kmdbtc * 1000000000) / btcusd; - printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); + //printf("kmdbtc.%llu btcusd.%llu base -> USD %llu, usdkmd %llu usdvol %llu -> %llu\n",(long long)kmdbtc,(long long)btcusd,(long long)baseusd,(long long)usdkmd,(long long)usdvol,(long long)(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100))); //printf("usdkmd.%llu basevolume.%llu baseusd.%llu paxvol.%llu usdvol.%llu -> %.8f\n",(long long)usdkmd,(long long)basevolume,(long long)baseusd,(long long)komodo_paxvol(basevolume,baseusd),(long long)usdvol,dstr(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd))); return(MINDENOMS[USD] * komodo_paxvol(usdvol,usdkmd) / (MINDENOMS[baseid]/100)); } //else printf("zero val in KMD conv %llu %llu %llu\n",(long long)pvals[USD],(long long)kmdbtc,(long long)btcusd); @@ -407,7 +407,7 @@ uint64_t komodo_paxcalc(uint32_t *pvals,int32_t baseid,int32_t relid,uint64_t ba else if ( (pvalr= pvals[relid]) != 0 ) { baserel = ((uint64_t)pvalb * 1000000000) / pvalr; - printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); + //printf("baserel.%lld %lld %lld %.8f %.8f\n",(long long)baserel,(long long)MINDENOMS[baseid],(long long)MINDENOMS[relid],dstr(MINDENOMS[baseid]/MINDENOMS[relid]),dstr(MINDENOMS[relid]/MINDENOMS[baseid])); if ( MINDENOMS[baseid] > MINDENOMS[relid] ) basevolume /= (MINDENOMS[baseid] / MINDENOMS[relid]); else if ( MINDENOMS[baseid] < MINDENOMS[relid] ) From ccdd88f40f8c02baab5cfa485ded099e2da83d79 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:22:24 -0300 Subject: [PATCH 135/142] test --- src/komodo_gateway.h | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 358ae20d1..2f1e64c07 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -512,7 +512,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -522,7 +522,8 @@ int32_t komodo_paxcmp(uint64_t value,uint64_t checkvalue,uint64_t seed) return(0); else { - printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + if ( height >= 85000 ) + printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); return(-1); } } @@ -560,7 +561,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 printf("%02x",pubkey33[i]); printf(" checkpubkey check %.8f v %.8f dest.(%s) kmdheight.%d height.%d\n",dstr(checktoshis),dstr(value),destaddr,kmdheight,height);*/ didstats = 0; - if ( komodo_paxcmp(value,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(kmdheight,value,checktoshis,seed) == 0 ) { if ( (pax= komodo_paxfind(txid,vout,'D')) == 0 ) { @@ -602,7 +603,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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); didstats = 0; - if ( komodo_paxcmp(komodoshis,checktoshis,seed) == 0 ) + if ( komodo_paxcmp(kmdheight,komodoshis,checktoshis,seed) == 0 ) { if ( value != 0 && ((pax= komodo_paxfind(txid,vout,'W')) == 0 || pax->didstats == 0) ) { From dd23e17ff75a4667ab95f70c592dc8a092eb6e99 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:26:49 -0300 Subject: [PATCH 136/142] 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 2f1e64c07..21439fca9 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -512,7 +512,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t seed) +int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) { int32_t ratio; if ( seed == 0 && checkvalue != 0 ) @@ -522,8 +522,8 @@ int32_t komodo_paxcmp(int32_t height,uint64_t value,uint64_t checkvalue,uint64_t return(0); else { - if ( height >= 85000 ) - printf("ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",(long long)value,(long long)checkvalue,ratio); + if ( kmdheight >= 85000 ) + printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } } From c88bda8b76b36b9eee456419e019764d1cfa1877 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:28:50 -0300 Subject: [PATCH 137/142] 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 21439fca9..6dbf3b26a 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint6 return(0); else { - if ( kmdheight >= 85000 ) + if ( kmdheight >= 86050 ) printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } From ce1cfd1687fba16abe5cb57c54e3a64a08e1ee3b Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:35:05 -0300 Subject: [PATCH 138/142] 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 6dbf3b26a..9da4a96ac 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -522,7 +522,7 @@ int32_t komodo_paxcmp(int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint6 return(0); else { - if ( kmdheight >= 86050 ) + if ( kmdheight >= 86150 ) printf("ht.%d ignore mismatched value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,(long long)value,(long long)checkvalue,ratio); return(-1); } From 8ea67f059595b803e39be4337563fb42ab9dead1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 27 Nov 2016 16:52:09 -0300 Subject: [PATCH 139/142] test --- src/komodo_pax.h | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/komodo_pax.h b/src/komodo_pax.h index 7ee964f23..d8cfc4f0b 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -317,6 +317,8 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) zeroes++; else sum += votes[i], nonz++; } + if ( nonz < (numvotes >> 2) ) + return(0) sum /= nonz; lastprice = sum; for (i=0; i Date: Sun, 27 Nov 2016 16:52:56 -0300 Subject: [PATCH 140/142] 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 d8cfc4f0b..3fe5304cc 100644 --- a/src/komodo_pax.h +++ b/src/komodo_pax.h @@ -318,7 +318,7 @@ uint64_t komodo_paxcorrelation(uint64_t *votes,int32_t numvotes,uint64_t seed) else sum += votes[i], nonz++; } if ( nonz < (numvotes >> 2) ) - return(0) + return(0); sum /= nonz; lastprice = sum; for (i=0; i Date: Sun, 27 Nov 2016 17:26:02 -0300 Subject: [PATCH 141/142] test --- src/komodo.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index a7c38399a..84cb87c93 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -512,8 +512,8 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } numvalid = bitweight(signedmask); - if ( height == 79633 ) - notarized = 1; + //if ( height == 79633 ) + // notarized = 1; if ( (((height < 90000 || (signedmask & 1) != 0) && numvalid >= KOMODO_MINRATIFY) || numvalid > (numnotaries/3)) ) { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d <<<<<<<<<<< notarized\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); From 93204984f645b9a4d96f5305ab1ac60bdc6d56e1 Mon Sep 17 00:00:00 2001 From: jl777 Date: Mon, 28 Nov 2016 09:29:56 -0300 Subject: [PATCH 142/142] test --- src/komodo.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/komodo.h b/src/komodo.h index 84cb87c93..1645f9516 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -23,7 +23,7 @@ // a. automate notarization fee payouts // b. automated distribution of test REVS snapshot -#define KOMODO_ASSETCHAINS_WAITNOTARIZE +//#define KOMODO_ASSETCHAINS_WAITNOTARIZE #define KOMODO_PAXMAX (10000 * COIN) #include