@@ -637,29 +637,29 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
637
637
// Basic checks that don't depend on any context
638
638
if (tx.vin .empty ())
639
639
return state.DoS (10 , error (" CheckTransaction() : vin empty" ),
640
- REJECT_INVALID, " vin empty" );
640
+ REJECT_INVALID, " bad-txns- vin- empty" );
641
641
if (tx.vout .empty ())
642
642
return state.DoS (10 , error (" CheckTransaction() : vout empty" ),
643
- REJECT_INVALID, " vout empty" );
643
+ REJECT_INVALID, " bad-txns- vout- empty" );
644
644
// Size limits
645
645
if (::GetSerializeSize (tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
646
646
return state.DoS (100 , error (" CheckTransaction() : size limits failed" ),
647
- REJECT_INVALID, " oversize" );
647
+ REJECT_INVALID, " bad-txns- oversize" );
648
648
649
649
// Check for negative or overflow output values
650
650
int64_t nValueOut = 0 ;
651
651
BOOST_FOREACH (const CTxOut& txout, tx.vout )
652
652
{
653
653
if (txout.nValue < 0 )
654
654
return state.DoS (100 , error (" CheckTransaction() : txout.nValue negative" ),
655
- REJECT_INVALID, " vout negative" );
655
+ REJECT_INVALID, " bad-txns- vout- negative" );
656
656
if (txout.nValue > MAX_MONEY)
657
657
return state.DoS (100 , error (" CheckTransaction() : txout.nValue too high" ),
658
- REJECT_INVALID, " vout too large " );
658
+ REJECT_INVALID, " bad-txns- vout-toolarge " );
659
659
nValueOut += txout.nValue ;
660
660
if (!MoneyRange (nValueOut))
661
661
return state.DoS (100 , error (" CheckTransaction() : txout total out of range" ),
662
- REJECT_INVALID, " txout total too large " );
662
+ REJECT_INVALID, " bad-txns-txouttotal-toolarge " );
663
663
}
664
664
665
665
// Check for duplicate inputs
@@ -668,22 +668,22 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
668
668
{
669
669
if (vInOutPoints.count (txin.prevout ))
670
670
return state.DoS (100 , error (" CheckTransaction() : duplicate inputs" ),
671
- REJECT_INVALID, " duplicate inputs" );
671
+ REJECT_INVALID, " bad-txns- inputs-duplicate " );
672
672
vInOutPoints.insert (txin.prevout );
673
673
}
674
674
675
675
if (tx.IsCoinBase ())
676
676
{
677
677
if (tx.vin [0 ].scriptSig .size () < 2 || tx.vin [0 ].scriptSig .size () > 100 )
678
678
return state.DoS (100 , error (" CheckTransaction() : coinbase script size" ),
679
- REJECT_INVALID, " coinbase script too large " );
679
+ REJECT_INVALID, " bad-cb-length " );
680
680
}
681
681
else
682
682
{
683
683
BOOST_FOREACH (const CTxIn& txin, tx.vin )
684
684
if (txin.prevout .IsNull ())
685
685
return state.DoS (10 , error (" CheckTransaction() : prevout is null" ),
686
- REJECT_INVALID, " prevout null" );
686
+ REJECT_INVALID, " bad-txns- prevout- null" );
687
687
}
688
688
689
689
return true ;
@@ -791,7 +791,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
791
791
// are the actual inputs available?
792
792
if (!view.HaveInputs (tx))
793
793
return state.Invalid (error (" AcceptToMemoryPool : inputs already spent" ),
794
- REJECT_DUPLICATE, " inputs spent" );
794
+ REJECT_DUPLICATE, " bad-txns- inputs- spent" );
795
795
796
796
// Bring the best block into scope
797
797
view.GetBestBlock ();
@@ -1410,30 +1410,30 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCach
1410
1410
if (nSpendHeight - coins.nHeight < COINBASE_MATURITY)
1411
1411
return state.Invalid (
1412
1412
error (" CheckInputs() : tried to spend coinbase at depth %d" , nSpendHeight - coins.nHeight ),
1413
- REJECT_INVALID, " premature spend of coinbase" );
1413
+ REJECT_INVALID, " bad-txns- premature- spend-of- coinbase" );
1414
1414
}
1415
1415
1416
1416
// Check for negative or overflow input values
1417
1417
nValueIn += coins.vout [prevout.n ].nValue ;
1418
1418
if (!MoneyRange (coins.vout [prevout.n ].nValue ) || !MoneyRange (nValueIn))
1419
1419
return state.DoS (100 , error (" CheckInputs() : txin values out of range" ),
1420
- REJECT_INVALID, " input values out of range " );
1420
+ REJECT_INVALID, " bad-txns-inputvalues-outofrange " );
1421
1421
1422
1422
}
1423
1423
1424
1424
if (nValueIn < tx.GetValueOut ())
1425
1425
return state.DoS (100 , error (" CheckInputs() : %s value in < value out" , tx.GetHash ().ToString ()),
1426
- REJECT_INVALID, " in < out " );
1426
+ REJECT_INVALID, " bad-txns-in-belowout " );
1427
1427
1428
1428
// Tally transaction fees
1429
1429
int64_t nTxFee = nValueIn - tx.GetValueOut ();
1430
1430
if (nTxFee < 0 )
1431
1431
return state.DoS (100 , error (" CheckInputs() : %s nTxFee < 0" , tx.GetHash ().ToString ()),
1432
- REJECT_INVALID, " fee < 0 " );
1432
+ REJECT_INVALID, " bad-txns- fee-negative " );
1433
1433
nFees += nTxFee;
1434
1434
if (!MoneyRange (nFees))
1435
1435
return state.DoS (100 , error (" CheckInputs() : nFees out of range" ),
1436
- REJECT_INVALID, " fee out of range " );
1436
+ REJECT_INVALID, " bad-txns- fee-outofrange " );
1437
1437
1438
1438
// The first loop above does all the inexpensive checks.
1439
1439
// Only if ALL inputs pass do we perform expensive ECDSA signature checks.
@@ -1630,7 +1630,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1630
1630
uint256 hash = block.GetTxHash (i);
1631
1631
if (view.HaveCoins (hash) && !view.GetCoins (hash).IsPruned ())
1632
1632
return state.DoS (100 , error (" ConnectBlock() : tried to overwrite transaction" ),
1633
- REJECT_INVALID, " BIP30" );
1633
+ REJECT_INVALID, " bad-txns- BIP30" );
1634
1634
}
1635
1635
}
1636
1636
@@ -1660,13 +1660,13 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1660
1660
nSigOps += GetLegacySigOpCount (tx);
1661
1661
if (nSigOps > MAX_BLOCK_SIGOPS)
1662
1662
return state.DoS (100 , error (" ConnectBlock() : too many sigops" ),
1663
- REJECT_INVALID, " too many sigops" );
1663
+ REJECT_INVALID, " bad-blk- sigops" );
1664
1664
1665
1665
if (!tx.IsCoinBase ())
1666
1666
{
1667
1667
if (!view.HaveInputs (tx))
1668
1668
return state.DoS (100 , error (" ConnectBlock() : inputs missing/spent" ),
1669
- REJECT_INVALID, " inputs missing/spent " );
1669
+ REJECT_INVALID, " bad-txns- inputs-missingorspent " );
1670
1670
1671
1671
if (fStrictPayToScriptHash )
1672
1672
{
@@ -1676,7 +1676,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1676
1676
nSigOps += GetP2SHSigOpCount (tx, view);
1677
1677
if (nSigOps > MAX_BLOCK_SIGOPS)
1678
1678
return state.DoS (100 , error (" ConnectBlock() : too many sigops" ),
1679
- REJECT_INVALID, " too many sigops" );
1679
+ REJECT_INVALID, " bad-blk- sigops" );
1680
1680
}
1681
1681
1682
1682
nFees += view.GetValueIn (tx)-tx.GetValueOut ();
@@ -1703,7 +1703,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1703
1703
return state.DoS (100 ,
1704
1704
error (" ConnectBlock() : coinbase pays too much (actual=%" PRId64" vs limit=%" PRId64" )" ,
1705
1705
block.vtx [0 ].GetValueOut (), GetBlockValue (pindex->nHeight , nFees)),
1706
- REJECT_INVALID, " coinbase too large " );
1706
+ REJECT_INVALID, " bad-cb-amount " );
1707
1707
1708
1708
if (!control.Wait ())
1709
1709
return state.DoS (100 , false );
@@ -1762,7 +1762,7 @@ bool static WriteChainState(CValidationState &state) {
1762
1762
// an overestimation, as most will delete an existing entry or
1763
1763
// overwrite one. Still, use a conservative safety factor of 2.
1764
1764
if (!CheckDiskSpace (100 * 2 * 2 * pcoinsTip->GetCacheSize ()))
1765
- return state.Error ();
1765
+ return state.Error (" out of disk space " );
1766
1766
FlushBlockFile ();
1767
1767
pblocktree->Sync ();
1768
1768
if (!pcoinsTip->Flush ())
@@ -1987,7 +1987,7 @@ bool AddToBlockIndex(CBlock& block, CValidationState& state, const CDiskBlockPos
1987
1987
// Check for duplicate
1988
1988
uint256 hash = block.GetHash ();
1989
1989
if (mapBlockIndex.count (hash))
1990
- return state.Invalid (error (" AddToBlockIndex() : %s already exists" , hash.ToString ()));
1990
+ return state.Invalid (error (" AddToBlockIndex() : %s already exists" , hash.ToString ()), 0 , " duplicate " );
1991
1991
1992
1992
// Construct new block index object
1993
1993
CBlockIndex* pindexNew = new CBlockIndex (block);
@@ -2082,7 +2082,7 @@ bool FindBlockPos(CValidationState &state, CDiskBlockPos &pos, unsigned int nAdd
2082
2082
}
2083
2083
}
2084
2084
else
2085
- return state.Error ();
2085
+ return state.Error (" out of disk space " );
2086
2086
}
2087
2087
}
2088
2088
@@ -2128,7 +2128,7 @@ bool FindUndoPos(CValidationState &state, int nFile, CDiskBlockPos &pos, unsigne
2128
2128
}
2129
2129
}
2130
2130
else
2131
- return state.Error ();
2131
+ return state.Error (" out of disk space " );
2132
2132
}
2133
2133
2134
2134
return true ;
@@ -2143,26 +2143,26 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2143
2143
// Size limits
2144
2144
if (block.vtx .empty () || block.vtx .size () > MAX_BLOCK_SIZE || ::GetSerializeSize (block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
2145
2145
return state.DoS (100 , error (" CheckBlock() : size limits failed" ),
2146
- REJECT_INVALID, " block size too large " );
2146
+ REJECT_INVALID, " bad-blk-length " );
2147
2147
2148
2148
// Check proof of work matches claimed amount
2149
2149
if (fCheckPOW && !CheckProofOfWork (block.GetHash (), block.nBits ))
2150
2150
return state.DoS (50 , error (" CheckBlock() : proof of work failed" ),
2151
- REJECT_INVALID, " invalid pow " );
2151
+ REJECT_INVALID, " high-hash " );
2152
2152
2153
2153
// Check timestamp
2154
2154
if (block.GetBlockTime () > GetAdjustedTime () + 2 * 60 * 60 )
2155
2155
return state.Invalid (error (" CheckBlock() : block timestamp too far in the future" ),
2156
- REJECT_INVALID, " time in future " );
2156
+ REJECT_INVALID, " time-too-new " );
2157
2157
2158
2158
// First transaction must be coinbase, the rest must not be
2159
2159
if (block.vtx .empty () || !block.vtx [0 ].IsCoinBase ())
2160
2160
return state.DoS (100 , error (" CheckBlock() : first tx is not coinbase" ),
2161
- REJECT_INVALID, " no coinbase " );
2161
+ REJECT_INVALID, " bad-cb-missing " );
2162
2162
for (unsigned int i = 1 ; i < block.vtx .size (); i++)
2163
2163
if (block.vtx [i].IsCoinBase ())
2164
2164
return state.DoS (100 , error (" CheckBlock() : more than one coinbase" ),
2165
- REJECT_INVALID, " duplicate coinbase " );
2165
+ REJECT_INVALID, " bad-cb-multiple " );
2166
2166
2167
2167
// Check transactions
2168
2168
BOOST_FOREACH (const CTransaction& tx, block.vtx )
@@ -2182,7 +2182,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2182
2182
}
2183
2183
if (uniqueTx.size () != block.vtx .size ())
2184
2184
return state.DoS (100 , error (" CheckBlock() : duplicate transaction" ),
2185
- REJECT_INVALID, " duplicate transaction " , true );
2185
+ REJECT_INVALID, " bad-txns- duplicate" , true );
2186
2186
2187
2187
unsigned int nSigOps = 0 ;
2188
2188
BOOST_FOREACH (const CTransaction& tx, block.vtx )
@@ -2191,12 +2191,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2191
2191
}
2192
2192
if (nSigOps > MAX_BLOCK_SIGOPS)
2193
2193
return state.DoS (100 , error (" CheckBlock() : out-of-bounds SigOpCount" ),
2194
- REJECT_INVALID, " sig op count " , true );
2194
+ REJECT_INVALID, " bad-blk-sigops " , true );
2195
2195
2196
2196
// Check merkle root
2197
2197
if (fCheckMerkleRoot && block.hashMerkleRoot != block.vMerkleTree .back ())
2198
2198
return state.DoS (100 , error (" CheckBlock() : hashMerkleRoot mismatch" ),
2199
- REJECT_INVALID, " bad merkle root " , true );
2199
+ REJECT_INVALID, " bad-txnmrklroot " , true );
2200
2200
2201
2201
return true ;
2202
2202
}
@@ -2206,33 +2206,33 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2206
2206
// Check for duplicate
2207
2207
uint256 hash = block.GetHash ();
2208
2208
if (mapBlockIndex.count (hash))
2209
- return state.Invalid (error (" AcceptBlock() : block already in mapBlockIndex" ));
2209
+ return state.Invalid (error (" AcceptBlock() : block already in mapBlockIndex" ), 0 , " duplicate " );
2210
2210
2211
2211
// Get prev block index
2212
2212
CBlockIndex* pindexPrev = NULL ;
2213
2213
int nHeight = 0 ;
2214
2214
if (hash != Params ().HashGenesisBlock ()) {
2215
2215
map<uint256, CBlockIndex*>::iterator mi = mapBlockIndex.find (block.hashPrevBlock );
2216
2216
if (mi == mapBlockIndex.end ())
2217
- return state.DoS (10 , error (" AcceptBlock() : prev block not found" ));
2217
+ return state.DoS (10 , error (" AcceptBlock() : prev block not found" ), 0 , " bad-prevblk " );
2218
2218
pindexPrev = (*mi).second ;
2219
2219
nHeight = pindexPrev->nHeight +1 ;
2220
2220
2221
2221
// Check proof of work
2222
2222
if (block.nBits != GetNextWorkRequired (pindexPrev, &block))
2223
2223
return state.DoS (100 , error (" AcceptBlock() : incorrect proof of work" ),
2224
- REJECT_INVALID, " bad pow " );
2224
+ REJECT_INVALID, " bad-diffbits " );
2225
2225
2226
2226
// Check timestamp against prev
2227
2227
if (block.GetBlockTime () <= pindexPrev->GetMedianTimePast ())
2228
2228
return state.Invalid (error (" AcceptBlock() : block's timestamp is too early" ),
2229
- REJECT_INVALID, " timestamp too early " );
2229
+ REJECT_INVALID, " time- too-old " );
2230
2230
2231
2231
// Check that all transactions are finalized
2232
2232
BOOST_FOREACH (const CTransaction& tx, block.vtx )
2233
2233
if (!IsFinalTx (tx, nHeight, block.GetBlockTime ()))
2234
2234
return state.DoS (10 , error (" AcceptBlock() : contains a non-final transaction" ),
2235
- REJECT_INVALID, " non-final tx " );
2235
+ REJECT_INVALID, " bad-txns-nonfinal " );
2236
2236
2237
2237
// Check that the block chain matches the known block chain up to a checkpoint
2238
2238
if (!Checkpoints::CheckBlock (nHeight, hash))
@@ -2246,7 +2246,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2246
2246
(TestNet () && CBlockIndex::IsSuperMajority (2 , pindexPrev, 75 , 100 )))
2247
2247
{
2248
2248
return state.Invalid (error (" AcceptBlock() : rejected nVersion=1 block" ),
2249
- REJECT_OBSOLETE, " version 1 blocks obsolete " );
2249
+ REJECT_OBSOLETE, " bad- version" );
2250
2250
}
2251
2251
}
2252
2252
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
@@ -2260,7 +2260,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2260
2260
if (block.vtx [0 ].vin [0 ].scriptSig .size () < expect.size () ||
2261
2261
!std::equal (expect.begin (), expect.end (), block.vtx [0 ].vin [0 ].scriptSig .begin ()))
2262
2262
return state.DoS (100 , error (" AcceptBlock() : block height mismatch in coinbase" ),
2263
- REJECT_INVALID, " height incorrect in coinbase " );
2263
+ REJECT_INVALID, " bad-cb- height" );
2264
2264
}
2265
2265
}
2266
2266
}
@@ -2337,9 +2337,9 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
2337
2337
// Check for duplicate
2338
2338
uint256 hash = pblock->GetHash ();
2339
2339
if (mapBlockIndex.count (hash))
2340
- return state.Invalid (error (" ProcessBlock() : already have block %d %s" , mapBlockIndex[hash]->nHeight , hash.ToString ()));
2340
+ return state.Invalid (error (" ProcessBlock() : already have block %d %s" , mapBlockIndex[hash]->nHeight , hash.ToString ()), 0 , " duplicate " );
2341
2341
if (mapOrphanBlocks.count (hash))
2342
- return state.Invalid (error (" ProcessBlock() : already have block (orphan) %s" , hash.ToString ()));
2342
+ return state.Invalid (error (" ProcessBlock() : already have block (orphan) %s" , hash.ToString ()), 0 , " duplicate " );
2343
2343
2344
2344
// Preliminary checks
2345
2345
if (!CheckBlock (*pblock, state)) {
@@ -2356,7 +2356,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
2356
2356
if (deltaTime < 0 )
2357
2357
{
2358
2358
return state.DoS (100 , error (" ProcessBlock() : block with timestamp before last checkpoint" ),
2359
- REJECT_CHECKPOINT, " timestamp before checkpoint " );
2359
+ REJECT_CHECKPOINT, " time-too-old " );
2360
2360
}
2361
2361
CBigNum bnNewBlock;
2362
2362
bnNewBlock.SetCompact (pblock->nBits );
@@ -2365,7 +2365,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
2365
2365
if (bnNewBlock > bnRequired)
2366
2366
{
2367
2367
return state.DoS (100 , error (" ProcessBlock() : block with too little proof-of-work" ),
2368
- REJECT_INVALID, " invalid pow " );
2368
+ REJECT_INVALID, " bad-diffbits " );
2369
2369
}
2370
2370
}
2371
2371
0 commit comments