From ea365a71c9ccb55caaab9c3c4a2bf0c407d474fd Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 15:52:34 -0300 Subject: [PATCH] test --- src/komodo.h | 53 +++++++++++++++++++++++--------------------- src/komodo_gateway.h | 15 +++++++++++-- 2 files changed, 41 insertions(+), 27 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index 7e8202be0..eaeeb6b07 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -311,7 +311,7 @@ void komodo_stateupdate(int32_t height,uint8_t notarypubs[][33],uint8_t numnotar } } -int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value) +int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scriptbuf,int32_t scriptlen,int32_t height,uint256 txhash,int32_t i,int32_t j,uint64_t *voutmaskp,int32_t *specialtxp,int32_t *notarizedheightp,uint64_t value,int32_t notarized) { static uint256 zero; int32_t opretlen,nid,k,len = 0; uint256 kmdtxid,desttxid; uint8_t crypto777[33]; struct komodo_state *sp; char symbol[16],dest[16]; if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) @@ -366,7 +366,7 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&kmdtxid); len += iguana_rwnum(0,&scriptbuf[len],4,(uint8_t *)notarizedheightp); len += iguana_rwbignum(0,&scriptbuf[len],32,(uint8_t *)&desttxid); - if ( *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) + if ( notarized != 0 && *notarizedheightp > sp->NOTARIZED_HEIGHT && *notarizedheightp < height ) { printf("%s ht.%d NOTARIZED.%d %s.%s %sTXID.%s (%s)\n",ASSETCHAINS_SYMBOL,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),ASSETCHAINS_SYMBOL[0]==0?"BTC":"KMD",desttxid.ToString().c_str(),(char *)&scriptbuf[len]); sp->NOTARIZED_HEIGHT = *notarizedheightp; @@ -435,7 +435,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) static int32_t hwmheight; uint64_t signedmask,voutmask; char symbol[16],dest[16]; struct komodo_state *sp; uint8_t scriptbuf[4096],pubkeys[64][33],rmd160[20],scriptPubKey[35]; uint256 kmdtxid,zero,btctxid,txhash; - int32_t i,j,k,numnotaries,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; + int32_t i,j,k,numnotaries,notarized,scriptlen,isratification,nid,numvalid,specialtx,notarizedheight,notaryid,len,numvouts,numvins,height,txn_count; memset(&zero,0,sizeof(zero)); komodo_init(pindex->nHeight); if ( (sp= komodo_stateptr(symbol,dest)) == 0 ) @@ -469,26 +469,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) txhash = block.vtx[i].GetHash(); numvouts = block.vtx[i].vout.size(); notaryid = -1; - voutmask = specialtx = notarizedheight = isratification = 0; - for (j=0; j 0 ) - { - for (k=0; k= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + { printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); - if ( signedmask != 0 && (notarizedheight != 0 || specialtx != 0) ) + notarized = 1; + } + for (j=0; j 0 ) + { + for (k=0; kfiatoshis = fiatoshis; memcpy(pax->rmd160,rmd160,20); pax->height = height; - pax->otherheight = sp->CURRENT_HEIGHT;//otherheight; + pax->otherheight = otherheight; if ( pax->marked == 0 ) { if ( addflag != 0 ) @@ -368,7 +368,18 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 if ( (pax= komodo_paxfind(&space,txid,vout)) == 0 ) { printf("notarize %s %.8f -> %.8f kmd.%d other.%d\n",ASSETCHAINS_SYMBOL,dstr(value),dstr(komodoshis),kmdheight,height); - } else printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + } + else + { + printf(" %.8f -> %s withdraw already there\n",dstr(value),coinaddr); + strcpy(pax->coinaddr,coinaddr); + pax->komodoshis = komodoshis; + strcpy(pax->symbol,"KMD"); + pax->fiatoshis = value; + memcpy(pax->rmd160,rmd160,20); + pax->height = kmdheight; + pax->otherheight = height; + } } } else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 )