Browse Source

test

pull/4/head
jl777 8 years ago
parent
commit
ea365a71c9
  1. 39
      src/komodo.h
  2. 15
      src/komodo_gateway.h

39
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,7 +469,22 @@ 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;
voutmask = specialtx = notarizedheight = isratification = notarized = 0;
signedmask = 0;
numvins = block.vtx[i].vin.size();
for (j=0; j<numvins; j++)
{
if ( (scriptlen= gettxout_scriptPubKey(scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) > 0 )
{
if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 )
signedmask |= (1LL << k);
}
}
if ( specialtx != 0 && (((signedmask & 1) != 0 && numvalid >= 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);
notarized = 1;
}
for (j=0; j<numvouts; j++)
{
len = block.vtx[i].vout[j].scriptPubKey.size();
@ -480,7 +495,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
#else
memcpy(scriptbuf,(uint8_t *)&block.vtx[i].vout[j].scriptPubKey[0],len);
#endif
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,&notarizedheight,(uint64_t)block.vtx[i].vout[j].nValue);
notaryid = komodo_voutupdate(&isratification,notaryid,scriptbuf,len,height,txhash,i,j,&voutmask,&specialtx,&notarizedheight,(uint64_t)block.vtx[i].vout[j].nValue,notarized);
if ( 0 && i > 0 )
{
for (k=0; k<len; k++)
@ -489,19 +504,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
}
}
}
signedmask = 0;
numvins = block.vtx[i].vin.size();
for (j=0; j<numvins; j++)
{
if ( (scriptlen= gettxout_scriptPubKey(scriptPubKey,sizeof(scriptPubKey),block.vtx[i].vin[j].prevout.hash,block.vtx[i].vin[j].prevout.n)) > 0 )
{
if ( (k= komodo_notarycmp(scriptPubKey,scriptlen,pubkeys,numnotaries,rmd160)) >= 0 )
signedmask |= (1LL << k);
}
}
if ( 0 && signedmask != 0 )
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) )
if ( notarized != 0 && (notarizedheight != 0 || specialtx != 0) )
{
printf("%s NOTARY SIGNED.%llx numvins.%d ht.%d txi.%d notaryht.%d specialtx.%d\n",ASSETCHAINS_SYMBOL,(long long)signedmask,numvins,height,i,notarizedheight,specialtx);
printf("ht.%d specialtx.%d isratification.%d numvouts.%d signed.%llx numnotaries.%d\n",height,specialtx,isratification,numvouts,(long long)signedmask,numnotaries);

15
src/komodo_gateway.h

@ -80,7 +80,7 @@ void komodo_gateway_deposit(char *coinaddr,uint64_t value,char *symbol,uint64_t
pax->fiatoshis = 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 )

Loading…
Cancel
Save