2
While running bitcoind I once had the blockchain get corrupted and it manifested as a non-obvious error message which unfortunately I can't remember. I would like to know if there is a robust way to check that the blockchain has been corrupted, preferably using a standard tool such as bitcoin-cli.
I'd prefer to err on the side of false positives (it's not corrupt but the test says it is corrupt) if necessary.
Reindexing with
bitcoind -reindexshould detect any corruption, but takes a long time. In principle it should be sufficient to compute the hashes of all the blocks in theblk*.datfiles and check that they all link together in a chain. – Nate Eldredge – 2017-03-26T17:22:47.590By corrupted blockchain, do you mean that literally the blocks on disk are corrupted (uncommon) or that Bitcoin Core's database was in an inconsistent state (common)? – Pieter Wuille – 2017-03-27T03:42:55.660
@PieterWuille I'm sorry I'm not sure. At the time I looked up the error and found that it likely indicated a "corrupt" blockchain. I did not look into it further and simply used
-reindexto rebuild and it worked after that. If the common case is an inconsistent state, then I guess that is what I would want to check for. – kobejohn – 2017-03-27T06:29:58.390@kobejohn: You got any solution for the same because I am facing the same issue and tried for reindexing but after 91% reindex the same error came again – Codebrekers – 2018-06-20T06:34:45.523
@Codebrekers Unfortunately I do not. I put that project on hold so I did not work on it. If I were going to, I would probably try an alternate implementation like BitPrim to see if it is more reliable. – kobejohn – 2018-06-20T20:17:22.347