From 673fddf0d73a13533848f1341cc2a8ab6b0ecbf5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Dec 2016 13:02:37 +0200 Subject: [PATCH 1/5] 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 3c50527c5..9d174a065 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -353,7 +353,7 @@ 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) %.8f\n",pax->source,pax->marked,pax->approved,dstr(pax->komodoshis)); } } } From 716aa1d5ed3b3a7c98fe2f335c2609b85d1e118a Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Dec 2016 13:07:08 +0200 Subject: [PATCH 2/5] 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 9d174a065..afb529600 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -353,8 +353,8 @@ 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) %.8f\n",pax->source,pax->marked,pax->approved,dstr(pax->komodoshis)); } + printf("%s.(kmdht.%d ht.%d marked.%u approved.%d validated %.8f) %.8f\n",pax->source,pax->height,pax->otherheight,pax->marked,pax->approved,dstr(pax->validated),dstr(pax->komodoshis)); } } if ( len > 0 ) From 772c13de095ba8470f9082dac120de3ae1e9fd58 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Dec 2016 13:14:18 +0200 Subject: [PATCH 3/5] test --- src/komodo_gateway.h | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index afb529600..00b4956a0 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -275,7 +275,10 @@ uint64_t komodo_paxtotal() if ( (checktoshis= komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis)) != 0 ) { if ( checktoshis != pax->komodoshis ) + { pax->marked = pax->height; + printf("WITHDRAW mark <- %d %.8f != %.8f\n",pax->height,dstr(checktoshis),dstr(pax->komodoshis)); + } else if ( pax->validated == 0 ) { pax->validated = pax->komodoshis; From 865bd97214a4ae23e4d4fe5c3de6ed51eb5891ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Dec 2016 13:19:41 +0200 Subject: [PATCH 4/5] test --- src/komodo_gateway.h | 52 ++++++++++++++++++++++---------------------- 1 file changed, 26 insertions(+), 26 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 00b4956a0..408fe42d2 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -238,6 +238,30 @@ int32_t komodo_issued_opreturn(char *base,uint256 *txids,uint16_t *vouts,int64_t return(n); } +int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) +{ + int32_t ratio; + if ( seed == 0 && checkvalue != 0 ) + { + ratio = ((value << 6) / checkvalue); + if ( ratio >= 63 && ratio <= 65 ) + return(0); + else + { + if ( kmdheight >= 86150 ) + printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,symbol,(long long)value,(long long)checkvalue,ratio); + return(-1); + } + } + else if ( checkvalue != 0 ) + { + ratio = ((value << 10) / checkvalue); + if ( ratio >= 1023 && ratio <= 1025 ) + return(0); + } + return(value != checkvalue); +} + uint64_t komodo_paxtotal() { struct pax_transaction *pax,*pax2,*tmp,*tmp2; char symbol[16],dest[16],*str; int32_t i,ht; int64_t checktoshis; uint64_t seed,total = 0; struct komodo_state *basesp; @@ -274,10 +298,10 @@ uint64_t komodo_paxtotal() //bitcoin_address(coinaddr,addrtype,rmd160,20); if ( (checktoshis= komodo_paxprice(&seed,pax->height,pax->source,(char *)"KMD",(uint64_t)pax->fiatoshis)) != 0 ) { - if ( checktoshis != pax->komodoshis ) + if ( komodo_paxcmp(pax->source,pax->height,pax->komodoshis,checktoshis,seed) == 0 ) { pax->marked = pax->height; - printf("WITHDRAW mark <- %d %.8f != %.8f\n",pax->height,dstr(checktoshis),dstr(pax->komodoshis)); + printf("WITHDRAW.%s mark <- %d %.8f != %.8f\n",pax->source,pax->height,dstr(checktoshis),dstr(pax->komodoshis)); } else if ( pax->validated == 0 ) { @@ -544,30 +568,6 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above return(0); } -int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t checkvalue,uint64_t seed) -{ - int32_t ratio; - if ( seed == 0 && checkvalue != 0 ) - { - ratio = ((value << 6) / checkvalue); - if ( ratio >= 63 && ratio <= 65 ) - return(0); - else - { - if ( kmdheight >= 86150 ) - printf("ht.%d ignore mismatched %s value %lld vs checkvalue %lld -> ratio.%d\n",kmdheight,symbol,(long long)value,(long long)checkvalue,ratio); - return(-1); - } - } - else if ( checkvalue != 0 ) - { - ratio = ((value << 10) / checkvalue); - if ( ratio >= 1023 && ratio <= 1025 ) - return(0); - } - 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,*pax2; struct komodo_state *basesp; double diff; From 60cd57df7f0ef45f952402a58414a4e9ebda2bd5 Mon Sep 17 00:00:00 2001 From: jl777 Date: Tue, 13 Dec 2016 13:22:59 +0200 Subject: [PATCH 5/5] 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 408fe42d2..d4cf8979b 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -301,7 +301,7 @@ uint64_t komodo_paxtotal() if ( komodo_paxcmp(pax->source,pax->height,pax->komodoshis,checktoshis,seed) == 0 ) { pax->marked = pax->height; - printf("WITHDRAW.%s mark <- %d %.8f != %.8f\n",pax->source,pax->height,dstr(checktoshis),dstr(pax->komodoshis)); + //printf("WITHDRAW.%s mark <- %d %.8f != %.8f\n",pax->source,pax->height,dstr(checktoshis),dstr(pax->komodoshis)); } else if ( pax->validated == 0 ) {