Post
Topic
Re: I can not parse files after blk00975.dat (Bitcoin Core)
by
jaruvido
on 13/06/2018, 13:56:37 UTC
I fall into this issue before but still cannot solve it.
I change the way to parse block data.

I got this explanation from https://github.com/bitcoin/bitcoin/blob/master/src/primitives/transaction.h


/ **
  * Basic transaction serialization format:
  * - int32_t nVersion
  * - std :: vector vin
  * - std :: vector vout
  * - uint32_t nLockTime
  *
  * Extended transaction serialization format:
  * - int32_t nVersion
  * - unsigned char dummy = 0x00
  * - unsigned char flags (! = 0)
  * - std :: vector vin
  * - std :: vector vout
  * - if (flags & 1):
  * - CTxWitness wit;
  * - uint32_t nLockTime
  * /

and from here https://bitcoin.stackexchange.com/questions/55232/parsing-a-segwit-transaction-what-is-the-size-of-witness-data/55234

for each input {
     stackItems = read integer
     if stackItems> 0 {
         for each stackItem {
             bytes = read integer
             // witness data is bytes long
         }
     }
}