diff --git a/include/bitcoin/system/chain/block.hpp b/include/bitcoin/system/chain/block.hpp index 36ee4ba1fa..3432ba6690 100644 --- a/include/bitcoin/system/chain/block.hpp +++ b/include/bitcoin/system/chain/block.hpp @@ -109,8 +109,8 @@ class BC_API block /// ----------------------------------------------------------------------- /// Consensus checks (no DoS guards for block sync without headers first). - code check() const NOEXCEPT; - code check(const context& ctx) const NOEXCEPT; + code check(bool bypass=false) const NOEXCEPT; + code check(const context& ctx, bool bypass=false) const NOEXCEPT; code accept(const context& ctx, size_t subsidy_interval, uint64_t initial_subsidy) const NOEXCEPT; code connect(const context& ctx) const NOEXCEPT; diff --git a/src/chain/block.cpp b/src/chain/block.cpp index 32c98432f2..0ef7503389 100644 --- a/src/chain/block.cpp +++ b/src/chain/block.cpp @@ -723,8 +723,14 @@ code block::confirm_transactions(const context& ctx) const NOEXCEPT // ---------------------------------------------------------------------------- // The block header is checked/accepted independently. -code block::check() const NOEXCEPT +code block::check(bool bypass) const NOEXCEPT { + if (bypass) + { + return is_invalid_merkle_root() ? error::merkle_mismatch : + error::block_success; + } + // context free. // empty_block is redundant with first_not_coinbase. //if (is_empty()) @@ -750,8 +756,15 @@ code block::check() const NOEXCEPT // timestamp // median_time_past -code block::check(const context& ctx) const NOEXCEPT +code block::check(const context& ctx, bool bypass) const NOEXCEPT { + if (bypass) + { + const auto bip141 = ctx.is_enabled(bip141_rule); + return bip141 && is_invalid_witness_commitment() ? + error::invalid_witness_commitment : error::block_success; + } + const auto bip34 = ctx.is_enabled(bip34_rule); const auto bip50 = ctx.is_enabled(bip50_rule); const auto bip141 = ctx.is_enabled(bip141_rule);