TeachMeBitcoin

The Vigilance of the Vault: Auditing with `verifychain`

From TeachMeBitcoin, the free encyclopedia Reading time: 2 min

The Vigilance of the Vault: Auditing with verifychain

In the world of Bitcoin, "Don't Trust, Verify" is not just a slogan; it's a "Lifestyle." Even if your node has been running for years, you might want to perform a "Deep Audit" of your own local records. This is the job of verifychain. it is the "Vigilance of the Vault," the "Self-Audit" of the Librarian.

It scans the local block files and re-verifies the math, the signatures, and the links. It is the "Price of Certainty" in a world of digital entropy.

Analyzing the "Auditor" Code

In the source code (src/rpc/blockchain.cpp), verifychain allows you to set the "Intensity" of the audit.

/**
 * This function triggers a manual re-verification of the local data.
 * It is the "Audit of the Librarian."
 */
static RPCMethod verifychain()
{
 return RPCMethod{"verifychain",
 "Verifies blockchain database.\n",
 {
 {"checklevel", RPCArg::Type::NUM, RPCArg::Default{3}, "0=minimal, 4=full signature check"},
 {"nblocks", RPCArg::Type::NUM, RPCArg::Default{6}, "Number of blocks to check back"},
 },
 // ... (Example omitted)
 [](const RPCMethod& self, const JSONRPCRequest& request) -> UniValue
{
 int level = request.params[0].isNull() ? 3 : request.params[0].getInt<int>();
 int depth = request.params[1].isNull() ? 6 : request.params[1].getInt<int>();

 ChainstateManager& chainman = EnsureAnyChainman(request.context);
 LOCK(cs_main);

 CVerifyDB vdb;
 return vdb.VerifyDB(chainman.ActiveChainstate(), chainman.GetConsensus(), chainman.ActiveChainstate().CoinsTip(), level, depth);
}

Explaining the Audit Levels to a Non-Coder


☕ Help support TeachMeBitcoin

TeachMeBitcoin is an ad-free, open-source educational repository curated by a passionate team of Bitcoin researchers and educators for public benefit. If you found our articles helpful, please consider supporting our hosting and ongoing content updates with a clean donation:

Ethereum: 0x578417C51783663D8A6A811B3544E1f779D39A85
Bitcoin: bc1q77k9e95rn669kpzyjr8ke9w95zhk7pa5s63qzz
Solana: 4ycT2ayqeMucixj3wS8Ay8Tq9NRDYRPKYbj3UGESyQ4J
Address copied to clipboard!