<p>While running <code>bitcoind</code> 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 <code>bitcoin-cli</code>.</p>

<p>I'd prefer to err on the side of false positives (it's not corrupt but the test says it is corrupt) if necessary.</p>

CC BY-SA 3.0
2017-03-26T17:22:47.590Z
Reindexing with `bitcoind -reindex` should detect any corruption, but takes a long time.  In principle it should be sufficient to compute the hashes of all the blocks in the `blk*.dat` files and check that they all link together in a chain.
Nate Eldredge
CC BY-SA 3.0
2017-03-27T03:42:55.660Z
By 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
CC BY-SA 3.0
2017-03-27T06:29:58.390Z
@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 `-reindex` to 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
CC BY-SA 4.0
2018-06-20T06:34:45.523Z
@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
CC BY-SA 4.0
2018-06-20T20:17:22.347Z
@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
<blockchain><bitcoind>
Is there a robust way to test for a corrupted blockchain?
kobejohn
# Is there a robust way to test for a corrupted blockchain?

(Asked by: username_0 on 2017-03-26)

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.

**Tags:** blockchain, bitcoind

> **Comments:**
> **username_1**: Reindexing with `bitcoind -reindex` should detect any corruption, but takes a long time.  In principle it should be sufficient to compute the hashes of all the blocks in the `blk*.dat` files and check that they all link together in a chain.  
> **username_2**: By 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)?  
> **username_0**: @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 `-reindex` to 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.  
> **username_3**: @username_0: 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  
> **username_0**: @username_3 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.  

---

## 0 answers

