]>
Commit | Line | Data |
---|---|---|
3eea72f2 | 1 | // komodo functions that interact with bitcoind C++ |
2 | ||
3 | uint32_t komodo_txtime(uint256 hash) | |
4 | { | |
5 | CTransaction tx; | |
6 | uint256 hashBlock; | |
7 | if (!GetTransaction(hash, tx, hashBlock, true)) | |
8 | { | |
9 | //printf("null GetTransaction\n"); | |
10 | return(tx.nLockTime); | |
11 | } | |
12 | return(0); | |
13 | } | |
14 | ||
15 | void komodo_disconnect(CBlockIndex *pindex,CBlock& block) | |
16 | { | |
17 | komodo_init(); | |
18 | //uint256 zero; | |
19 | //printf("disconnect ht.%d\n",pindex->nHeight); | |
20 | //memset(&zero,0,sizeof(zero)); | |
21 | //komodo_stateupdate(-pindex->nHeight,0,0,0,zero,0,0,0,0); | |
22 | } | |
23 | ||
24 | int32_t komodo_block2height(CBlock *block) | |
25 | { | |
26 | int32_t i,n,height = 0; uint8_t *ptr = (uint8_t *)block->vtx[0].vin[0].scriptSig.data(); | |
27 | komodo_init(); | |
28 | if ( block->vtx[0].vin[0].scriptSig.size() > 5 ) | |
29 | { | |
30 | //for (i=0; i<6; i++) | |
31 | // printf("%02x",ptr[i]); | |
32 | n = ptr[0]; | |
33 | for (i=0; i<n; i++) | |
34 | { | |
35 | //03bb81000101(bb 187) (81 48001) (00 12288256) <- coinbase.6 ht.12288256 | |
36 | height += ((uint32_t)ptr[i+1] << (i*8)); | |
37 | //printf("(%02x %x %d) ",ptr[i+1],((uint32_t)ptr[i+1] << (i*8)),height); | |
38 | } | |
39 | //printf(" <- coinbase.%d ht.%d\n",(int32_t)block->vtx[0].vin[0].scriptSig.size(),height); | |
40 | } | |
41 | return(height); | |
42 | } | |
43 | ||
44 | void komodo_block2pubkey33(uint8_t *pubkey33,CBlock& block) | |
45 | { | |
46 | uint8_t *ptr = (uint8_t *)block.vtx[0].vout[0].scriptPubKey.data(); | |
47 | komodo_init(); | |
48 | memcpy(pubkey33,ptr+1,33); | |
49 | } | |
50 | ||
51 | void komodo_index2pubkey33(uint8_t *pubkey33,CBlockIndex *pindex,int32_t height) | |
52 | { | |
53 | CBlock block; | |
54 | komodo_init(); | |
55 | memset(pubkey33,0,33); | |
56 | if ( pindex != 0 ) | |
57 | { | |
58 | if ( ReadBlockFromDisk(block,(const CBlockIndex *)pindex) != 0 ) | |
59 | { | |
60 | komodo_block2pubkey33(pubkey33,block); | |
61 | } | |
62 | } | |
63 | else | |
64 | { | |
65 | // height -> pubkey33 | |
66 | //printf("extending chaintip komodo_index2pubkey33 height.%d need to get pubkey33\n",height); | |
67 | } | |
68 | } | |
69 |