aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorGregory Maxwell <greg@xiph.org>2013-09-10 16:07:34 -0700
committerGregory Maxwell <greg@xiph.org>2013-09-10 16:07:34 -0700
commit85311c1ef8b438a93ecf04c100e877fb49634a90 (patch)
tree7ef00e3a06fe4b1afe8cce672c468f40ec01de33 /src
parent2bc004c658ab14f1708a40e1e15536d00553d50d (diff)
parentf8b7aa862519ab2efd1ce327d2ed4bea1325dc11 (diff)
downloadbitcoin-85311c1ef8b438a93ecf04c100e877fb49634a90.tar.xz
Merge pull request #2982 from gmaxwell/20130908_ccoins_corrupt
Longer term workaround for chainstate corruption from negative versions.
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/main.cpp b/src/main.cpp
index 89761dc2b3..4b2c32e345 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -466,7 +466,7 @@ unsigned int LimitOrphanTxSize(unsigned int nMaxOrphans)
bool IsStandardTx(const CTransaction& tx, string& reason)
{
- if (tx.nVersion > CTransaction::CURRENT_VERSION) {
+ if (tx.nVersion > CTransaction::CURRENT_VERSION || tx.nVersion < 1) {
reason = "version";
return false;
}
@@ -1778,6 +1778,11 @@ bool DisconnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex
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");