Skip to content

Commit 1fa9a9e

Browse files
authored
Merge pull request #1643 from evoskuil/master
Move malleated check into block.check (for ec resolution).
2 parents fcc210d + d0c10c0 commit 1fa9a9e

2 files changed

Lines changed: 10 additions & 6 deletions

File tree

include/bitcoin/system/chain/block.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ class BC_API block
149149
block(const chain::header::cptr& header,
150150
const chain::transactions_cptr& txs, bool valid) NOEXCEPT;
151151

152+
code check_with_malleated() const NOEXCEPT;
152153
size_t malleated32_size() const NOEXCEPT;
153154
bool is_malleated32(size_t width) const NOEXCEPT;
154155
static constexpr bool is_malleable32(size_t set, size_t width) NOEXCEPT

src/chain/block.cpp

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -884,22 +884,25 @@ code block::identify(const context& ctx) const NOEXCEPT
884884
// In the case of validation failure
885885
// The block header is checked/accepted independently.
886886

887-
// TODO: use of get_hash() in is_forward_reference makes this thread unsafe.
887+
// TODO: use of get_hash() in is_forward_reference makes this thread-unsafe.
888888
code block::check() const NOEXCEPT
889889
{
890890
// empty_block is subset of first_not_coinbase.
891-
//if (is_empty())
892-
// return error::empty_block;
891+
// type64 malleated is a subset of first_not_coinbase.
892+
// type32 malleated is a subset of is_internal_double_spend.
893893
if (is_oversized())
894894
return error::block_size_limit;
895895
if (is_first_non_coinbase())
896-
return error::first_not_coinbase;
896+
return (is_empty() ? error::empty_block :
897+
(is_malleated() ? error::invalid_transaction_commitment :
898+
error::first_not_coinbase));
897899
if (is_extra_coinbases())
898900
return error::extra_coinbases;
899901
if (is_forward_reference())
900902
return error::forward_reference;
901903
if (is_internal_double_spend())
902-
return error::block_internal_double_spend;
904+
return is_malleated() ? error::invalid_transaction_commitment :
905+
error::block_internal_double_spend;
903906
if (is_invalid_merkle_root())
904907
return error::invalid_transaction_commitment;
905908

@@ -911,7 +914,7 @@ code block::check() const NOEXCEPT
911914
// timestamp
912915
// median_time_past
913916

914-
// TODO: use of get_hash() in is_hash_limit_exceeded makes this thread unsafe.
917+
// TODO: use of get_hash() in is_hash_limit_exceeded makes this thread-unsafe.
915918
// bip141 should be disabled when the node is not accepting witness data.
916919
code block::check(const context& ctx) const NOEXCEPT
917920
{

0 commit comments

Comments
 (0)