From a4c672852fecac53f03bba7e3863d4c7490b79d8 Mon Sep 17 00:00:00 2001 From: jl777 Date: Sun, 20 Nov 2016 16:45:33 -0300 Subject: [PATCH] test --- src/komodo.h | 5 +++-- src/komodo_gateway.h | 27 ++++++++++++++++++--------- src/komodo_structs.h | 2 +- 3 files changed, 22 insertions(+), 12 deletions(-) diff --git a/src/komodo.h b/src/komodo.h index cbeb8185c..34bcfed63 100644 --- a/src/komodo.h +++ b/src/komodo.h @@ -373,7 +373,8 @@ int32_t komodo_voutupdate(int32_t *isratificationp,int32_t notaryid,uint8_t *scr sp->NOTARIZED_HASH = kmdtxid; sp->NOTARIZED_DESTTXID = desttxid; komodo_stateupdate(height,0,0,0,zero,0,0,0,0,0,0,0,0,0,0); - // extract X opreturns here + if ( opretlen > len && scriptbuf[len] == 'A' ) + komodo_stateupdate(height,0,0,0,txhash,0,0,0,0,0,0,value,&scriptbuf[len],opretlen-len,j); } else printf("notarized.%d reject ht.%d NOTARIZED.%d %s.%s DESTTXID.%s (%s)\n",notarized,height,*notarizedheightp,ASSETCHAINS_SYMBOL[0]==0?"KMD":ASSETCHAINS_SYMBOL,kmdtxid.ToString().c_str(),desttxid.ToString().c_str(),(char *)&scriptbuf[len]); } else if ( i == 0 && j == 1 && opretlen == 149 ) @@ -481,7 +482,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block) } } printf("%s ht.%d txi.%d signedmask.%llx numvins.%d numvouts.%d\n",ASSETCHAINS_SYMBOL,height,i,(long long)signedmask,numvins,numvouts); - if ( specialtx != 0 && (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) + if ( (((signedmask & 1) != 0 && numvalid >= KOMODO_MINRATIFY) || bitweight(signedmask) > (numnotaries>>1)) ) { 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; diff --git a/src/komodo_gateway.h b/src/komodo_gateway.h index a3c8c25ab..841abc21e 100644 --- a/src/komodo_gateway.h +++ b/src/komodo_gateway.h @@ -155,6 +155,8 @@ uint64_t komodo_paxtotal() return(total); } +// need a function to return pending withdraws for notarizing opreturn + 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[10000],data[10000]; int32_t i,baseid,ht,len=0,opretlen=0,numvouts=1; struct komodo_state *sp; uint64_t mask; @@ -372,19 +374,26 @@ const char *komodo_opreturn(int32_t height,uint64_t value,uint8_t *opretbuf,int3 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; + komodo_gateway_deposit(coinaddr,komodoshis,"KMD",value,rmd160,txid,vout,kmdheight,height); } } } - else if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 || opretlen == 38 ) + else if ( tokomodo != 0 && opretbuf[0] == 'A' ) { - if ( tokomodo == 0 && opretbuf[0] == 'I' ) // assetchain coinbase + if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) + { + for (i=0; iapproved = kmdheights[i]; + } + } + } + else if ( tokomodo == 0 && opretbuf[0] == 'I' ) + { + if ( strncmp((char *)"KMD",(char *)&opretbuf[opretlen-4],3) != 0 ) { if ( (n= komodo_issued_opreturn(base,txids,vouts,values,kmdheights,otherheights,baseids,opretbuf,opretlen,0)) > 0 ) { diff --git a/src/komodo_structs.h b/src/komodo_structs.h index 4d09d5a81..f62e5de1a 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; - int32_t marked,height,otherheight; + int32_t marked,height,otherheight,approved; uint16_t vout; char symbol[16],coinaddr[64]; uint8_t rmd160[20],shortflag; };