I've been looking at the on disk structured generated by the standard bitcoin-qt client. It looks to me that the rev?????.dat files are reverse application for blocks? So I imagine every single spent output is added to the reverse dat, so that they can be applied directly to the unspent pool during a rewind?

What exactly is stored, and what is the format?

1 Answer 1


Indeed, you can consider transactions to be 'patches' against the set of unspent outputs (the UTXO set): they consume some outputs, and they create some new outputs. Blocks are aggregated patches.

And indeed, to be able to undo the effects of a block on the UTXO set, a record with the reverse patch is written to the rev*.dat files (corresponding to the blocks in the same blk*.dat file).

The format is custom and very compact. For every transaction input (excluding the coinbase's, which does not spend anything) it contains the script and amount of the output being spent and whether it was created by a coinbase. If the output was the last of a particular transaction being spent, the transaction version and height in the chain it was created at are also stored.

  • I'm going to accept this answer, but I was hoping for more detail on the format itself. It seems spectacularly compact, at roughly 18 megs~ per file that seems like far less than would be necessary to revert a lot of one meg blocks. Unless I misunderstood and the rev patch doesn't rewind a block as a single block at a time but instead rewinds in a single patch N blocks back then forward applies the correct chain?
    – Matt
    Commented Nov 26, 2014 at 16:59
  • No, it contains one record per block, which is individually applied when rolling back. Commented Nov 26, 2014 at 17:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.