This is a follow-up question for rev.dat file format

Pieter Wuille gave a great explanation that is easy to follow. Since that posting there was a replacement of CTxInUndo with Coin, does the format still stands for the CBlockUndo record?

  • 4 bytes: network magic (0xf9,0xbe,0xb4,0xd9)
  • 4 bytes: size of the CBlockUndo record (LE32)
  • data_size bytes: CBlockUndo record
  • 32 bytes: double-SHA256 of the serialized CBlockUndo record

CBlockUndo results in a serialized vector of CTxUndo records. Which is right now the serialized vector of Coin records.

And here is the Coin (or at least how I get it right now):

  • varint that is serialized: 2*height (+1 if it was a coinbase output): the height of the block that created the spent UTXO. By the way, is uint32_t{2} the same as (uint32_t)2 in TxInUndoFormatter varint Serialize
  • version dummy value 0: we do not use version anymore but for compatibility using a 0000 or zero value in here
  • CompressedAmount: spent UTXO's nValue
  • CompressedScript: spent UTXO's scriptPubKey


  1. Is it correct?
  2. Does anyone by any chance have a detailed mind map of undo process and a byte format map for the CBlockUndo record?

Just for reference, I draw some image of current v0.19 and previous v0.13 versions of rev*.dat file: enter image description here

enter image description here

  • There have not been any format changes in 0.19 as far as I know. There last was a backward-compatible change in 0.15. – Pieter Wuille May 1 at 1:41
  • Thank you for responding. So we can use the format that you described earlier and my pic of v0.19 is correct? – Vlad Proskurin May 1 at 2:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.