Bitcoin Forum
September 27, 2018, 11:22:56 PM *
News: ♦♦ New info! Bitcoin Core users absolutely must upgrade to previously-announced 0.16.3 [Torrent]. All Bitcoin users should temporarily trust confirmations slightly less. More info.
 
   Home   Help Search Donate Login Register  
Pages: [1]
  Print  
Author Topic: parsing leveldb txindex  (Read 423 times)
ivoras
Newbie
*
Offline Offline

Activity: 5
Merit: 0


View Profile
May 25, 2015, 10:41:14 PM
 #1

I'm trying to parse the LevelDB txindex, i.e. fetch raw transaction data given a transaction hash.

I'm reading a key-value pair from LevelDB with 't' + hash_bytes, and e.g. for transaction 444b7ecbda319e184da1a3d68968e6e0ca9346ddcf7afd0e2b887a7949128805 the key's value is

80 58 8f c4 c8 66 80 9b 24

Now, if I'm reading the bitcoin source correctly, this should be three varints:

  • nFile
  • nPos
  • nTxOffset

If I'm correctly decoding them, the 3 values are: 216 34694374 20004 -- which looks good. However, the data at offset 34694374 + 20004 in file 216 is unexpected:

version: 4293214589
inCount: 93952409796607

It looks like either I'm decoding the varints the wrong way or I'm calculating the file offset wrongly?

The varint read+decode code is mostly a direct port from C:

Code:
  def varint(s):
      n = 0
      while True:
          ch = read1(s)
          n = (n << 7) | (ch & 0x7f)
          if ch & 0x80:
              n += 1
          else:
              return n
Pages: [1]
  Print  
 
Jump to:  

Sponsored by , a Bitcoin-accepting VPN.
Powered by MySQL Powered by PHP Powered by SMF 1.1.19 | SMF © 2006-2009, Simple Machines Valid XHTML 1.0! Valid CSS!