From 571fd156dc3e514501f8c97e44a66e99a3a871e7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:13:58 +0200 Subject: [PATCH 01/17] Notarizations api --- iguana/dpow/dpow_fsm.c | 15 +++++++----- iguana/iguana_notary.c | 46 +++++++++++++++++++++++++++++++++-- includes/iguana_apideclares.h | 1 + 3 files changed, 54 insertions(+), 8 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index bf68ebf19..c603c4c12 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -162,9 +162,9 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct uint32_t Numallocated; -int32_t dpow_txhasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) +int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) { - cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; + cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 ) { if ( (vins= jarray(&numvins,txobj,"vin")) != 0 ) @@ -223,19 +223,22 @@ int32_t dpow_txhasnotarization(int32_t *nothtp,struct supernet_info *myinfo,stru } free_json(txobj); } + if ( hasnotarization != 0 ) + (*signedmaskp) = notarymask; return(hasnotarization); } -int32_t dpow_hasnotarization(int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht) +int32_t dpow_hasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,cJSON *blockjson,int32_t ht) { int32_t i,n,hasnotarization = 0; bits256 txid; cJSON *txarray; *nothtp = 0; + *signedmaskp = 0; if ( (txarray= jarray(&n,blockjson,"tx")) != 0 ) { for (i=0; isymbol,height); @@ -262,7 +265,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { - if ( breakht == 0 && dpow_hasnotarization(¬ht,myinfo,coin,blockjson,ht) > 0 ) + if ( breakht == 0 && dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,ht) > 0 ) { breakht = notht; //free_json(blockjson); diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index f56bb4c79..d4ea4a55f 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -60,7 +60,7 @@ void dpow_checkpointset(struct supernet_info *myinfo,struct dpow_checkpoint *che void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t height,bits256 hash,uint32_t timestamp,uint32_t blocktime) { - void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; struct dpow_block *bp; + void **ptrs; char str[65]; cJSON *blockjson; struct iguana_info *coin; struct dpow_checkpoint checkpoint; int32_t freq,minsigs,i,ht,notht; uint64_t signedmask; struct dpow_block *bp; dpow_checkpointset(myinfo,&dp->last,height,hash,timestamp,blocktime); checkpoint = dp->srcfifo[dp->srcconfirms]; if ( strcmp("BTC",dp->dest) == 0 ) @@ -88,7 +88,7 @@ void dpow_srcupdate(struct supernet_info *myinfo,struct dpow_info *dp,int32_t he if ( (blockjson= dpow_getblock(myinfo,coin,hash)) != 0 ) { height = jint(blockjson,"height"); - if ( dpow_hasnotarization(¬ht,myinfo,coin,blockjson,height) <= 0 ) + if ( dpow_hasnotarization(&signedmask,¬ht,myinfo,coin,blockjson,height) <= 0 ) { blocktime = juint(blockjson,"time"); free_json(blockjson); @@ -575,6 +575,48 @@ void iguana_notarystats(int32_t totals[64],int32_t dispflag) } } +STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) +{ + int32_t i,j,ht,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; + memset(masksums,0,sizeof(masksums)); + if ( (coin= iguana_coinfind(symbol)) != 0 ) + { + for (i=0; i 0 ) + { + for (j=0; j<64; j++) + if ( ((1LL << j) & signedmask) != 0 ) + masksums[j]++; + } + free_json(blockjson); + } + } + array = cJSON_CreateArray(); + for (i=0; i Date: Sun, 18 Mar 2018 15:14:18 +0200 Subject: [PATCH 02/17] Script --- iguana/notarizations | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 iguana/notarizations diff --git a/iguana/notarizations b/iguana/notarizations new file mode 100644 index 000000000..17ed49712 --- /dev/null +++ b/iguana/notarizations @@ -0,0 +1,2 @@ + curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" + From 1cd43e437df9a67db9e329ff37dcc6acc42cf1f7 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:14:59 +0200 Subject: [PATCH 03/17] Fix --- iguana/notarizations | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 iguana/notarizations diff --git a/iguana/notarizations b/iguana/notarizations old mode 100644 new mode 100755 From cdf07b1f094a6c3383c3d1dffeb04b9f3aa29e95 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:18:36 +0200 Subject: [PATCH 04/17] Fix --- iguana/notarizations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/notarizations b/iguana/notarizations index 17ed49712..ad27bd3d1 100755 --- a/iguana/notarizations +++ b/iguana/notarizations @@ -1,2 +1,2 @@ - curl --url "http://127.0.0.1:7776" --data "{\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" + curl --url "http://127.0.0.1:7776" --data "{\"pubkey\":\"$pubkey\",\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" From 8c0fe90458e12c93e0475935593f592f65b2d5de Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:19:36 +0200 Subject: [PATCH 05/17] Fix --- iguana/notarizations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/notarizations b/iguana/notarizations index ad27bd3d1..980fb63ef 100755 --- a/iguana/notarizations +++ b/iguana/notarizations @@ -1,2 +1,2 @@ - curl --url "http://127.0.0.1:7776" --data "{\"pubkey\":\"$pubkey\",\"agent\":\"iguana\",\"method\":\"dpow\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" + curl --url "http://127.0.0.1:7776" --data "{\"pubkey\":\"$pubkey\",\"agent\":\"iguana\",\"method\":\"notarizations\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" From 1bd695bde533afe0f7eb343148295ad6f27970d3 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:21:10 +0200 Subject: [PATCH 06/17] Fixed --- iguana/notarizations | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/notarizations b/iguana/notarizations index 980fb63ef..a1a8fd0ed 100755 --- a/iguana/notarizations +++ b/iguana/notarizations @@ -1,2 +1,2 @@ - curl --url "http://127.0.0.1:7776" --data "{\"pubkey\":\"$pubkey\",\"agent\":\"iguana\",\"method\":\"notarizations\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" + curl --url "http://127.0.0.1:7776" --data "{\"pubkey\":\"$pubkey\",\"agent\":\"dpow\",\"method\":\"notarizations\",\"symbol\":\"PIZZA\",\"height\":5000,\"numblocks\":1000}" From 004ee06505598a452d5ac21d3803997cec06b4ae Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 15:25:00 +0200 Subject: [PATCH 07/17] Max height --- iguana/iguana_notary.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index d4ea4a55f..5f0197e0b 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -577,13 +577,20 @@ void iguana_notarystats(int32_t totals[64],int32_t dispflag) STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) { - int32_t i,j,ht,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; + int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; + if ( (retjson= dpow_getinfo(myinfo,coin)) != 0 ) + { + maxheight = jint(retjson,"blocks"); + free_json(retjson); + } else maxheight = (1 << 30); memset(masksums,0,sizeof(masksums)); if ( (coin= iguana_coinfind(symbol)) != 0 ) { for (i=0; i maxheight ) + break; blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { From d151c51ee2554336502c447526fed7ab8b671f34 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 16:47:22 +0200 Subject: [PATCH 08/17] Test --- iguana/dpow/dpow_fsm.c | 60 +++++++++++++++++++++++++++++++++++++- iguana/dpow/dpow_network.c | 2 +- iguana/iguana_notary.c | 5 +++- 3 files changed, 64 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index c603c4c12..980be9e36 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -162,6 +162,48 @@ int32_t dpow_checkutxo(struct supernet_info *myinfo,struct dpow_info *dp,struct uint32_t Numallocated; +int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txidp,char *symbol,bits256 *MoMp,uint32_t *MoMdepthp,uint8_t *opret,int32_t opretlen) +{ + int32_t i,c,len,offset = 0; uint8_t op; + symbol[0] = 0; + memset(blockhashp->bytes,0,sizeof(*blockhashp)); + memset(heightp,0,sizeof(*heightp)); + memset(txidp->bytes,0,sizeof(*txidp)); + memset(MoMp->bytes,0,sizeof(*MoMp)); + memset(MoMdepthp,0,sizeof(*MoMdepthp)); + if ( opret[offset++] == 0x6a ) + { + if ( (op= opret[offset++]) < 0x4c ) + len = op; + else if ( op == 0x4c ) + len = opret[offset++]; + else if ( op == 0x4d ) + { + len = opret[offset++]; + len = len + ((int32_t)opret[offset++] << 8); + } else return(-1); + offset += iguana_rwbignum(0,&opret[offset],sizeof(*blockhashp),blockhashp->bytes); + offset += iguana_rwnum(0,&opret[offset],sizeof(*heightp),(uint32_t *)heightp); + offset += iguana_rwbignum(0,&opret[offset],sizeof(*txidp),txidp->bytes); + for (i=0; i<65; i++) + { + if ( (c= opret[offset++]) == 0 ) + break; + if ( offset > opretlen ) + break; + symbol[i] = c; + } + symbol[i] = 0; + if ( offset+sizeof(bits256)+sizeof(uint32_t) <= opretlen ) + { + offset += iguana_rwbignum(0,&opret[offset],sizeof(*MoMp),MoMp->bytes); + offset += iguana_rwnum(0,&opret[offset],sizeof(*MoMdepthp),(uint32_t *)MoMdepthp); + } + return(len); + } + return(-1); +} + int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) { cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; @@ -216,6 +258,22 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { hasnotarization = 1; *nothtp = height - 10; + if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 ) + { + bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65],str[65],str2[65],str3[65]; + vout = jitem(vouts,numvouts-1); + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == sizeof(script)*2 ) + { + len >>= 1; + decode_hex(script,len,hexstr); + if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) + { + printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth); + if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 ) + *nothtp = 0; + } + } + } printf("numnotaries.%d %s hasnotarization.%d ht.%d MUSTFIX notht.%d\n",numnotaries,coin->symbol,hasnotarization,height,*nothtp); } } @@ -259,7 +317,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu merkles = calloc(3*maxdepth+1,sizeof(*merkles)); merkles[MoMdepth++] = merkle; ht = height - MoMdepth; - while ( MoMdepth < maxdepth && ht >= breakht && ht > 0 ) + while ( MoMdepth < maxdepth && ht > breakht && ht > 0 ) { //fprintf(stderr,"%s.%d ",coin->symbol,ht); blockhash = dpow_getblockhash(myinfo,coin,ht); diff --git a/iguana/dpow/dpow_network.c b/iguana/dpow/dpow_network.c index 0da39c78d..27ebcf91e 100755 --- a/iguana/dpow/dpow_network.c +++ b/iguana/dpow/dpow_network.c @@ -2243,7 +2243,7 @@ int32_t dpow_rwopret(int32_t rwflag,uint8_t *opret,bits256 *hashmsg,int32_t *hei { memcpy(&opret[opretlen],extras,extralen); opretlen += extralen; - printf("added extra.%d crc.%08x\n",extralen,calc_crc32(0,extras,extralen)); + //printf("added extra.%d crc.%08x\n",extralen,calc_crc32(0,extras,extralen)); } } else diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 5f0197e0b..717a05350 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -584,6 +584,7 @@ STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) free_json(retjson); } else maxheight = (1 << 30); memset(masksums,0,sizeof(masksums)); + ht = height; if ( (coin= iguana_coinfind(symbol)) != 0 ) { for (i=0; i Date: Sun, 18 Mar 2018 16:54:51 +0200 Subject: [PATCH 09/17] Test --- iguana/dpow/dpow_fsm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 980be9e36..39cfa2c25 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -262,7 +262,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65],str[65],str2[65],str3[65]; vout = jitem(vouts,numvouts-1); - if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == sizeof(script)*2 ) + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36 ) { len >>= 1; decode_hex(script,len,hexstr); From e00434bbdbbaea3aa52549d9644756d63d409151 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:01:41 +0200 Subject: [PATCH 10/17] Test --- iguana/dpow/dpow_fsm.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 39cfa2c25..55bfcee43 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -257,7 +257,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS ) { hasnotarization = 1; - *nothtp = height - 10; + *nothtp = 0; if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 ) { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65],str[65],str2[65],str3[65]; @@ -268,9 +268,9 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe decode_hex(script,len,hexstr); if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) { - printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth); - if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 ) + if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) *nothtp = 0; + printf("%s.%d notarizationht.%d %s -> %s MoM.%s [%d]\n",symbol,height,*nothtp,bits256_str(str,blockhash),bits256_str(str2,txid),bits256_str(str3,MoM),MoMdepth); } } } @@ -319,7 +319,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht > breakht && ht > 0 ) { - //fprintf(stderr,"%s.%d ",coin->symbol,ht); + fprintf(stderr,"%s.%d ",coin->symbol,ht); blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { @@ -327,7 +327,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { breakht = notht; //free_json(blockjson); - //printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); + printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); free_json(blockjson); From c9af32641faeab822b2d46bb4065a49237ef44ad Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:12:05 +0200 Subject: [PATCH 11/17] Test --- iguana/dpow/dpow_fsm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index 55bfcee43..e4fedde75 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -199,6 +199,7 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi offset += iguana_rwbignum(0,&opret[offset],sizeof(*MoMp),MoMp->bytes); offset += iguana_rwnum(0,&opret[offset],sizeof(*MoMdepthp),(uint32_t *)MoMdepthp); } + printf("offset.%d vs len.%d\n",offset,len); return(len); } return(-1); From cf00203997672f1bfb4e2035bae5175743c1ea01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:13:52 +0200 Subject: [PATCH 12/17] Test --- iguana/dpow/dpow_fsm.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index e4fedde75..b283ebe0c 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -188,12 +188,14 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi for (i=0; i<65; i++) { if ( (c= opret[offset++]) == 0 ) + { + symbol[i] = 0; break; + } if ( offset > opretlen ) break; symbol[i] = c; } - symbol[i] = 0; if ( offset+sizeof(bits256)+sizeof(uint32_t) <= opretlen ) { offset += iguana_rwbignum(0,&opret[offset],sizeof(*MoMp),MoMp->bytes); From 78bc32099abaa6ac37af92ff078752a35af520bf Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:21:15 +0200 Subject: [PATCH 13/17] Test --- iguana/dpow/dpow_fsm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index b283ebe0c..a7fce6532 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -201,7 +201,7 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi offset += iguana_rwbignum(0,&opret[offset],sizeof(*MoMp),MoMp->bytes); offset += iguana_rwnum(0,&opret[offset],sizeof(*MoMdepthp),(uint32_t *)MoMdepthp); } - printf("offset.%d vs len.%d\n",offset,len); + ///printf("offset.%d vs len.%d\n",offset,len); return(len); } return(-1); @@ -260,7 +260,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe if ( numnotaries >= DPOW_MIN_ASSETCHAIN_SIGS ) { hasnotarization = 1; - *nothtp = 0; + *nothtp = height - 10; if ( (vouts= jarray(&numvouts,txobj,"vout")) != 0 ) { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65],str[65],str2[65],str3[65]; @@ -269,7 +269,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { len >>= 1; decode_hex(script,len,hexstr); - if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) + if ( 0 && dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) { if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) *nothtp = 0; From 00a0941376d54b451ae70883bce6b98b67928507 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:27:28 +0200 Subject: [PATCH 14/17] Test --- iguana/dpow/dpow_fsm.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index a7fce6532..d6a1bcdfc 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -209,7 +209,7 @@ int32_t dpow_opreturn_parsesrc(bits256 *blockhashp,int32_t *heightp,bits256 *txi int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supernet_info *myinfo,struct iguana_info *coin,bits256 txid,int32_t height) { - cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[35]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; + cJSON *txobj,*vins,*vin,*vouts,*vout,*spentobj,*sobj; char *hexstr; uint8_t script[256]; bits256 spenttxid; uint64_t notarymask=0; int32_t i,j,numnotaries,len,spentvout,numvins,numvouts,hasnotarization = 0; if ( (txobj= dpow_gettransaction(myinfo,coin,txid)) != 0 ) { if ( (vins= jarray(&numvins,txobj,"vin")) != 0 ) @@ -229,7 +229,7 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe if ( spentvout < numvouts ) { vout = jitem(vouts,spentvout); - if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == sizeof(script)*2 ) + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) == 35*2 ) { len >>= 1; decode_hex(script,len,hexstr); @@ -265,11 +265,11 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe { bits256 blockhash,txid,MoM; uint32_t MoMdepth; char symbol[65],str[65],str2[65],str3[65]; vout = jitem(vouts,numvouts-1); - if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36 ) + if ( (sobj= jobj(vout,"scriptPubKey")) != 0 && (hexstr= jstr(sobj,"hex")) != 0 && (len= is_hexstr(hexstr,0)) > 36 && len < sizeof(script) ) { len >>= 1; decode_hex(script,len,hexstr); - if ( 0 && dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) + if ( dpow_opreturn_parsesrc(&blockhash,nothtp,&txid,symbol,&MoM,&MoMdepth,script,len) > 0 ) { if ( bits256_nonz(MoM) == 0 || MoMdepth == 0 || *nothtp >= height || *nothtp < 0 ) *nothtp = 0; From 7393d0ad988818d4d9e3d12bf2840c64ce74fe01 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:29:37 +0200 Subject: [PATCH 15/17] Test --- iguana/dpow/dpow_fsm.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/iguana/dpow/dpow_fsm.c b/iguana/dpow/dpow_fsm.c index d6a1bcdfc..793c255a7 100755 --- a/iguana/dpow/dpow_fsm.c +++ b/iguana/dpow/dpow_fsm.c @@ -277,7 +277,6 @@ int32_t dpow_txhasnotarization(uint64_t *signedmaskp,int32_t *nothtp,struct supe } } } - printf("numnotaries.%d %s hasnotarization.%d ht.%d MUSTFIX notht.%d\n",numnotaries,coin->symbol,hasnotarization,height,*nothtp); } } } @@ -322,7 +321,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu ht = height - MoMdepth; while ( MoMdepth < maxdepth && ht > breakht && ht > 0 ) { - fprintf(stderr,"%s.%d ",coin->symbol,ht); + //fprintf(stderr,"%s.%d ",coin->symbol,ht); blockhash = dpow_getblockhash(myinfo,coin,ht); if ( (blockjson= dpow_getblock(myinfo,coin,blockhash)) != 0 ) { @@ -330,7 +329,7 @@ bits256 dpow_calcMoM(uint32_t *MoMdepthp,struct supernet_info *myinfo,struct igu { breakht = notht; //free_json(blockjson); - printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); + //printf("%s has notarization at %d for breakht.%d\n",coin->symbol,ht,notht); } merkle = jbits256(blockjson,"merkleroot"); free_json(blockjson); From 85001e63064911551ff558d60505cb6ae5373306 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 18 Mar 2018 17:32:59 +0200 Subject: [PATCH 16/17] Test --- iguana/iguana_notary.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/iguana/iguana_notary.c b/iguana/iguana_notary.c index 717a05350..9f94fb4ea 100755 --- a/iguana/iguana_notary.c +++ b/iguana/iguana_notary.c @@ -578,15 +578,15 @@ void iguana_notarystats(int32_t totals[64],int32_t dispflag) STRING_AND_TWOINTS(dpow,notarizations,symbol,height,numblocks) { int32_t i,j,ht,maxheight,notht,masksums[64]; uint64_t signedmask; cJSON *retjson,*blockjson,*item,*array; bits256 blockhash; - if ( (retjson= dpow_getinfo(myinfo,coin)) != 0 ) - { - maxheight = jint(retjson,"blocks"); - free_json(retjson); - } else maxheight = (1 << 30); memset(masksums,0,sizeof(masksums)); ht = height; if ( (coin= iguana_coinfind(symbol)) != 0 ) { + if ( (retjson= dpow_getinfo(myinfo,coin)) != 0 ) + { + maxheight = jint(retjson,"blocks"); + free_json(retjson); + } else maxheight = (1 << 30); for (i=0; i Date: Sun, 18 Mar 2018 17:36:36 +0200 Subject: [PATCH 17/17] Test --- iguana/dPoW.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/iguana/dPoW.h b/iguana/dPoW.h index 7e3a8ca33..7862fe36d 100755 --- a/iguana/dPoW.h +++ b/iguana/dPoW.h @@ -23,7 +23,7 @@ #define DPOW_MIN_ASSETCHAIN_SIGS 11 //#define DPOW_M(bp) ((bp)->minsigs) // (((bp)->numnotaries >> 1) + 1) #define DPOW_MODIND(bp,offset) (((((bp)->height / DPOW_CHECKPOINTFREQ) % (bp)->numnotaries) + (offset)) % (bp)->numnotaries) -#define DPOW_VERSION 0x0781 +#define DPOW_VERSION 0x1781 #define DPOW_UTXOSIZE 50000 #define DPOW_MINOUTPUT 6000 #define DPOW_DURATION 600