diff --git a/Makefile.am b/Makefile.am index 857a09e2b3..f17e906f9d 100755 --- a/Makefile.am +++ b/Makefile.am @@ -418,6 +418,7 @@ include_bitcoin_system_HEADERS = \ include/bitcoin/system/constraints.hpp \ include/bitcoin/system/define.hpp \ include/bitcoin/system/exceptions.hpp \ + include/bitcoin/system/forks.hpp \ include/bitcoin/system/funclets.hpp \ include/bitcoin/system/have.hpp \ include/bitcoin/system/literals.hpp \ @@ -449,7 +450,7 @@ include_bitcoin_system_chain_HEADERS = \ include_bitcoin_system_chain_enumsdir = ${includedir}/bitcoin/system/chain/enums include_bitcoin_system_chain_enums_HEADERS = \ include/bitcoin/system/chain/enums/coverage.hpp \ - include/bitcoin/system/chain/enums/forks.hpp \ + include/bitcoin/system/chain/enums/flags.hpp \ include/bitcoin/system/chain/enums/magic_numbers.hpp \ include/bitcoin/system/chain/enums/numbers.hpp \ include/bitcoin/system/chain/enums/opcode.hpp \ diff --git a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj index 12374c7e41..f79db3df19 100644 --- a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj +++ b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj @@ -252,7 +252,7 @@ - + @@ -332,6 +332,7 @@ + diff --git a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters index ee53e616c0..0cd02801f5 100644 --- a/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters +++ b/builds/msvc/vs2022/libbitcoin-system/libbitcoin-system.vcxproj.filters @@ -635,7 +635,7 @@ include\bitcoin\system\chain\enums - + include\bitcoin\system\chain\enums @@ -875,6 +875,9 @@ include\bitcoin\system + + include\bitcoin\system + include\bitcoin\system diff --git a/include/bitcoin/system.hpp b/include/bitcoin/system.hpp index f95ee83499..be4fd77623 100755 --- a/include/bitcoin/system.hpp +++ b/include/bitcoin/system.hpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -44,7 +45,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/bitcoin/system/chain/chain.hpp b/include/bitcoin/system/chain/chain.hpp index 090b687dff..77560a3a3d 100644 --- a/include/bitcoin/system/chain/chain.hpp +++ b/include/bitcoin/system/chain/chain.hpp @@ -26,7 +26,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/include/bitcoin/system/chain/chain_state.hpp b/include/bitcoin/system/chain/chain_state.hpp index 9e15e6b26b..72fd892cea 100644 --- a/include/bitcoin/system/chain/chain_state.hpp +++ b/include/bitcoin/system/chain/chain_state.hpp @@ -19,12 +19,13 @@ #ifndef LIBBITCOIN_SYSTEM_CHAIN_CHAIN_STATE_HPP #define LIBBITCOIN_SYSTEM_CHAIN_CHAIN_STATE_HPP -#include #include +#include #include #include -#include +#include #include +#include #include #include @@ -38,6 +39,8 @@ namespace chain { class block; class header; +/// system::settings are using within chain_state to compute context, but are +/// not used directly within chain classes, which would be an abstraction leak. class BC_API chain_state { public: @@ -48,29 +51,6 @@ class BC_API chain_state typedef std::deque timestamps; typedef std::shared_ptr ptr; typedef struct { size_t count; size_t high; } range; - typedef struct - { - bool bip16; - bool bip30; - bool bip30_deactivate; - bool bip30_reactivate; - bool bip34; - bool bip42; - bool bip65; - bool bip66; - bool bip68; - bool bip90; - bool bip112; - bool bip113; - bool bip141; - bool bip143; - bool bip147; - bool retarget; // !regtest - bool difficult; // !testnet - bool time_warp_patch; // litecoin - bool retarget_overflow_patch; // litecoin - bool scrypt_proof_of_work; // litecoin - } forks_t; /// Heights used to identify construction requirements. /// All values are lower-bounded by the genesis block height. @@ -224,23 +204,23 @@ class BC_API chain_state /// No failure sentinel. static activations activation(const data& values, - const forks_t& forks, const system::settings& settings) NOEXCEPT; + const forks& forks, const system::settings& settings) NOEXCEPT; /// Returns zero if data is invalid. static uint32_t median_time_past(const data& values, - const forks_t& forks) NOEXCEPT; + const forks& forks) NOEXCEPT; /// Returns zero if data is invalid. static uint32_t work_required(const data& values, - const forks_t& forks, const system::settings& settings) NOEXCEPT; + const forks& forks, const system::settings& settings) NOEXCEPT; private: - static size_t bits_count(size_t height, const forks_t& forks, + static size_t bits_count(size_t height, const forks& forks, size_t retargeting_interval) NOEXCEPT; - static size_t version_count(size_t height, const forks_t& forks, + static size_t version_count(size_t height, const forks& forks, size_t bip34_activation_sample) NOEXCEPT; - static size_t timestamp_count(size_t height, const forks_t& forks) NOEXCEPT; - static size_t retarget_height(size_t height, const forks_t& forks, + static size_t timestamp_count(size_t height, const forks& forks) NOEXCEPT; + static size_t retarget_height(size_t height, const forks& forks, size_t retargeting_interval) NOEXCEPT; static size_t bip30_deactivate_height(size_t height, @@ -258,7 +238,7 @@ class BC_API chain_state const system::settings& settings) NOEXCEPT; static uint32_t work_required_retarget(const data& values, - const forks_t& forks, uint32_t proof_of_work_limit, + const forks& forks, uint32_t proof_of_work_limit, uint32_t minimum_timespan, uint32_t maximum_timespan, uint32_t retargeting_interval_seconds) NOEXCEPT; static uint32_t retarget_timespan(const data& values, @@ -269,7 +249,7 @@ class BC_API chain_state // These are thread safe. const data data_; - const forks_t& forks_; + const forks& forks_; const activations activations_; const uint32_t work_required_; const uint32_t median_time_past_; diff --git a/include/bitcoin/system/chain/context.hpp b/include/bitcoin/system/chain/context.hpp index 679b695cb5..1a53d4355d 100644 --- a/include/bitcoin/system/chain/context.hpp +++ b/include/bitcoin/system/chain/context.hpp @@ -20,7 +20,7 @@ #define LIBBITCOIN_SYSTEM_CHAIN_CONTEXT_HPP #include -#include +#include #include namespace libbitcoin { @@ -30,8 +30,8 @@ namespace chain { class BC_API context final { public: - /// Determine if the fork is active for this block. - bool is_enabled(chain::forks fork) const NOEXCEPT; + /// Determine if the flag is active for this block. + bool is_enabled(chain::flags flag) const NOEXCEPT; /// Header context within chain. uint32_t flags; diff --git a/include/bitcoin/system/chain/enums/forks.hpp b/include/bitcoin/system/chain/enums/flags.hpp similarity index 93% rename from include/bitcoin/system/chain/enums/forks.hpp rename to include/bitcoin/system/chain/enums/flags.hpp index f47c9e384b..7a9250765d 100644 --- a/include/bitcoin/system/chain/enums/forks.hpp +++ b/include/bitcoin/system/chain/enums/flags.hpp @@ -16,8 +16,8 @@ * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ -#ifndef LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FORKS_HPP -#define LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FORKS_HPP +#ifndef LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FLAGS_HPP +#define LIBBITCOIN_SYSTEM_CHAIN_ENUMS_FLAGS_HPP #include #include @@ -26,7 +26,7 @@ namespace libbitcoin { namespace system { namespace chain { -enum forks : uint32_t +enum flags : uint32_t { /// Rules start at satoshi v0.3.0. /// Only satoshi-released hard forks, and enforced soft forks are included. @@ -133,25 +133,25 @@ enum forks : uint32_t /// Rules that use bip34-based activation. bip34_activations = - forks::bip34_rule | - forks::bip65_rule | - forks::bip66_rule, + flags::bip34_rule | + flags::bip65_rule | + flags::bip66_rule, /// Rules that use BIP9 bit 0 first time activation. bip9_bit0_group = - forks::bip68_rule | - forks::bip112_rule | - forks::bip113_rule, + flags::bip68_rule | + flags::bip112_rule | + flags::bip113_rule, /// Rules that use BIP9 bit 1 first time activation. bip9_bit1_group = - forks::bip141_rule | - forks::bip143_rule | - forks::bip147_rule, + flags::bip141_rule | + flags::bip143_rule | + flags::bip147_rule, /////// Rules that use BIP9 bit 4 first time activation. ////bip9_bit4_group = - //// forks::bip91_rule, + //// flags::bip91_rule, /// Mask to set all rule bits. all_rules = bit_all diff --git a/include/bitcoin/system/chain/enums/policy.hpp b/include/bitcoin/system/chain/enums/policy.hpp index d564e4cfb9..b670d1ec1e 100644 --- a/include/bitcoin/system/chain/enums/policy.hpp +++ b/include/bitcoin/system/chain/enums/policy.hpp @@ -26,7 +26,7 @@ namespace libbitcoin { namespace system { namespace chain { -/// Analog to chain::forks but without impacting validation. These provide +/// Analog to chain::flags but without impacting validation. These provide /// additional validation context, giving a node the option to reject an /// unconfirmed transaction. enum policy : uint32_t diff --git a/include/bitcoin/system/chain/operation.hpp b/include/bitcoin/system/chain/operation.hpp index 46c7f21092..89250f0a69 100644 --- a/include/bitcoin/system/chain/operation.hpp +++ b/include/bitcoin/system/chain/operation.hpp @@ -394,7 +394,7 @@ class BC_API operation void to_data(writer& sink) const NOEXCEPT; // TODO: move to config serialization wrapper. - std::string to_string(uint32_t active_forks) const NOEXCEPT; + std::string to_string(uint32_t active_flags) const NOEXCEPT; /// Properties. /// ----------------------------------------------------------------------- diff --git a/include/bitcoin/system/chain/script.hpp b/include/bitcoin/system/chain/script.hpp index ddc43ec42b..e5065f1677 100644 --- a/include/bitcoin/system/chain/script.hpp +++ b/include/bitcoin/system/chain/script.hpp @@ -24,7 +24,7 @@ #include #include #include -#include +#include #include #include #include @@ -51,10 +51,11 @@ class BC_API script /// Utilities. /// ----------------------------------------------------------------------- - /// Determine if the fork is enabled in the active forks set. - static constexpr bool is_enabled(uint32_t active_forks, forks fork) NOEXCEPT + /// Determine if the flag is enabled in the active flags set. + static constexpr bool is_enabled(uint32_t active_flags, + chain::flags flag) NOEXCEPT { - return to_bool(fork & active_forks); + return to_bool(flag & active_flags); } static inline bool is_push_only(const operations& ops) NOEXCEPT @@ -471,7 +472,7 @@ class BC_API script void to_data(writer& sink, bool prefix) const NOEXCEPT; // TODO: move to config serialization wrapper. - std::string to_string(uint32_t active_forks) const NOEXCEPT; + std::string to_string(uint32_t active_flags) const NOEXCEPT; /// Properties. /// ----------------------------------------------------------------------- @@ -489,8 +490,8 @@ class BC_API script /// ----------------------------------------------------------------------- /// Pattern optimizations. - bool is_pay_to_witness(uint32_t forks) const NOEXCEPT; - bool is_pay_to_script_hash(uint32_t forks) const NOEXCEPT; + bool is_pay_to_witness(uint32_t active_flags) const NOEXCEPT; + bool is_pay_to_script_hash(uint32_t active_flags) const NOEXCEPT; /// Common pattern detection. const data_chunk& witness_program() const NOEXCEPT; diff --git a/include/bitcoin/system/chain/transaction.hpp b/include/bitcoin/system/chain/transaction.hpp index 60ec216367..46f8b64970 100644 --- a/include/bitcoin/system/chain/transaction.hpp +++ b/include/bitcoin/system/chain/transaction.hpp @@ -126,17 +126,18 @@ class BC_API transaction // signature_hash exposed for op_check_multisig caching. hash_digest signature_hash(const input_iterator& input, const script& sub, - uint64_t value, uint8_t flags, script_version version, + uint64_t value, uint8_t sighash_flags, script_version version, bool bip143) const NOEXCEPT; bool check_signature(const ec_signature& signature, const data_slice& public_key, const script& sub, uint32_t index, - uint64_t value, uint8_t flags, script_version version, + uint64_t value, uint8_t sighash_flags, script_version version, bool bip143) const NOEXCEPT; bool create_endorsement(endorsement& out, const ec_secret& secret, - const script& sub, uint32_t index, uint64_t value, uint8_t flags, - script_version version, bool bip143) const NOEXCEPT; + const script& sub, uint32_t index, uint64_t value, + uint8_t sighash_flags, script_version version, + bool bip143) const NOEXCEPT; /// Guards (for tx pool without compact blocks). /// ----------------------------------------------------------------------- @@ -226,15 +227,15 @@ class BC_API transaction input_iterator input_at(uint32_t index) const NOEXCEPT; uint32_t input_index(const input_iterator& input) const NOEXCEPT; void signature_hash_single(writer& sink, const input_iterator& input, - const script& sub, uint8_t flags) const NOEXCEPT; + const script& sub, uint8_t sighash_flags) const NOEXCEPT; void signature_hash_none(writer& sink, const input_iterator& input, - const script& sub, uint8_t flags) const NOEXCEPT; + const script& sub, uint8_t sighash_flags) const NOEXCEPT; void signature_hash_all(writer& sink, const input_iterator& input, - const script& sub, uint8_t flags) const NOEXCEPT; + const script& sub, uint8_t sighash_flags) const NOEXCEPT; hash_digest unversioned_signature_hash(const input_iterator& input, - const script& sub, uint8_t flags) const NOEXCEPT; + const script& sub, uint8_t sighash_flags) const NOEXCEPT; hash_digest version_0_signature_hash(const input_iterator& input, - const script& sub, uint64_t value, uint8_t flags, + const script& sub, uint64_t value, uint8_t sighash_flags, bool bip143) const NOEXCEPT; // Transaction should be stored as shared (adds 16 bytes). diff --git a/include/bitcoin/system/forks.hpp b/include/bitcoin/system/forks.hpp new file mode 100644 index 0000000000..17608d8126 --- /dev/null +++ b/include/bitcoin/system/forks.hpp @@ -0,0 +1,77 @@ +/** + * Copyright (c) 2011-2024 libbitcoin developers (see AUTHORS) + * + * This file is part of libbitcoin. + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU Affero General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Affero General Public License for more details. + * + * You should have received a copy of the GNU Affero General Public License + * along with this program. If not, see . + */ +#ifndef LIBBITCOIN_SYSTEM_FORKS_HPP +#define LIBBITCOIN_SYSTEM_FORKS_HPP + +namespace libbitcoin { +namespace system { + +/// Chain state accepts configured forks and maps them onto active flags +/// for the a given validaton context (i.e. block). These are exposed as +/// chain::chain_state.flags() and chain::context.flags. +typedef struct +{ + /// ~55% activation by "/P2SH/" in coinbase. + /// github.com/bitcoin/bitcoin/pull/11739 + bool bip16; + + /// github.com/bitcoin/bitcoin/pull/8391 + bool bip90; + + /// github.com/bitcoin/bitcoin/commit/a206b0ea12eb4606b93323268fc81a4f1f952531 + /// github.com/bitcoin/bitcoin/pull/6931 + /// github.com/bitcoin/bitcoin/pull/12204 + bool bip30; + bool bip30_deactivate; + bool bip30_reactivate; + + /// github.com/bitcoin/bitcoin/pull/3842 + bool bip42; + + /// bip34-based activations + bool bip34; + bool bip65; + bool bip66; + + /// bip9 bit0 activation group + bool bip68; + bool bip112; + bool bip113; + + /// bip9 bit1 activation group + bool bip141; + bool bip143; + bool bip147; + + /// Regtest does not retarget. + bool retarget; + + /// Testnet is not difficult. + bool difficult; + + /// Litecoin deviations from Bitcoin. + bool time_warp_patch; // litecoin + bool retarget_overflow_patch; // litecoin + bool scrypt_proof_of_work; // litecoin +} forks; + +} // namespace system +} // namespace libbitcoin + +#endif diff --git a/include/bitcoin/system/impl/machine/interpreter.ipp b/include/bitcoin/system/impl/machine/interpreter.ipp index e6a692d7c8..3d16eaad85 100644 --- a/include/bitcoin/system/impl/machine/interpreter.ipp +++ b/include/bitcoin/system/impl/machine/interpreter.ipp @@ -70,7 +70,7 @@ template inline op_error_t interpreter:: op_nop(opcode) const NOEXCEPT { - if (state::is_enabled(forks::nops_rule)) + if (state::is_enabled(flags::nops_rule)) return error::op_success; ////return op_unevaluated(code); @@ -141,7 +141,7 @@ template inline op_error_t interpreter:: op_ver() const NOEXCEPT { - if (state::is_enabled(forks::nops_rule)) + if (state::is_enabled(flags::nops_rule)) return op_unevaluated(opcode::op_ver); return error::op_not_implemented; @@ -187,7 +187,7 @@ template inline op_error_t interpreter:: op_verif() const NOEXCEPT { - if (state::is_enabled(forks::nops_rule)) + if (state::is_enabled(flags::nops_rule)) return op_unevaluated(opcode::op_verif); return error::op_not_implemented; @@ -197,7 +197,7 @@ template inline op_error_t interpreter:: op_vernotif() const NOEXCEPT { - if (state::is_enabled(forks::nops_rule)) + if (state::is_enabled(flags::nops_rule)) return op_unevaluated(opcode::op_vernotif); return error::op_not_implemented; @@ -243,7 +243,7 @@ template inline op_error_t interpreter:: op_return() const NOEXCEPT { - if (state::is_enabled(forks::nops_rule)) + if (state::is_enabled(flags::nops_rule)) return op_unevaluated(opcode::op_return); return error::op_not_implemented; @@ -515,7 +515,7 @@ template inline op_error_t interpreter:: op_cat() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_cat); return error::op_not_implemented; @@ -525,7 +525,7 @@ template inline op_error_t interpreter:: op_substr() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_substr); return error::op_not_implemented; @@ -535,7 +535,7 @@ template inline op_error_t interpreter:: op_left() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_left); return error::op_not_implemented; @@ -545,7 +545,7 @@ template inline op_error_t interpreter:: op_right() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_right); return error::op_not_implemented; @@ -566,7 +566,7 @@ template inline op_error_t interpreter:: op_invert() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_invert); return error::op_not_implemented; @@ -576,7 +576,7 @@ template inline op_error_t interpreter:: op_and() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_and); return error::op_not_implemented; @@ -586,7 +586,7 @@ template inline op_error_t interpreter:: op_or() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_or); return error::op_not_implemented; @@ -596,7 +596,7 @@ template inline op_error_t interpreter:: op_xor() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_xor); return error::op_not_implemented; @@ -652,7 +652,7 @@ template inline op_error_t interpreter:: op_mul2() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_mul2); return error::op_not_implemented; @@ -662,7 +662,7 @@ template inline op_error_t interpreter:: op_div2() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_div2); return error::op_not_implemented; @@ -749,7 +749,7 @@ template inline op_error_t interpreter:: op_mul() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_mul); return error::op_not_implemented; @@ -759,7 +759,7 @@ template inline op_error_t interpreter:: op_div() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_div); return error::op_not_implemented; @@ -769,7 +769,7 @@ template inline op_error_t interpreter:: op_mod() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_mod); return error::op_not_implemented; @@ -779,7 +779,7 @@ template inline op_error_t interpreter:: op_lshift() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_lshift); return error::op_not_implemented; @@ -789,7 +789,7 @@ template inline op_error_t interpreter:: op_rshift() const NOEXCEPT { - if (state::is_enabled(forks::cats_rule)) + if (state::is_enabled(flags::cats_rule)) return op_unevaluated(opcode::op_rshift); return error::op_not_implemented; @@ -1008,7 +1008,7 @@ inline op_error_t interpreter:: op_check_sig() NOEXCEPT { const auto verify = op_check_sig_verify(); - const auto bip66 = state::is_enabled(forks::bip66_rule); + const auto bip66 = state::is_enabled(flags::bip66_rule); // BIP66: invalid signature encoding fails the operation. if (bip66 && verify == error::op_check_sig_verify_parse) @@ -1058,7 +1058,7 @@ inline op_error_t interpreter:: op_check_multisig() NOEXCEPT { const auto verify = op_check_multisig_verify(); - const auto bip66 = state::is_enabled(forks::bip66_rule); + const auto bip66 = state::is_enabled(flags::bip66_rule); // BIP66: invalid signature encoding fails the operation. if (bip66 && verify == error::op_check_multisig_verify_parse) @@ -1072,7 +1072,7 @@ template inline op_error_t interpreter:: op_check_multisig_verify() NOEXCEPT { - const auto bip147 = state::is_enabled(forks::bip147_rule); + const auto bip147 = state::is_enabled(flags::bip147_rule); size_t count; if (!state::pop_index32(count)) @@ -1109,8 +1109,8 @@ op_check_multisig_verify() NOEXCEPT if (state::pop_strict_bool_() && bip147) return error::op_check_multisig_verify9; - uint8_t flags; ec_signature sig; + uint8_t sighash_flags; typename state::hash_cache cache; // Subscript is the same for all signatures. @@ -1131,11 +1131,12 @@ op_check_multisig_verify() NOEXCEPT { // Parse endorsement into DER signature into an EC signature. // Also generates signature hash from endorsement sighash flags. - if (!state::prepare(sig, *key, cache, flags, **endorsement, *sub)) + if (!state::prepare(sig, *key, cache, sighash_flags, + **endorsement, *sub)) return error::op_check_multisig_verify_parse; BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - const auto& hash = cache.at(flags); + const auto& hash = cache.at(sighash_flags); BC_POP_WARNING() // TODO: for signing mode - make key mutable and return above. @@ -1153,7 +1154,7 @@ inline op_error_t interpreter:: op_check_locktime_verify() const NOEXCEPT { // BIP65: nop2 subsumed by checklocktimeverify when bip65 fork is active. - if (!state::is_enabled(forks::bip65_rule)) + if (!state::is_enabled(flags::bip65_rule)) return op_nop(opcode::nop2); // BIP65: the tx sequence is 0xffffffff. @@ -1185,7 +1186,7 @@ inline op_error_t interpreter:: op_check_sequence_verify() const NOEXCEPT { // BIP112: nop3 subsumed by checksequenceverify when bip112 fork is active. - if (!state::is_enabled(forks::bip112_rule)) + if (!state::is_enabled(flags::bip112_rule)) return op_nop(opcode::nop3); // BIP112: the stack is empty. diff --git a/include/bitcoin/system/impl/machine/program.ipp b/include/bitcoin/system/impl/machine/program.ipp index a2961ca64a..7cf24b4d26 100644 --- a/include/bitcoin/system/impl/machine/program.ipp +++ b/include/bitcoin/system/impl/machine/program.ipp @@ -45,11 +45,11 @@ using namespace system::error; template inline program:: program(const chain::transaction& tx, const input_iterator& input, - uint32_t forks) NOEXCEPT + uint32_t active_flags) NOEXCEPT : transaction_(tx), input_(input), script_((*input)->script_ptr()), - forks_(forks), + flags_(active_flags), value_(max_uint64), version_(script_version::unversioned), witness_(), @@ -67,7 +67,7 @@ program(const program& other, const script::cptr& script) NOEXCEPT : transaction_(other.transaction_), input_(other.input_), script_(script), - forks_(other.forks_), + flags_(other.flags_), value_(other.value_), version_(other.version_), witness_(), @@ -82,7 +82,7 @@ program(program&& other, const script::cptr& script) NOEXCEPT : transaction_(other.transaction_), input_(other.input_), script_(script), - forks_(other.forks_), + flags_(other.flags_), value_(other.value_), version_(other.version_), witness_(), @@ -97,12 +97,12 @@ program(program&& other, const script::cptr& script) NOEXCEPT template inline program:: program(const chain::transaction& tx, const input_iterator& input, - const script::cptr& script, uint32_t forks, script_version version, + const script::cptr& script, uint32_t active_flags, script_version version, const chunk_cptrs_ptr& witness) NOEXCEPT : transaction_(tx), input_(input), script_(script), - forks_(forks), + flags_(active_flags), value_((*input)->prevout->value()), version_(version), witness_(witness), @@ -170,9 +170,9 @@ transaction() const NOEXCEPT template INLINE bool program:: -is_enabled(chain::forks rule) const NOEXCEPT +is_enabled(chain::flags flag) const NOEXCEPT { - return to_bool(forks_ & rule); + return to_bool(flags_ & flag); } // TODO: only perform is_push_size check on witness initialized stack. @@ -182,7 +182,7 @@ INLINE script_error_t program:: validate() const NOEXCEPT { // TODO: nops rule must first be enabled in tests and config. - const auto bip141 = is_enabled(forks::bip141_rule); + const auto bip141 = is_enabled(flags::bip141_rule); // The script was determined by the parser to contain an invalid opcode. if (is_prefail()) @@ -742,7 +742,7 @@ subscript(const chunk_xptrs& endorsements) const NOEXCEPT { // bip141: establishes the version property. // bip143: op stripping is not applied to bip141 v0 scripts. - if (is_enabled(forks::bip143_rule) && version_ == script_version::zero) + if (is_enabled(flags::bip143_rule) && version_ == script_version::zero) return script_; // Transform into a set of endorsement push ops and one op_codeseparator. @@ -766,18 +766,18 @@ inline bool program:: prepare(ec_signature& signature, const data_chunk&, hash_digest& hash, const chunk_xptr& endorsement) const NOEXCEPT { - uint8_t flags; + uint8_t sighash_flags; data_slice distinguished; // Parse Bitcoin endorsement into DER signature and sighash flags. - if (!parse_endorsement(flags, distinguished, *endorsement)) + if (!parse_endorsement(sighash_flags, distinguished, *endorsement)) return false; // Obtain the signature hash from subscript and sighash flags. - hash = signature_hash(*subscript({ endorsement }), flags); + hash = signature_hash(*subscript({ endorsement }), sighash_flags); // Parse DER signature into an EC signature (bip66 sets strict). - const auto bip66 = is_enabled(forks::bip66_rule); + const auto bip66 = is_enabled(flags::bip66_rule); return parse_signature(signature, distinguished, bip66); } @@ -785,19 +785,20 @@ prepare(ec_signature& signature, const data_chunk&, hash_digest& hash, template inline bool program:: prepare(ec_signature& signature, const data_chunk&, hash_cache& cache, - uint8_t& flags, const data_chunk& endorsement, const script& sub) const NOEXCEPT + uint8_t& sighash_flags, const data_chunk& endorsement, + const script& sub) const NOEXCEPT { data_slice distinguished; // Parse Bitcoin endorsement into DER signature and sighash flags. - if (!parse_endorsement(flags, distinguished, endorsement)) + if (!parse_endorsement(sighash_flags, distinguished, endorsement)) return false; // Obtain the signature hash from subscript and sighash flags. - signature_hash(cache, sub, flags); + signature_hash(cache, sub, sighash_flags); // Parse DER signature into an EC signature (bip66 sets strict). - const auto bip66 = is_enabled(forks::bip66_rule); + const auto bip66 = is_enabled(flags::bip66_rule); return parse_signature(signature, distinguished, bip66); } @@ -809,7 +810,7 @@ INLINE hash_digest program:: signature_hash(const script& sub, uint8_t flags) const NOEXCEPT { // The bip141 fork establishes witness version, hashing is a distinct fork. - const auto bip143 = is_enabled(forks::bip143_rule); + const auto bip143 = is_enabled(flags::bip143_rule); // bip143: the method of signature hashing is changed for v0 scripts. return transaction_.signature_hash(input_, sub, value_, flags, version_, @@ -821,11 +822,11 @@ signature_hash(const script& sub, uint8_t flags) const NOEXCEPT template INLINE void program:: signature_hash(hash_cache& cache, const script& sub, - uint8_t flags) const NOEXCEPT + uint8_t sighash_flags) const NOEXCEPT { BC_PUSH_WARNING(NO_THROW_IN_NOEXCEPT) - if (cache.find(flags) == cache.end()) - cache.emplace(flags, signature_hash(sub, flags)); + if (cache.find(sighash_flags) == cache.end()) + cache.emplace(sighash_flags, signature_hash(sub, sighash_flags)); BC_POP_WARNING() } diff --git a/include/bitcoin/system/machine/program.hpp b/include/bitcoin/system/machine/program.hpp index c2e2338cfe..757f672fd6 100644 --- a/include/bitcoin/system/machine/program.hpp +++ b/include/bitcoin/system/machine/program.hpp @@ -46,7 +46,7 @@ class program /// Input script run (default/empty stack). inline program(const chain::transaction& transaction, - const input_iterator& input, uint32_t forks) NOEXCEPT; + const input_iterator& input, uint32_t active_flags) NOEXCEPT; /// Legacy p2sh or prevout script run (copied input stack). inline program(const program& other, @@ -59,7 +59,7 @@ class program /// Witness script run (witness-initialized stack). inline program(const chain::transaction& transaction, const input_iterator& input, const chain::script::cptr& script, - uint32_t forks, chain::script_version version, + uint32_t active_flags, chain::script_version version, const chunk_cptrs_ptr& stack) NOEXCEPT; /// Program result. @@ -80,7 +80,7 @@ class program INLINE op_iterator end() const NOEXCEPT; INLINE const chain::input& input() const NOEXCEPT; INLINE const chain::transaction& transaction() const NOEXCEPT; - INLINE bool is_enabled(chain::forks rule) const NOEXCEPT; + INLINE bool is_enabled(chain::flags flag) const NOEXCEPT; INLINE error::script_error_t validate() const NOEXCEPT; /// Primary stack. @@ -163,9 +163,9 @@ class program inline bool prepare(ec_signature& signature, const data_chunk& key, hash_digest& hash, const chunk_xptr& endorsement) const NOEXCEPT; - /// Prepare signature, with caching for multisig with same flags. + /// Prepare signature, with caching for multisig with same sighash flags. inline bool prepare(ec_signature& signature, const data_chunk& key, - hash_cache& cache, uint8_t& flags, const data_chunk& endorsement, + hash_cache& cache, uint8_t& sighash_flags, const data_chunk& endorsement, const chain::script& sub) const NOEXCEPT; private: @@ -194,7 +194,7 @@ class program const chain::transaction& transaction_; const input_iterator input_; const chain::script::cptr script_; - const uint32_t forks_; + const uint32_t flags_; const uint64_t value_; const chain::script_version version_; const chunk_cptrs_ptr witness_; diff --git a/include/bitcoin/system/settings.hpp b/include/bitcoin/system/settings.hpp index b6956a5cd7..6fbc7316f3 100644 --- a/include/bitcoin/system/settings.hpp +++ b/include/bitcoin/system/settings.hpp @@ -23,6 +23,7 @@ #include #include #include +#include namespace libbitcoin { namespace system { @@ -39,33 +40,33 @@ class BC_API settings /// Computed properties. /// ----------------------------------------------------------------------- - /// These are not used internal to system. + /// These are not used by the system library. virtual uint64_t max_money() const NOEXCEPT; virtual uint64_t initial_subsidy() const NOEXCEPT; virtual uint64_t bitcoin_to_satoshi(uint64_t value) const NOEXCEPT; - /// These are used internal to system. + /// These are used by chain_state (only). virtual uint32_t minimum_timespan() const NOEXCEPT; virtual uint32_t maximum_timespan() const NOEXCEPT; virtual size_t retargeting_interval() const NOEXCEPT; /// Configured forks. /// ----------------------------------------------------------------------- + /// These are used by chain_state (only). - /// These are not used internal to system. - chain::chain_state::forks_t forks{}; + system::forks forks{}; /// Consensus parameters. /// ----------------------------------------------------------------------- - /// These are not used internal to system. + /// These are not used by the system library. uint64_t initial_subsidy_bitcoin; uint32_t subsidy_interval_blocks; uint32_t timestamp_limit_seconds; chain::checkpoints checkpoints{}; config::block genesis_block{}; - /// These are used internal to system. + /// These are used by chain_state (only). uint32_t retargeting_factor; uint32_t retargeting_interval_seconds; uint32_t block_spacing_seconds; @@ -73,7 +74,7 @@ class BC_API settings /// Activation settings. /// ----------------------------------------------------------------------- - /// These are used internal to system. + /// These are used by chain_state (only). /// Consensus rule change activation and enforcement parameters. uint32_t first_version; diff --git a/src/chain/block.cpp b/src/chain/block.cpp index 04e1e1fec9..a592359523 100644 --- a/src/chain/block.cpp +++ b/src/chain/block.cpp @@ -29,7 +29,7 @@ #include #include #include -#include +#include #include #include #include @@ -38,7 +38,6 @@ #include #include #include -#include #include namespace libbitcoin { @@ -554,10 +553,8 @@ bool block::is_signature_operations_limited(bool bip16, //***************************************************************************** // CONSENSUS: -// This check is excluded under two bip30 exception blocks. This also cannot -// occur in any branch above bip34, due to height in coinbase and the -// presumption of sha256 non-collision. So this check is bypassed for both -// exception blocks and if bip34 is active (including under bip90 activation). +// This check is excluded under two bip30 exception blocks and bip30_deactivate +// until bip30_reactivate. These conditions are rolled up into the bip30 flag. //***************************************************************************** bool block::is_unspent_coinbase_collision() const NOEXCEPT { @@ -668,8 +665,9 @@ code block::confirm_transactions(const context& ctx) const NOEXCEPT code block::check() const NOEXCEPT { // context free. - if (is_empty()) - return error::empty_block; + // empty_block is redundant with first_not_coinbase. + ////if (is_empty()) + //// return error::empty_block; if (is_oversized()) return error::block_size_limit; if (is_first_non_coinbase()) diff --git a/src/chain/chain_state.cpp b/src/chain/chain_state.cpp index 1892bad393..da53d2fd95 100644 --- a/src/chain/chain_state.cpp +++ b/src/chain/chain_state.cpp @@ -26,10 +26,11 @@ #include #include #include -#include +#include #include #include #include +#include #include #include #include @@ -100,58 +101,58 @@ inline uint32_t bits_high(const chain_state::data& values) NOEXCEPT // ---------------------------------------------------------------------------- chain_state::activations chain_state::activation(const data& values, - const forks_t& forks, const system::settings& settings) NOEXCEPT + const forks& forks, const system::settings& settings) NOEXCEPT { // Initialize activation results with genesis values. - activations result{ forks::no_rules, settings.first_version }; + activations result{ flags::no_rules, settings.first_version }; // regtest is only activated via configuration. if (forks.retarget) { - result.flags |= forks::retarget; + result.flags |= flags::retarget; } // testnet is activated based on configuration alone. if (forks.difficult) { - result.flags |= forks::difficult; + result.flags |= flags::difficult; } // time_warp_patch is activated based on configuration alone. if (forks.time_warp_patch) { - result.flags |= forks::time_warp_patch; + result.flags |= flags::time_warp_patch; } // retarget_overflow_patch is activated based on configuration alone. if (forks.retarget_overflow_patch) { - result.flags |= forks::retarget_overflow_patch; + result.flags |= flags::retarget_overflow_patch; } // scrypt_proof_of_work is activated based on configuration alone. if (forks.scrypt_proof_of_work) { - result.flags |= forks::scrypt_proof_of_work; + result.flags |= flags::scrypt_proof_of_work; } // bip42 is activated based on configuration alone (soft fork). if (forks.bip42) { - result.flags |= forks::bip42_rule; + result.flags |= flags::bip42_rule; } // bip90 is activated based on configuration alone (hard fork). if (forks.bip90) { - result.flags |= forks::bip90_rule; + result.flags |= flags::bip90_rule; } // bip16 was activated by manual inspection of signal history (soft fork). if (forks.bip16 && (values.timestamp.self >= settings.bip16_activation_time)) { - result.flags |= forks::bip16_rule; + result.flags |= flags::bip16_rule; } const auto height = values.height; @@ -192,7 +193,7 @@ chain_state::activations chain_state::activation(const data& values, (is_active(count_2, settings.bip34_activation_threshold) && version >= settings.bip34_version)) { - result.flags |= forks::bip34_rule; + result.flags |= flags::bip34_rule; } // bip66 is active based on 75% of preceding 1000 mainnet blocks. @@ -200,7 +201,7 @@ chain_state::activations chain_state::activation(const data& values, (is_active(count_3, settings.bip34_activation_threshold) && version >= settings.bip66_version)) { - result.flags |= forks::bip66_rule; + result.flags |= flags::bip66_rule; } // bip65 is active based on 75% of preceding 1000 mainnet blocks. @@ -208,7 +209,7 @@ chain_state::activations chain_state::activation(const data& values, (is_active(count_4, settings.bip34_activation_threshold) && version >= settings.bip65_version)) { - result.flags |= forks::bip65_rule; + result.flags |= flags::bip65_rule; } // version 4/3/2 enforced based on 95% of preceding 1000 mainnet blocks. @@ -237,17 +238,17 @@ chain_state::activations chain_state::activation(const data& values, // bip9_bit0 forks are enforced above the bip9_bit0 checkpoint. if (values.bip9_bit0_hash == settings.bip9_bit0_active_checkpoint.hash()) { - result.flags |= forks::bip68_rule; - result.flags |= forks::bip112_rule; - result.flags |= forks::bip113_rule; + result.flags |= flags::bip68_rule; + result.flags |= flags::bip112_rule; + result.flags |= flags::bip113_rule; } // bip9_bit1 forks are enforced above the bip9_bit1 checkpoint. if (values.bip9_bit1_hash == settings.bip9_bit1_active_checkpoint.hash()) { - result.flags |= forks::bip141_rule; - result.flags |= forks::bip143_rule; - result.flags |= forks::bip147_rule; + result.flags |= flags::bip141_rule; + result.flags |= flags::bip143_rule; + result.flags |= flags::bip147_rule; } // bip30_deactivate fork enforced above bip30_deactivate (bip34) checkpoint. @@ -264,13 +265,13 @@ chain_state::activations chain_state::activation(const data& values, if (forks.bip30 && (!bip30_deactivate || bip30_reactivate) && !is_bip30_exception({ values.hash, height })) { - result.flags |= forks::bip30_rule; + result.flags |= flags::bip30_rule; } return result; } -size_t chain_state::bits_count(size_t height, const forks_t& forks, +size_t chain_state::bits_count(size_t height, const forks& forks, size_t retargeting_interval) NOEXCEPT { // Mainnet doesn't use bits in retargeting. @@ -289,7 +290,7 @@ size_t chain_state::bits_count(size_t height, const forks_t& forks, return std::min(height, retargeting_interval); } -size_t chain_state::version_count(size_t height, const forks_t& forks, +size_t chain_state::version_count(size_t height, const forks& forks, size_t bip34_activation_sample) NOEXCEPT { if (forks.bip90 || (!forks.bip34 && !forks.bip65 && !forks.bip66)) @@ -298,12 +299,12 @@ size_t chain_state::version_count(size_t height, const forks_t& forks, return std::min(height, bip34_activation_sample); } -size_t chain_state::timestamp_count(size_t height, const forks_t&) NOEXCEPT +size_t chain_state::timestamp_count(size_t height, const forks&) NOEXCEPT { return std::min(height, median_time_past_interval); } -size_t chain_state::retarget_height(size_t height, const forks_t& forks, +size_t chain_state::retarget_height(size_t height, const forks& forks, size_t retargeting_interval) NOEXCEPT { if (!forks.retarget) @@ -326,7 +327,7 @@ size_t chain_state::retarget_height(size_t height, const forks_t& forks, // block N with block N. This is simple but requires care when comparing code. //***************************************************************************** uint32_t chain_state::median_time_past(const data& values, - const forks_t&) NOEXCEPT + const forks&) NOEXCEPT { // Sort the times by value to obtain the median. auto times = sort_copy(values.timestamp.ordered); @@ -341,7 +342,7 @@ uint32_t chain_state::median_time_past(const data& values, // work_required // ---------------------------------------------------------------------------- -uint32_t chain_state::work_required(const data& values, const forks_t& forks, +uint32_t chain_state::work_required(const data& values, const forks& forks, const system::settings& settings) NOEXCEPT { // Genesis has no preceding block data. @@ -393,15 +394,15 @@ uint32_t chain_state::retarget_timespan(const data& values, return limit(timespan, minimum_timespan, maximum_timespan); } -constexpr bool patch_timewarp(const chain_state::forks_t& forks, - const uint256_t& limit, const uint256_t& target) NOEXCEPT +constexpr bool patch_timewarp(const forks& forks, const uint256_t& limit, + const uint256_t& target) NOEXCEPT { return forks.retarget_overflow_patch && floored_log2(target) >= floored_log2(limit); } uint32_t chain_state::work_required_retarget(const data& values, - const forks_t& forks, uint32_t proof_of_work_limit, + const forks& forks, uint32_t proof_of_work_limit, uint32_t minimum_timespan, uint32_t maximum_timespan, uint32_t retargeting_interval_seconds) NOEXCEPT { diff --git a/src/chain/context.cpp b/src/chain/context.cpp index 27f06e9cd7..f3d143494b 100644 --- a/src/chain/context.cpp +++ b/src/chain/context.cpp @@ -18,16 +18,16 @@ */ #include -#include +#include #include namespace libbitcoin { namespace system { namespace chain { -bool context::is_enabled(chain::forks fork) const NOEXCEPT +bool context::is_enabled(chain::flags flag) const NOEXCEPT { - return to_bool(fork & flags); + return to_bool(flag & flags); } bool operator==(const context& left, const context& right) NOEXCEPT diff --git a/src/chain/enums/opcode.cpp b/src/chain/enums/opcode.cpp index 1671082b07..1011401f99 100644 --- a/src/chain/enums/opcode.cpp +++ b/src/chain/enums/opcode.cpp @@ -19,7 +19,7 @@ #include #include -#include +#include #include #include #include @@ -308,10 +308,10 @@ std::string opcode_to_mnemonic(opcode value, uint32_t active_forks) NOEXCEPT case opcode::nop1: return "nop1"; case opcode::checklocktimeverify: - return script::is_enabled(active_forks, forks::bip65_rule) ? + return script::is_enabled(active_forks, flags::bip65_rule) ? "checklocktimeverify" : "nop2"; case opcode::checksequenceverify: - return script::is_enabled(active_forks, forks::bip112_rule) ? + return script::is_enabled(active_forks, flags::bip112_rule) ? "checksequenceverify" : "nop3"; case opcode::nop4: return "nop4"; diff --git a/src/chain/input.cpp b/src/chain/input.cpp index 0634e95944..2e634862d0 100644 --- a/src/chain/input.cpp +++ b/src/chain/input.cpp @@ -346,7 +346,7 @@ bool input::extract_sigop_script(chain::script& out, } // TODO: Prior to block 79400 sigops were limited only by policy. -// TODO: Create legacy sigops fork flag and pass here, return 0 if false. +// TODO: Create legacy sigops fork/flag and pass here, return 0 if false. // TODO: this was an unbipped flag day soft fork, prior to BIP16/141. // TODO: if (nHeight > 79400 && GetSigOpCount() > MAX_BLOCK_SIGOPS). size_t input::signature_operations(bool bip16, bool bip141) const NOEXCEPT diff --git a/src/chain/operation.cpp b/src/chain/operation.cpp index 9cbd3c0f9c..a951b465b9 100644 --- a/src/chain/operation.cpp +++ b/src/chain/operation.cpp @@ -419,7 +419,7 @@ static std::string opcode_to_prefix(opcode code, } } -std::string operation::to_string(uint32_t active_forks) const NOEXCEPT +std::string operation::to_string(uint32_t active_flags) const NOEXCEPT { if (!is_valid()) return "(?)"; @@ -428,7 +428,7 @@ std::string operation::to_string(uint32_t active_forks) const NOEXCEPT return "<" + encode_base16(*data_) + ">"; if (data_->empty()) - return opcode_to_mnemonic(code_, active_forks); + return opcode_to_mnemonic(code_, active_flags); // Data encoding uses single token with explicit size prefix as required. return "[" + opcode_to_prefix(code_, *data_) + encode_base16(*data_) + "]"; @@ -615,7 +615,7 @@ operation tag_invoke(json::value_to_tag, void tag_invoke(json::value_from_tag, json::value& value, const operation& operation) NOEXCEPT { - value = operation.to_string(forks::all_rules); + value = operation.to_string(flags::all_rules); } BC_POP_WARNING() diff --git a/src/chain/script.cpp b/src/chain/script.cpp index d9310516eb..30f4ba7993 100644 --- a/src/chain/script.cpp +++ b/src/chain/script.cpp @@ -25,7 +25,7 @@ #include #include #include -#include +#include #include #include #include @@ -306,7 +306,7 @@ void script::to_data(writer& sink, bool prefix) const NOEXCEPT op->to_data(sink); } -std::string script::to_string(uint32_t active_forks) const NOEXCEPT +std::string script::to_string(uint32_t active_flags) const NOEXCEPT { auto first = true; std::ostringstream text; @@ -316,7 +316,7 @@ std::string script::to_string(uint32_t active_forks) const NOEXCEPT for (const auto& op: ops()) { - text << (first ? "" : " ") << op.to_string(active_forks); + text << (first ? "" : " ") << op.to_string(active_flags); first = false; } @@ -452,17 +452,17 @@ script_pattern script::input_pattern() const NOEXCEPT return script_pattern::non_standard; } -bool script::is_pay_to_witness(uint32_t forks) const NOEXCEPT +bool script::is_pay_to_witness(uint32_t active_flags) const NOEXCEPT { // This is an optimization over using script::pattern. - return is_enabled(forks, forks::bip141_rule) && + return is_enabled(active_flags, flags::bip141_rule) && is_witness_program_pattern(ops()); } -bool script::is_pay_to_script_hash(uint32_t forks) const NOEXCEPT +bool script::is_pay_to_script_hash(uint32_t active_flags) const NOEXCEPT { // This is an optimization over using script::pattern. - return is_enabled(forks, forks::bip16_rule) && + return is_enabled(active_flags, flags::bip16_rule) && is_pay_script_hash_pattern(ops()); } @@ -543,7 +543,7 @@ script tag_invoke(json::value_to_tag