It is known that historical database of all bitcoin transactions stored in blk*.dat files. Is it possible for bitcoin-core to change any of this files in any time? Or this database is equal for all bitcoin peers (may be except the last few files)?

I think this files consist non-changable historical data for blockchain. Is it true?


Yes, Bitcoin Core can and will change the blk*.dat files, which, as has been told to you many times before, can be different for all nodes. Once Bitcoin Core has validated a block, it updates its chainstate database so that it knows what its current blockchain tip is. It also updates that database with the most recent UTXO set. So once this is done, the block can be thrown away as we have now recorded that we validated it. This is what pruning does; it throws away old blocks that we have already validated. Having the correct chainstate (UTXO set and blockchain tip) is all that matters.

  • 1
    However, if pruning is not enabled, then AFAIK the most recent blk*.dat file is only appended to, and the older files are never changed at all. Is that correct? – Nate Eldredge Aug 30 '17 at 13:51
  • Yes. The files are append only. – Andrew Chow Aug 30 '17 at 13:52
  • @NateEldredge how to enable or disable prunning? – Denis Leonov Aug 30 '17 at 14:42
  • @Denis: It's disabled by default; see bitcoin.stackexchange.com/questions/37496/… for how to enable it. – Nate Eldredge Aug 30 '17 at 16:06
  • Bitcoin Core can change on-disk database. Malware? If need, I can prove it. Guys, don't be so homely. Answer to me. – Denis Leonov Jun 5 '18 at 4:16

Your Answer

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

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