test
This commit is contained in:
69
src/komodo_bitcoind.h
Normal file
69
src/komodo_bitcoind.h
Normal file
@@ -0,0 +1,69 @@
|
||||
// komodo functions that interact with bitcoind C++
|
||||
|
||||
uint32_t komodo_txtime(uint256 hash)
|
||||
{
|
||||
CTransaction tx;
|
||||
uint256 hashBlock;
|
||||
if (!GetTransaction(hash, tx, hashBlock, true))
|
||||
{
|
||||
//printf("null GetTransaction\n");
|
||||
return(tx.nLockTime);
|
||||
}
|
||||
return(0);
|
||||
}
|
||||
|
||||
void komodo_disconnect(CBlockIndex *pindex,CBlock& block)
|
||||
{
|
||||
komodo_init();
|
||||
//uint256 zero;
|
||||
//printf("disconnect ht.%d\n",pindex->nHeight);
|
||||
//memset(&zero,0,sizeof(zero));
|
||||
//komodo_stateupdate(-pindex->nHeight,0,0,0,zero,0,0,0,0);
|
||||
}
|
||||
|
||||
int32_t komodo_block2height(CBlock *block)
|
||||
{
|
||||
int32_t i,n,height = 0; uint8_t *ptr = (uint8_t *)block->vtx[0].vin[0].scriptSig.data();
|
||||
komodo_init();
|
||||
if ( block->vtx[0].vin[0].scriptSig.size() > 5 )
|
||||
{
|
||||
//for (i=0; i<6; i++)
|
||||
// printf("%02x",ptr[i]);
|
||||
n = ptr[0];
|
||||
for (i=0; i<n; i++)
|
||||
{
|
||||
//03bb81000101(bb 187) (81 48001) (00 12288256) <- coinbase.6 ht.12288256
|
||||
height += ((uint32_t)ptr[i+1] << (i*8));
|
||||
//printf("(%02x %x %d) ",ptr[i+1],((uint32_t)ptr[i+1] << (i*8)),height);
|
||||
}
|
||||
//printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height);
|
||||
}
|
||||
return(height);
|
||||
}
|
||||
|
||||
void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block)
|
||||
{
|
||||
uint8_t *ptr = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data();
|
||||
komodo_init();
|
||||
memcpy(pubkey33,ptr+1,33);
|
||||
}
|
||||
|
||||
void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height)
|
||||
{
|
||||
CBlock block;
|
||||
komodo_init();
|
||||
memset(pubkey33,0,33);
|
||||
if ( pindex != 0 )
|
||||
{
|
||||
if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 )
|
||||
{
|
||||
komodo_block2pubkey33(pubkey33,block);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
// height -> pubkey33
|
||||
//printf("extending chaintip komodo_index2pubkey33 height.%d need to get pubkey33\n",height);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user