Merge pull request #179 from jl777/beta

Beta
This commit is contained in:
jl777
2017-02-07 18:40:46 +02:00
committed by GitHub
2 changed files with 47 additions and 34 deletions

View File

@@ -545,7 +545,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
for (j=0; j<numvouts; j++)
{
len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len <= sizeof(scriptbuf) )
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
#ifdef KOMODO_ZCASH
memcpy(scriptbuf,block.vtx[i].vout[j].scriptPubKey.data(),len);
@@ -576,7 +576,7 @@ void komodo_connectblock(CBlockIndex *pindex,CBlock& block)
for (j=1; j<numvouts-1; j++)
{
len = block.vtx[i].vout[j].scriptPubKey.size();
if ( len <= sizeof(scriptbuf) )
if ( len >= sizeof(uint32_t) && len <= sizeof(scriptbuf) )
{
#ifdef KOMODO_ZCASH
memcpy(scriptbuf,block.vtx[i].vout[j].scriptPubKey.data(),len);

View File

@@ -507,32 +507,41 @@ void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
} else printf("komodo_disconnect: ht.%d cant get komodo_state.(%s)\n",pindex->nHeight,ASSETCHAINS_SYMBOL);
}
int32_t komodo_is_notarytx(const CTransaction& tx)
{
uint8_t *ptr,crypto777[33];
if ( tx.vout.size() > 0 )
{
#ifdef KOMODO_ZCASH
ptr = (uint8_t *)tx.vout[0].scriptPubKey.data();
#else
ptr = (uint8_t *)&tx.vout[0].scriptPubKey[0];
#endif
if ( ptr != 0 )
{
decode_hex(crypto777,33,(char *)CRYPTO777_PUBSECPSTR);
if ( memcmp(ptr+1,crypto777,33) == 0 )
{
//printf("found notarytx\n");
return(1);
}
else return(0);
}
}
return(0);
}
int32_t komodo_block2height(CBlock *block)
{
int32_t i,n,height = 0; uint8_t *ptr;
if ( block->vtx[0].vin.size() > 0 )
{
#ifdef KOMODO_ZCASH
ptr = (uint8_t *)block->vtx[0].vin[0].scriptSig.data();
#else
ptr = (uint8_t *)&block->vtx[0].vin[0].scriptSig[0];
#endif
if ( block->vtx[0].vin[0].scriptSig.size() > 5 )
if ( ptr != 0 && block->vtx[0].vin[0].scriptSig.size() > 5 )
{
//for (i=0; i<6; i++)
// printf("%02x",ptr[i]);
@@ -546,12 +555,16 @@ int32_t komodo_block2height(CBlock *block)
//printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height);
}
//komodo_init(height);
}
return(height);
}
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
{
int32_t n;
memset(pubkey33,0,33);
if ( block.vtx[0].vout.size() > 0 )
{
#ifdef KOMODO_ZCASH
uint8_t *ptr = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data();
#else
@@ -561,7 +574,7 @@ void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
n = block.vtx[0].vout[0].scriptPubKey.size();
if ( n == 35 )
memcpy(pubkey33,ptr+1,33);
else memset(pubkey33,0,33);
}
}
int32_t komodo_blockload(CBlock& block,CBlockIndex *pindex)