@@ -605,29 +605,29 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
605
605
// Basic checks that don't depend on any context
606
606
if (tx.vin .empty ())
607
607
return state.DoS (10 , error (" CheckTransaction() : vin empty" ),
608
- REJECT_INVALID, " vin empty" );
608
+ REJECT_INVALID, " bad-txns- vin- empty" );
609
609
if (tx.vout .empty ())
610
610
return state.DoS (10 , error (" CheckTransaction() : vout empty" ),
611
- REJECT_INVALID, " vout empty" );
611
+ REJECT_INVALID, " bad-txns- vout- empty" );
612
612
// Size limits
613
613
if (::GetSerializeSize (tx, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
614
614
return state.DoS (100 , error (" CheckTransaction() : size limits failed" ),
615
- REJECT_INVALID, " oversize" );
615
+ REJECT_INVALID, " bad-txns- oversize" );
616
616
617
617
// Check for negative or overflow output values
618
618
int64_t nValueOut = 0 ;
619
619
BOOST_FOREACH (const CTxOut& txout, tx.vout )
620
620
{
621
621
if (txout.nValue < 0 )
622
622
return state.DoS (100 , error (" CheckTransaction() : txout.nValue negative" ),
623
- REJECT_INVALID, " vout negative" );
623
+ REJECT_INVALID, " bad-txns- vout- negative" );
624
624
if (txout.nValue > MAX_MONEY)
625
625
return state.DoS (100 , error (" CheckTransaction() : txout.nValue too high" ),
626
- REJECT_INVALID, " vout too large " );
626
+ REJECT_INVALID, " bad-txns- vout-toolarge " );
627
627
nValueOut += txout.nValue ;
628
628
if (!MoneyRange (nValueOut))
629
629
return state.DoS (100 , error (" CheckTransaction() : txout total out of range" ),
630
- REJECT_INVALID, " txout total too large " );
630
+ REJECT_INVALID, " bad-txns-txouttotal-toolarge " );
631
631
}
632
632
633
633
// Check for duplicate inputs
@@ -636,22 +636,22 @@ bool CheckTransaction(const CTransaction& tx, CValidationState &state)
636
636
{
637
637
if (vInOutPoints.count (txin.prevout ))
638
638
return state.DoS (100 , error (" CheckTransaction() : duplicate inputs" ),
639
- REJECT_INVALID, " duplicate inputs" );
639
+ REJECT_INVALID, " bad-txns- inputs-duplicate " );
640
640
vInOutPoints.insert (txin.prevout );
641
641
}
642
642
643
643
if (tx.IsCoinBase ())
644
644
{
645
645
if (tx.vin [0 ].scriptSig .size () < 2 || tx.vin [0 ].scriptSig .size () > 100 )
646
646
return state.DoS (100 , error (" CheckTransaction() : coinbase script size" ),
647
- REJECT_INVALID, " coinbase script too large " );
647
+ REJECT_INVALID, " bad-cb-length " );
648
648
}
649
649
else
650
650
{
651
651
BOOST_FOREACH (const CTxIn& txin, tx.vin )
652
652
if (txin.prevout .IsNull ())
653
653
return state.DoS (10 , error (" CheckTransaction() : prevout is null" ),
654
- REJECT_INVALID, " prevout null" );
654
+ REJECT_INVALID, " bad-txns- prevout- null" );
655
655
}
656
656
657
657
return true ;
@@ -759,7 +759,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
759
759
// are the actual inputs available?
760
760
if (!view.HaveInputs (tx))
761
761
return state.Invalid (error (" AcceptToMemoryPool : inputs already spent" ),
762
- REJECT_DUPLICATE, " inputs spent" );
762
+ REJECT_DUPLICATE, " bad-txns- inputs- spent" );
763
763
764
764
// Bring the best block into scope
765
765
view.GetBestBlock ();
@@ -1404,30 +1404,30 @@ bool CheckInputs(const CTransaction& tx, CValidationState &state, CCoinsViewCach
1404
1404
if (nSpendHeight - coins.nHeight < COINBASE_MATURITY)
1405
1405
return state.Invalid (
1406
1406
error (" CheckInputs() : tried to spend coinbase at depth %d" , nSpendHeight - coins.nHeight ),
1407
- REJECT_INVALID, " premature spend of coinbase" );
1407
+ REJECT_INVALID, " bad-txns- premature- spend-of- coinbase" );
1408
1408
}
1409
1409
1410
1410
// Check for negative or overflow input values
1411
1411
nValueIn += coins.vout [prevout.n ].nValue ;
1412
1412
if (!MoneyRange (coins.vout [prevout.n ].nValue ) || !MoneyRange (nValueIn))
1413
1413
return state.DoS (100 , error (" CheckInputs() : txin values out of range" ),
1414
- REJECT_INVALID, " input values out of range " );
1414
+ REJECT_INVALID, " bad-txns-inputvalues-outofrange " );
1415
1415
1416
1416
}
1417
1417
1418
1418
if (nValueIn < tx.GetValueOut ())
1419
1419
return state.DoS (100 , error (" CheckInputs() : %s value in < value out" , tx.GetHash ().ToString ()),
1420
- REJECT_INVALID, " in < out " );
1420
+ REJECT_INVALID, " bad-txns-in-belowout " );
1421
1421
1422
1422
// Tally transaction fees
1423
1423
int64_t nTxFee = nValueIn - tx.GetValueOut ();
1424
1424
if (nTxFee < 0 )
1425
1425
return state.DoS (100 , error (" CheckInputs() : %s nTxFee < 0" , tx.GetHash ().ToString ()),
1426
- REJECT_INVALID, " fee < 0 " );
1426
+ REJECT_INVALID, " bad-txns- fee-negative " );
1427
1427
nFees += nTxFee;
1428
1428
if (!MoneyRange (nFees))
1429
1429
return state.DoS (100 , error (" CheckInputs() : nFees out of range" ),
1430
- REJECT_INVALID, " fee out of range " );
1430
+ REJECT_INVALID, " bad-txns- fee-outofrange " );
1431
1431
1432
1432
// The first loop above does all the inexpensive checks.
1433
1433
// Only if ALL inputs pass do we perform expensive ECDSA signature checks.
@@ -1624,7 +1624,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1624
1624
uint256 hash = block.GetTxHash (i);
1625
1625
if (view.HaveCoins (hash) && !view.GetCoins (hash).IsPruned ())
1626
1626
return state.DoS (100 , error (" ConnectBlock() : tried to overwrite transaction" ),
1627
- REJECT_INVALID, " BIP30" );
1627
+ REJECT_INVALID, " bad-txns- BIP30" );
1628
1628
}
1629
1629
}
1630
1630
@@ -1654,13 +1654,13 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1654
1654
nSigOps += GetLegacySigOpCount (tx);
1655
1655
if (nSigOps > MAX_BLOCK_SIGOPS)
1656
1656
return state.DoS (100 , error (" ConnectBlock() : too many sigops" ),
1657
- REJECT_INVALID, " too many sigops" );
1657
+ REJECT_INVALID, " bad-blk- sigops" );
1658
1658
1659
1659
if (!tx.IsCoinBase ())
1660
1660
{
1661
1661
if (!view.HaveInputs (tx))
1662
1662
return state.DoS (100 , error (" ConnectBlock() : inputs missing/spent" ),
1663
- REJECT_INVALID, " inputs missing/spent " );
1663
+ REJECT_INVALID, " bad-txns- inputs-missingorspent " );
1664
1664
1665
1665
if (fStrictPayToScriptHash )
1666
1666
{
@@ -1670,7 +1670,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1670
1670
nSigOps += GetP2SHSigOpCount (tx, view);
1671
1671
if (nSigOps > MAX_BLOCK_SIGOPS)
1672
1672
return state.DoS (100 , error (" ConnectBlock() : too many sigops" ),
1673
- REJECT_INVALID, " too many sigops" );
1673
+ REJECT_INVALID, " bad-blk- sigops" );
1674
1674
}
1675
1675
1676
1676
nFees += view.GetValueIn (tx)-tx.GetValueOut ();
@@ -1697,7 +1697,7 @@ bool ConnectBlock(CBlock& block, CValidationState& state, CBlockIndex* pindex, C
1697
1697
return state.DoS (100 ,
1698
1698
error (" ConnectBlock() : coinbase pays too much (actual=%" PRId64" vs limit=%" PRId64" )" ,
1699
1699
block.vtx [0 ].GetValueOut (), GetBlockValue (pindex->nHeight , nFees)),
1700
- REJECT_INVALID, " coinbase too large " );
1700
+ REJECT_INVALID, " bad-cb-amount " );
1701
1701
1702
1702
if (!control.Wait ())
1703
1703
return state.DoS (100 , false );
@@ -2075,26 +2075,26 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2075
2075
// Size limits
2076
2076
if (block.vtx .empty () || block.vtx .size () > MAX_BLOCK_SIZE || ::GetSerializeSize (block, SER_NETWORK, PROTOCOL_VERSION) > MAX_BLOCK_SIZE)
2077
2077
return state.DoS (100 , error (" CheckBlock() : size limits failed" ),
2078
- REJECT_INVALID, " block size too large " );
2078
+ REJECT_INVALID, " bad-blk-length " );
2079
2079
2080
2080
// Check proof of work matches claimed amount
2081
2081
if (fCheckPOW && !CheckProofOfWork (block.GetHash (), block.nBits ))
2082
2082
return state.DoS (50 , error (" CheckBlock() : proof of work failed" ),
2083
- REJECT_INVALID, " invalid pow " );
2083
+ REJECT_INVALID, " high-hash " );
2084
2084
2085
2085
// Check timestamp
2086
2086
if (block.GetBlockTime () > GetAdjustedTime () + 2 * 60 * 60 )
2087
2087
return state.Invalid (error (" CheckBlock() : block timestamp too far in the future" ),
2088
- REJECT_INVALID, " time in future " );
2088
+ REJECT_INVALID, " time-too-new " );
2089
2089
2090
2090
// First transaction must be coinbase, the rest must not be
2091
2091
if (block.vtx .empty () || !block.vtx [0 ].IsCoinBase ())
2092
2092
return state.DoS (100 , error (" CheckBlock() : first tx is not coinbase" ),
2093
- REJECT_INVALID, " no coinbase " );
2093
+ REJECT_INVALID, " bad-cb-missing " );
2094
2094
for (unsigned int i = 1 ; i < block.vtx .size (); i++)
2095
2095
if (block.vtx [i].IsCoinBase ())
2096
2096
return state.DoS (100 , error (" CheckBlock() : more than one coinbase" ),
2097
- REJECT_INVALID, " duplicate coinbase " );
2097
+ REJECT_INVALID, " bad-cb-multiple " );
2098
2098
2099
2099
// Check transactions
2100
2100
BOOST_FOREACH (const CTransaction& tx, block.vtx )
@@ -2114,7 +2114,7 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2114
2114
}
2115
2115
if (uniqueTx.size () != block.vtx .size ())
2116
2116
return state.DoS (100 , error (" CheckBlock() : duplicate transaction" ),
2117
- REJECT_INVALID, " duplicate transaction " , true );
2117
+ REJECT_INVALID, " bad-txns- duplicate" , true );
2118
2118
2119
2119
unsigned int nSigOps = 0 ;
2120
2120
BOOST_FOREACH (const CTransaction& tx, block.vtx )
@@ -2123,12 +2123,12 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
2123
2123
}
2124
2124
if (nSigOps > MAX_BLOCK_SIGOPS)
2125
2125
return state.DoS (100 , error (" CheckBlock() : out-of-bounds SigOpCount" ),
2126
- REJECT_INVALID, " sig op count " , true );
2126
+ REJECT_INVALID, " bad-blk-sigops " , true );
2127
2127
2128
2128
// Check merkle root
2129
2129
if (fCheckMerkleRoot && block.hashMerkleRoot != block.vMerkleTree .back ())
2130
2130
return state.DoS (100 , error (" CheckBlock() : hashMerkleRoot mismatch" ),
2131
- REJECT_INVALID, " bad merkle root " , true );
2131
+ REJECT_INVALID, " bad-txnmrklroot " , true );
2132
2132
2133
2133
return true ;
2134
2134
}
@@ -2153,18 +2153,18 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2153
2153
// Check proof of work
2154
2154
if (block.nBits != GetNextWorkRequired (pindexPrev, &block))
2155
2155
return state.DoS (100 , error (" AcceptBlock() : incorrect proof of work" ),
2156
- REJECT_INVALID, " bad pow " );
2156
+ REJECT_INVALID, " bad-diffbits " );
2157
2157
2158
2158
// Check timestamp against prev
2159
2159
if (block.GetBlockTime () <= pindexPrev->GetMedianTimePast ())
2160
2160
return state.Invalid (error (" AcceptBlock() : block's timestamp is too early" ),
2161
- REJECT_INVALID, " timestamp too early " );
2161
+ REJECT_INVALID, " time- too-old " );
2162
2162
2163
2163
// Check that all transactions are finalized
2164
2164
BOOST_FOREACH (const CTransaction& tx, block.vtx )
2165
2165
if (!IsFinalTx (tx, nHeight, block.GetBlockTime ()))
2166
2166
return state.DoS (10 , error (" AcceptBlock() : contains a non-final transaction" ),
2167
- REJECT_INVALID, " non-final tx " );
2167
+ REJECT_INVALID, " bad-txns-nonfinal " );
2168
2168
2169
2169
// Check that the block chain matches the known block chain up to a checkpoint
2170
2170
if (!Checkpoints::CheckBlock (nHeight, hash))
@@ -2178,7 +2178,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2178
2178
(TestNet () && CBlockIndex::IsSuperMajority (2 , pindexPrev, 75 , 100 )))
2179
2179
{
2180
2180
return state.Invalid (error (" AcceptBlock() : rejected nVersion=1 block" ),
2181
- REJECT_OBSOLETE, " version 1 blocks obsolete " );
2181
+ REJECT_OBSOLETE, " bad- version" );
2182
2182
}
2183
2183
}
2184
2184
// Enforce block.nVersion=2 rule that the coinbase starts with serialized block height
@@ -2192,7 +2192,7 @@ bool AcceptBlock(CBlock& block, CValidationState& state, CDiskBlockPos* dbp)
2192
2192
if (block.vtx [0 ].vin [0 ].scriptSig .size () < expect.size () ||
2193
2193
!std::equal (expect.begin (), expect.end (), block.vtx [0 ].vin [0 ].scriptSig .begin ()))
2194
2194
return state.DoS (100 , error (" AcceptBlock() : block height mismatch in coinbase" ),
2195
- REJECT_INVALID, " height incorrect in coinbase " );
2195
+ REJECT_INVALID, " bad-cb- height" );
2196
2196
}
2197
2197
}
2198
2198
}
@@ -2285,7 +2285,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
2285
2285
if (deltaTime < 0 )
2286
2286
{
2287
2287
return state.DoS (100 , error (" ProcessBlock() : block with timestamp before last checkpoint" ),
2288
- REJECT_CHECKPOINT, " timestamp before checkpoint " );
2288
+ REJECT_CHECKPOINT, " time-too-old " );
2289
2289
}
2290
2290
CBigNum bnNewBlock;
2291
2291
bnNewBlock.SetCompact (pblock->nBits );
@@ -2294,7 +2294,7 @@ bool ProcessBlock(CValidationState &state, CNode* pfrom, CBlock* pblock, CDiskBl
2294
2294
if (bnNewBlock > bnRequired)
2295
2295
{
2296
2296
return state.DoS (100 , error (" ProcessBlock() : block with too little proof-of-work" ),
2297
- REJECT_INVALID, " invalid pow " );
2297
+ REJECT_INVALID, " bad-diffbits " );
2298
2298
}
2299
2299
}
2300
2300
0 commit comments