Merge branch 'FSM' of https://github.com/jl777/komodo into jl777-FSM

fix
This commit is contained in:
blackjok3r
2018-11-18 16:53:18 +08:00
9 changed files with 130 additions and 75 deletions

View File

@@ -1508,10 +1508,10 @@ int64_t komodo_checkcommission(CBlock *pblock,int32_t height)
matched = 25;
if ( matched == 0 )
{
int32_t i;
for (i=0; i<25; i++)
fprintf(stderr,"%02x",script[i]);
fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2);
//int32_t i;
//for (i=0; i<25; i++)
// fprintf(stderr,"%02x",script[i]);
//fprintf(stderr," payment to wrong pubkey scriptlen.%d, scriptpub[%d]\n",scriptlen,(int32_t)ASSETCHAINS_SCRIPTPUB.size()/2);
return(-1);
}
@@ -1606,13 +1606,25 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
return(-1);
}
}
if ( failed == 0 && ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
if ( failed == 0 && ASSETCHAINS_COMMISSION != 0 ) //ASSETCHAINS_OVERRIDE_PUBKEY33[0] != 0 )
{
if ( height == 1 )
{
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
return(-1);
if ( ASSETCHAINS_SCRIPTPUB.size() > 1 )
{
int32_t scriptlen; uint8_t scripthex[10000];
if ( ASSETCHAINS_SCRIPTPUB.size()/2 == pblock->vtx[0].vout[0].scriptPubKey.size() && scriptlen < sizeof(scripthex) )
{
decode_hex(scripthex,scriptlen,(char *)ASSETCHAINS_SCRIPTPUB.c_str());
if ( memcmp(scripthex,script,scriptlen) != 0 )
return(-1);
} else return(-1);
}
else
{
script = (uint8_t *)pblock->vtx[0].vout[0].scriptPubKey.data();
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 )
return(-1);
}
}
else
@@ -1623,19 +1635,15 @@ int32_t komodo_checkPOW(int32_t slowflag,CBlock *pblock,int32_t height)
if ( ASSETCHAINS_STREAM != 0 && height > 128 )
{
int lasttx = ( pblock->vtx.size() -1 );
printf("ABOUT TO CHECK LAST TX: %d\n",lasttx);
if ( lasttx == 0 )
return(-1);
uint256 hash; CTransaction tx;
if (GetTransaction(pblock->vtx[lasttx].vin[0].prevout.hash,tx,hash,false))
{
printf("CHECKING THE script pubkey\n");
script = (uint8_t *)tx.vout[pblock->vtx[lasttx].vin[0].prevout.n].scriptPubKey.data();
if ( script[0] != 33 || script[34] != OP_CHECKSIG || memcmp(script+1,ASSETCHAINS_OVERRIDE_PUBKEY33,33) != 0 ) {
printf("THE PUBKEY IS WRONG!\n");
return(-1);
}
printf("THE PUBKEY IS RIGHT! \n");
}
}
}