From 45c6eef80cde18d8971a197b96c712d9132d26fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:19:29 +0300 Subject: [PATCH 01/10] Test --- src/komodo_gateway.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 51c745e86..924a22aae 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -584,7 +584,7 @@ int32_t komodo_gateway_deposits(CMutableTransaction *txNew,char *base,int32_t to PENDING_KOMODO_TX += pax->komodoshis; printf(" len.%d vout.%u DEPOSIT %.8f <- pax.%s pending ht %d %d %.8f | ",len,pax->vout,(double)txNew->vout[numvouts].nValue/COIN,symbol,pax->height,pax->otherheight,dstr(PENDING_KOMODO_TX)); } - if ( numvouts++ >= 64 ) + if ( numvouts++ >= 1 ) break; } if ( numvouts > 1 ) @@ -939,7 +939,14 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above { } if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) + { + //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,block.vtx[0].vout[i].nValue,0) == 0 ) + printf("paxcmp PASS "); + else printf("paxcmp FAIL "); + printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { From 9866121b28e844a6e30c21b6ecb3397ff9f68031 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:30:17 +0300 Subject: [PATCH 02/10] 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 924a22aae..3f08753da 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -652,7 +652,7 @@ void komodo_passport_iteration(); int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above block is valid pax pricing { static uint256 array[64]; static int32_t numbanned,indallvouts; - int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; + int32_t i,j,k,n,ht,baseid,txn_count,activation,num,opretlen,offset=1,errs=0,matched=0,kmdheights[64],otherheights[64]; uint256 hash,txids[64]; char symbol[16],base[16]; uint16_t vouts[64]; int8_t baseids[64]; uint8_t *script,opcode,rmd160s[64*20]; uint64_t total,available,deposited,issued,withdrawn,approved,redeemed,checktoshis,seed; int64_t values[64],srcvalues[64]; struct pax_transaction *pax; struct komodo_state *sp; activation = 235300; if ( *(int32_t *)&array[0] == 0 ) numbanned = komodo_bannedset(&indallvouts,array,(int32_t)(sizeof(array)/sizeof(*array))); @@ -941,7 +941,8 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,block.vtx[0].vout[i].nValue,0) == 0 ) + checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)values[i-1]); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From 0c780ec8fa421461c83cddf085abd143b975dda9 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:32:18 +0300 Subject: [PATCH 03/10] 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 3f08753da..98228d585 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -1100,7 +1100,7 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 { basesp->issued += pax2->fiatoshis; pax2->didstats = 1; - if ( 1 && strcmp(base,"USD") == 0 ) + if ( 0 && strcmp(base,"USD") == 0 ) printf("########### %p issueda %s += %.8f kmdheight.%d %.8f other.%d [%d]\n",basesp,base,dstr(pax2->fiatoshis),pax2->height,dstr(pax2->komodoshis),pax2->otherheight,height); } } From 9bd8223b2c3a3ff8a6d1d35d75d43162f204cc33 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:36:03 +0300 Subject: [PATCH 04/10] 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 98228d585..6956314e3 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,7 +941,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)values[i-1]); + checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From c83e66e128a9136d4ac8e52f3be05bd82f5c9b37 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:42:20 +0300 Subject: [PATCH 05/10] Test --- src/komodo_gateway.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 6956314e3..9de8bb545 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -941,8 +941,10 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) { //check deposit validates AUD.1047 [3] 0.14585530 -> 0.01000000 (0.14585530 0.01000000 0.01000000) - checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->fiatoshis,checktoshis,0) == 0 ) + char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; + checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); + //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,0) == 0 ) printf("paxcmp PASS "); else printf("paxcmp FAIL "); From a2a15c59f87d1b1f016aeb1a3e7480803c36c022 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:46:49 +0300 Subject: [PATCH 06/10] 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 9de8bb545..7669bc061 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -944,11 +944,12 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above char destaddr[64],coinaddr[64]; uint8_t pubkey33[33]; checktoshis = PAX_fiatdest(&seed,0,destaddr,pubkey33,coinaddr,pax->height,CURRENCIES[baseids[i-1]],pax->fiatoshis); //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); - if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,0) == 0 ) - printf("paxcmp PASS "); - else printf("paxcmp FAIL "); - - printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) + { + printf("paxcmp FAIL "); + printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + return(-1); + } } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) From e86de02591269aa03473f5dbfb23e3b721cf4175 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:49:19 +0300 Subject: [PATCH 07/10] 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 7669bc061..17828c41e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -949,7 +949,7 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above printf("paxcmp FAIL "); printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); return(-1); - } + } else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 ) From 38fb23568e2c8164cd90121c9360137cd5e6c2f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:52:55 +0300 Subject: [PATCH 08/10] Test --- src/komodo_gateway.h | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 17828c41e..ce5586f86 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -281,6 +281,8 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che } else if ( checkvalue != 0 ) { + if ( checkvalue != value ) + fprintf(stderr,"(%.8f != %.8f) ",(double)value/COIN,(double)checkvalue/COIN); ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); From 548befdc629e7c9e9f50d039d0711a795855067c Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 21:55:20 +0300 Subject: [PATCH 09/10] Test --- src/komodo_gateway.h | 2 -- 1 file changed, 2 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index ce5586f86..17828c41e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -281,8 +281,6 @@ int32_t komodo_paxcmp(char *symbol,int32_t kmdheight,uint64_t value,uint64_t che } else if ( checkvalue != 0 ) { - if ( checkvalue != value ) - fprintf(stderr,"(%.8f != %.8f) ",(double)value/COIN,(double)checkvalue/COIN); ratio = ((value << 10) / checkvalue); if ( ratio >= 1023 && ratio <= 1025 ) return(0); From ba2a8aa714eed85ef6a24971f2f7202a658df415 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 26 Mar 2017 22:05:42 +0300 Subject: [PATCH 10/10] Test --- src/komodo_gateway.h | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index 17828c41e..371d2174d 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -946,10 +946,9 @@ int32_t komodo_check_deposit(int32_t height,const CBlock& block) // verify above //checktoshis = komodo_paxprice(&seed,pax->height,CURRENCIES[baseids[i-1]],(char *)"KMD",(uint64_t)pax->komodoshis); if ( komodo_paxcmp(CURRENCIES[baseids[i-1]],pax->height,pax->komodoshis,checktoshis,seed) < 0 ) { - printf("paxcmp FAIL "); - printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + printf("paxcmp FAIL when check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); return(-1); - } else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); + } //else printf("check deposit validates %s.%d [%d] %.8f -> %.8f (%.8f %.8f %.8f)\n",CURRENCIES[baseids[i-1]],height,i,dstr(srcvalues[i-1]),dstr(values[i-1]),dstr(pax->komodoshis),dstr(pax->fiatoshis),dstr(block.vtx[0].vout[i].nValue)); } } else if ( strcmp(ASSETCHAINS_SYMBOL,CURRENCIES[baseids[i-1]]) == 0 )