diff --git a/src/chainparams.cpp b/src/chainparams.cpp index 651899e542..b8ad8d5936 100644 --- a/src/chainparams.cpp +++ b/src/chainparams.cpp @@ -124,8 +124,7 @@ public: nTargetSpacing = 10 * 60; /** - * Build the genesis block. Note that the output of the genesis coinbase cannot - * be spent as it did not originally exist in the database. + * Build the genesis block. * * CBlock(hash=000000000019d6, ver=1, hashPrevBlock=00000000000000, hashMerkleRoot=4a5e1e, nTime=1231006505, nBits=1d00ffff, nNonce=2083236893, vtx=1) * CTransaction(hash=4a5e1e, ver=1, vin.size=1, vout.size=1, nLockTime=0) diff --git a/src/coins.cpp b/src/coins.cpp index 5765bb66d8..442b1d6d72 100644 --- a/src/coins.cpp +++ b/src/coins.cpp @@ -40,7 +40,7 @@ bool CCoins::Spend(const COutPoint &out, CTxInUndo &undo) { vout[out.n].SetNull(); Cleanup(); if (vout.size() == 0) { - undo.nHeight = nHeight; + undo.nHeight = nHeight + 1; undo.fCoinBase = fCoinBase; undo.nVersion = this->nVersion; } diff --git a/src/main.cpp b/src/main.cpp index 5f6f1b2e28..dbf8d75482 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1696,7 +1696,7 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex fClean = fClean && error("DisconnectBlock() : undo data overwriting existing transaction"); coins->Clear(); coins->fCoinBase = undo.fCoinBase; - coins->nHeight = undo.nHeight; + coins->nHeight = undo.nHeight - 1; coins->nVersion = undo.nVersion; } else { if (coins->IsPruned()) @@ -1788,10 +1788,10 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin // Special case for the genesis block, skipping connection of its transactions // (its coinbase is unspendable) - if (block.GetHash() == Params().HashGenesisBlock()) { + /*if (block.GetHash() == Params().HashGenesisBlock()) { view.SetBestBlock(pindex->GetBlockHash()); return true; - } + }*/ bool fScriptChecks = pindex->nHeight >= Checkpoints::GetTotalBlocksEstimate(); @@ -2015,7 +2015,7 @@ bool ConnectBlock(const CBlock& block, CValidationState& state, CBlockIndex* pin CDiskBlockPos pos; if (!FindUndoPos(state, pindex->nFile, pos, ::GetSerializeSize(blockundo, SER_DISK, CLIENT_VERSION) + 40)) return error("ConnectBlock() : FindUndoPos failed"); - if (!blockundo.WriteToDisk(pos, pindex->pprev->GetBlockHash())) + if (!blockundo.WriteToDisk(pos, pindex->pprev == NULL ? 0 : pindex->pprev->GetBlockHash())) return state.Abort("Failed to write undo data"); // update nUndoPos in block index @@ -3262,7 +3262,7 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth { boost::this_thread::interruption_point(); uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))))); - if (pindex->nHeight < chainActive.Height()-nCheckDepth) + if (pindex->nHeight < chainActive.Height()-nCheckDepth || pindex->nHeight == 0) break; CBlock block; // check level 0: read from disk