diff --git a/src/main.cpp b/src/main.cpp index 06fea7446e..972ea3de06 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -362,7 +362,7 @@ bool CTxOut::IsDust() const bool CTransaction::IsStandard(string& strReason) const { - if (nVersion > CTransaction::CURRENT_VERSION) { + if (nVersion > CTransaction::CURRENT_VERSION || nVersion < 1) { strReason = "version"; return false; } @@ -1513,6 +1513,11 @@ bool CBlock::DisconnectBlock(CValidationState &state, CBlockIndex *pindex, CCoin CCoins &outs = view.GetCoins(hash); CCoins outsBlock = CCoins(tx, pindex->nHeight); + // The CCoins serialization does not serialize negative numbers. + // No network rules currently depend on the version here, so an inconsistency is harmless + // but it must be corrected before txout nversion ever influences a network rule. + if (outsBlock.nVersion < 0) + outs.nVersion = outsBlock.nVersion; if (outs != outsBlock) fClean = fClean && error("DisconnectBlock() : added transaction mismatch? database corrupted");