Skip to content

Commit 57425a2

Browse files
committed
Check block header before accepting it.
Previously, AcceptBlockHeader did not check the header (in particular PoW). This made the client accept invalid-PoW-headers from peers in headers-first sync.
1 parent b5d1b10 commit 57425a2

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

src/main.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2280,6 +2280,8 @@ bool CheckBlock(const CBlock& block, CValidationState& state, bool fCheckPOW, bo
22802280
{
22812281
// These are checks that are independent of context.
22822282

2283+
// Check that the header is valid (particularly PoW). This is mostly
2284+
// redundant with the call in AcceptBlockHeader.
22832285
if (!CheckBlockHeader(block, state, fCheckPOW))
22842286
return false;
22852287

@@ -2351,6 +2353,9 @@ bool AcceptBlockHeader(const CBlockHeader& block, CValidationState& state, CBloc
23512353
return true;
23522354
}
23532355

2356+
if (!CheckBlockHeader(block, state))
2357+
return false;
2358+
23542359
// Get prev block index
23552360
CBlockIndex* pindexPrev = NULL;
23562361
int nHeight = 0;

0 commit comments

Comments
 (0)