/bitcoin/src/consensus/validation.h
Line | Count | Source |
1 | | // Copyright (c) 2009-2010 Satoshi Nakamoto |
2 | | // Copyright (c) 2009-2022 The Bitcoin Core developers |
3 | | // Distributed under the MIT software license, see the accompanying |
4 | | // file COPYING or http://www.opensource.org/licenses/mit-license.php. |
5 | | |
6 | | #ifndef BITCOIN_CONSENSUS_VALIDATION_H |
7 | | #define BITCOIN_CONSENSUS_VALIDATION_H |
8 | | |
9 | | #include <string> |
10 | | #include <consensus/consensus.h> |
11 | | #include <primitives/transaction.h> |
12 | | #include <primitives/block.h> |
13 | | |
14 | | /** Index marker for when no witness commitment is present in a coinbase transaction. */ |
15 | | static constexpr int NO_WITNESS_COMMITMENT{-1}; |
16 | | |
17 | | /** Minimum size of a witness commitment structure. Defined in BIP 141. **/ |
18 | | static constexpr size_t MINIMUM_WITNESS_COMMITMENT{38}; |
19 | | |
20 | | /** A "reason" why a transaction was invalid, suitable for determining whether the |
21 | | * provider of the transaction should be banned/ignored/disconnected/etc. |
22 | | */ |
23 | | enum class TxValidationResult { |
24 | | TX_RESULT_UNSET = 0, //!< initial value. Tx has not yet been rejected |
25 | | TX_CONSENSUS, //!< invalid by consensus rules |
26 | | TX_INPUTS_NOT_STANDARD, //!< inputs (covered by txid) failed policy rules |
27 | | TX_NOT_STANDARD, //!< otherwise didn't meet our local policy rules |
28 | | TX_MISSING_INPUTS, //!< transaction was missing some of its inputs |
29 | | TX_PREMATURE_SPEND, //!< transaction spends a coinbase too early, or violates locktime/sequence locks |
30 | | /** |
31 | | * Transaction might have a witness prior to SegWit |
32 | | * activation, or witness may have been malleated (which includes |
33 | | * non-standard witnesses). |
34 | | */ |
35 | | TX_WITNESS_MUTATED, |
36 | | /** |
37 | | * Transaction is missing a witness. |
38 | | */ |
39 | | TX_WITNESS_STRIPPED, |
40 | | /** |
41 | | * Tx already in mempool or conflicts with a tx in the chain |
42 | | * (if it conflicts with another tx in mempool, we use MEMPOOL_POLICY as it failed to reach the RBF threshold) |
43 | | * Currently this is only used if the transaction already exists in the mempool or on chain. |
44 | | */ |
45 | | TX_CONFLICT, |
46 | | TX_MEMPOOL_POLICY, //!< violated mempool's fee/size/descendant/RBF/etc limits |
47 | | TX_NO_MEMPOOL, //!< this node does not have a mempool so can't validate the transaction |
48 | | TX_RECONSIDERABLE, //!< fails some policy, but might be acceptable if submitted in a (different) package |
49 | | TX_UNKNOWN, //!< transaction was not validated because package failed |
50 | | }; |
51 | | |
52 | | /** A "reason" why a block was invalid, suitable for determining whether the |
53 | | * provider of the block should be banned/ignored/disconnected/etc. |
54 | | * These are much more granular than the rejection codes, which may be more |
55 | | * useful for some other use-cases. |
56 | | */ |
57 | | enum class BlockValidationResult { |
58 | | BLOCK_RESULT_UNSET = 0, //!< initial value. Block has not yet been rejected |
59 | | BLOCK_CONSENSUS, //!< invalid by consensus rules (excluding any below reasons) |
60 | | BLOCK_CACHED_INVALID, //!< this block was cached as being invalid and we didn't store the reason why |
61 | | BLOCK_INVALID_HEADER, //!< invalid proof of work or time too old |
62 | | BLOCK_MUTATED, //!< the block's data didn't match the data committed to by the PoW |
63 | | BLOCK_MISSING_PREV, //!< We don't have the previous block the checked one is built on |
64 | | BLOCK_INVALID_PREV, //!< A block this one builds on is invalid |
65 | | BLOCK_TIME_FUTURE, //!< block timestamp was > 2 hours in the future (or our clock is bad) |
66 | | BLOCK_HEADER_LOW_WORK //!< the block header may be on a too-little-work chain |
67 | | }; |
68 | | |
69 | | |
70 | | |
71 | | /** Template for capturing information about block/transaction validation. This is instantiated |
72 | | * by TxValidationState and BlockValidationState for validation information on transactions |
73 | | * and blocks respectively. */ |
74 | | template <typename Result> |
75 | | class ValidationState |
76 | | { |
77 | | private: |
78 | | enum class ModeState { |
79 | | M_VALID, //!< everything ok |
80 | | M_INVALID, //!< network rule violation (DoS value may be set) |
81 | | M_ERROR, //!< run-time error |
82 | | } m_mode{ModeState::M_VALID}; |
83 | | Result m_result{}; |
84 | | std::string m_reject_reason; |
85 | | std::string m_debug_message; |
86 | | |
87 | | public: |
88 | | bool Invalid(Result result, |
89 | | const std::string& reject_reason = "", |
90 | | const std::string& debug_message = "") |
91 | 376k | { |
92 | 376k | m_result = result; |
93 | 376k | m_reject_reason = reject_reason; |
94 | 376k | m_debug_message = debug_message; |
95 | 376k | if (m_mode != ModeState::M_ERROR) m_mode = ModeState::M_INVALID; Branch (95:13): [True: 6.34k, False: 0]
Branch (95:13): [True: 362k, False: 0]
Branch (95:13): [True: 7.26k, False: 0]
|
96 | 376k | return false; |
97 | 376k | } ValidationState<PackageValidationResult>::Invalid(PackageValidationResult, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) Line | Count | Source | 91 | 6.34k | { | 92 | 6.34k | m_result = result; | 93 | 6.34k | m_reject_reason = reject_reason; | 94 | 6.34k | m_debug_message = debug_message; | 95 | 6.34k | if (m_mode != ModeState::M_ERROR) m_mode = ModeState::M_INVALID; Branch (95:13): [True: 6.34k, False: 0]
| 96 | 6.34k | return false; | 97 | 6.34k | } |
ValidationState<TxValidationResult>::Invalid(TxValidationResult, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) Line | Count | Source | 91 | 362k | { | 92 | 362k | m_result = result; | 93 | 362k | m_reject_reason = reject_reason; | 94 | 362k | m_debug_message = debug_message; | 95 | 362k | if (m_mode != ModeState::M_ERROR) m_mode = ModeState::M_INVALID; Branch (95:13): [True: 362k, False: 0]
| 96 | 362k | return false; | 97 | 362k | } |
ValidationState<BlockValidationResult>::Invalid(BlockValidationResult, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) Line | Count | Source | 91 | 7.26k | { | 92 | 7.26k | m_result = result; | 93 | 7.26k | m_reject_reason = reject_reason; | 94 | 7.26k | m_debug_message = debug_message; | 95 | 7.26k | if (m_mode != ModeState::M_ERROR) m_mode = ModeState::M_INVALID; Branch (95:13): [True: 7.26k, False: 0]
| 96 | 7.26k | return false; | 97 | 7.26k | } |
|
98 | | bool Error(const std::string& reject_reason) |
99 | 0 | { |
100 | 0 | if (m_mode == ModeState::M_VALID) Branch (100:13): [True: 0, False: 0]
|
101 | 0 | m_reject_reason = reject_reason; |
102 | 0 | m_mode = ModeState::M_ERROR; |
103 | 0 | return false; |
104 | 0 | } |
105 | 9.67M | bool IsValid() const { return m_mode == ModeState::M_VALID; } ValidationState<TxValidationResult>::IsValid() const Line | Count | Source | 105 | 709k | bool IsValid() const { return m_mode == ModeState::M_VALID; } |
ValidationState<BlockValidationResult>::IsValid() const Line | Count | Source | 105 | 8.96M | bool IsValid() const { return m_mode == ModeState::M_VALID; } |
ValidationState<PackageValidationResult>::IsValid() const Line | Count | Source | 105 | 2.53k | bool IsValid() const { return m_mode == ModeState::M_VALID; } |
|
106 | 2.63M | bool IsInvalid() const { return m_mode == ModeState::M_INVALID; } ValidationState<BlockValidationResult>::IsInvalid() const Line | Count | Source | 106 | 2.24M | bool IsInvalid() const { return m_mode == ModeState::M_INVALID; } |
ValidationState<PackageValidationResult>::IsInvalid() const Line | Count | Source | 106 | 5.07k | bool IsInvalid() const { return m_mode == ModeState::M_INVALID; } |
ValidationState<TxValidationResult>::IsInvalid() const Line | Count | Source | 106 | 384k | bool IsInvalid() const { return m_mode == ModeState::M_INVALID; } |
|
107 | 0 | bool IsError() const { return m_mode == ModeState::M_ERROR; } |
108 | 1.53M | Result GetResult() const { return m_result; } ValidationState<BlockValidationResult>::GetResult() const Line | Count | Source | 108 | 11.0k | Result GetResult() const { return m_result; } |
ValidationState<TxValidationResult>::GetResult() const Line | Count | Source | 108 | 1.52M | Result GetResult() const { return m_result; } |
Unexecuted instantiation: ValidationState<PackageValidationResult>::GetResult() const |
109 | 2.51k | std::string GetRejectReason() const { return m_reject_reason; } ValidationState<TxValidationResult>::GetRejectReason[abi:cxx11]() const Line | Count | Source | 109 | 2.51k | std::string GetRejectReason() const { return m_reject_reason; } |
Unexecuted instantiation: ValidationState<PackageValidationResult>::GetRejectReason[abi:cxx11]() const Unexecuted instantiation: ValidationState<BlockValidationResult>::GetRejectReason[abi:cxx11]() const |
110 | 2.51k | std::string GetDebugMessage() const { return m_debug_message; } |
111 | | std::string ToString() const |
112 | 2.61M | { |
113 | 2.61M | if (IsValid()) { Branch (113:13): [True: 2.23M, False: 16.0k]
Branch (113:13): [True: 0, False: 358k]
Branch (113:13): [True: 0, False: 0]
|
114 | 2.23M | return "Valid"; |
115 | 2.23M | } |
116 | | |
117 | 374k | if (!m_debug_message.empty()) { Branch (117:13): [True: 15.2k, False: 758]
Branch (117:13): [True: 22.3k, False: 336k]
Branch (117:13): [True: 0, False: 0]
|
118 | 37.6k | return m_reject_reason + ", " + m_debug_message; |
119 | 37.6k | } |
120 | | |
121 | 337k | return m_reject_reason; |
122 | 374k | } ValidationState<BlockValidationResult>::ToString[abi:cxx11]() const Line | Count | Source | 112 | 2.25M | { | 113 | 2.25M | if (IsValid()) { Branch (113:13): [True: 2.23M, False: 16.0k]
| 114 | 2.23M | return "Valid"; | 115 | 2.23M | } | 116 | | | 117 | 16.0k | if (!m_debug_message.empty()) { Branch (117:13): [True: 15.2k, False: 758]
| 118 | 15.2k | return m_reject_reason + ", " + m_debug_message; | 119 | 15.2k | } | 120 | | | 121 | 758 | return m_reject_reason; | 122 | 16.0k | } |
ValidationState<TxValidationResult>::ToString[abi:cxx11]() const Line | Count | Source | 112 | 358k | { | 113 | 358k | if (IsValid()) { Branch (113:13): [True: 0, False: 358k]
| 114 | 0 | return "Valid"; | 115 | 0 | } | 116 | | | 117 | 358k | if (!m_debug_message.empty()) { Branch (117:13): [True: 22.3k, False: 336k]
| 118 | 22.3k | return m_reject_reason + ", " + m_debug_message; | 119 | 22.3k | } | 120 | | | 121 | 336k | return m_reject_reason; | 122 | 358k | } |
Unexecuted instantiation: ValidationState<PackageValidationResult>::ToString[abi:cxx11]() const |
123 | | }; |
124 | | |
125 | | class TxValidationState : public ValidationState<TxValidationResult> {}; |
126 | | class BlockValidationState : public ValidationState<BlockValidationResult> {}; |
127 | | |
128 | | // These implement the weight = (stripped_size * 4) + witness_size formula, |
129 | | // using only serialization with and without witness data. As witness_size |
130 | | // is equal to total_size - stripped_size, this formula is identical to: |
131 | | // weight = (stripped_size * 3) + total_size. |
132 | | static inline int32_t GetTransactionWeight(const CTransaction& tx) |
133 | 1.07M | { |
134 | 1.07M | return ::GetSerializeSize(TX_NO_WITNESS(tx)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(tx)); |
135 | 1.07M | } Unexecuted instantiation: init.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: net_processing.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: blockmanager_args.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: blockstorage.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: chainstate.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: chainstatemanager_args.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: context.cpp:GetTransactionWeight(CTransaction const&) interfaces.cpp:GetTransactionWeight(CTransaction const&) Line | Count | Source | 133 | 63.2k | { | 134 | 63.2k | return ::GetSerializeSize(TX_NO_WITNESS(tx)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(tx)); | 135 | 63.2k | } |
Unexecuted instantiation: mempool_persist.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: mempool_persist_args.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: miner.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: mini_miner.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: peerman_args.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: transaction.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: txdownloadman_impl.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: fees.cpp:GetTransactionWeight(CTransaction const&) packages.cpp:GetTransactionWeight(CTransaction const&) Line | Count | Source | 133 | 8.93k | { | 134 | 8.93k | return ::GetSerializeSize(TX_NO_WITNESS(tx)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(tx)); | 135 | 8.93k | } |
Unexecuted instantiation: rbf.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: rest.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: blockchain.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: mempool.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: mining.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: net.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: rawtransaction.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: server.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: server_util.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: txoutproof.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: signet.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: txmempool.cpp:GetTransactionWeight(CTransaction const&) txorphanage.cpp:GetTransactionWeight(CTransaction const&) Line | Count | Source | 133 | 608k | { | 134 | 608k | return ::GetSerializeSize(TX_NO_WITNESS(tx)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(tx)); | 135 | 608k | } |
Unexecuted instantiation: validation.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: validationinterface.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: blockencodings.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: tx_verify.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: base.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: blockfilterindex.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: coinstatsindex.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: txindex.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: coinstats.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: coin.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: utxo_snapshot.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: ephemeral_policy.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: truc_policy.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: spend.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: wallet.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: feebumper.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: transactions.cpp:GetTransactionWeight(CTransaction const&) Unexecuted instantiation: core_write.cpp:GetTransactionWeight(CTransaction const&) policy.cpp:GetTransactionWeight(CTransaction const&) Line | Count | Source | 133 | 397k | { | 134 | 397k | return ::GetSerializeSize(TX_NO_WITNESS(tx)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(tx)); | 135 | 397k | } |
Unexecuted instantiation: tx_check.cpp:GetTransactionWeight(CTransaction const&) |
136 | | static inline int64_t GetBlockWeight(const CBlock& block) |
137 | 2.23M | { |
138 | 2.23M | return ::GetSerializeSize(TX_NO_WITNESS(block)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(block)); |
139 | 2.23M | } Unexecuted instantiation: init.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: net_processing.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: blockmanager_args.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: blockstorage.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: chainstate.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: chainstatemanager_args.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: context.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: interfaces.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: mempool_persist.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: mempool_persist_args.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: miner.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: mini_miner.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: peerman_args.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: transaction.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: txdownloadman_impl.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: fees.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: packages.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: rbf.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: rest.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: blockchain.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: mempool.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: mining.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: net.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: rawtransaction.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: server.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: server_util.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: txoutproof.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: signet.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: txmempool.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: txorphanage.cpp:GetBlockWeight(CBlock const&) validation.cpp:GetBlockWeight(CBlock const&) Line | Count | Source | 137 | 2.23M | { | 138 | 2.23M | return ::GetSerializeSize(TX_NO_WITNESS(block)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(block)); | 139 | 2.23M | } |
Unexecuted instantiation: validationinterface.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: blockencodings.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: tx_verify.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: base.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: blockfilterindex.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: coinstatsindex.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: txindex.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: coinstats.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: coin.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: utxo_snapshot.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: ephemeral_policy.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: truc_policy.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: spend.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: wallet.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: feebumper.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: transactions.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: core_write.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: policy.cpp:GetBlockWeight(CBlock const&) Unexecuted instantiation: tx_check.cpp:GetBlockWeight(CBlock const&) |
140 | | static inline int64_t GetTransactionInputWeight(const CTxIn& txin) |
141 | 0 | { |
142 | | // scriptWitness size is added here because witnesses and txins are split up in segwit serialization. |
143 | 0 | return ::GetSerializeSize(TX_NO_WITNESS(txin)) * (WITNESS_SCALE_FACTOR - 1) + ::GetSerializeSize(TX_WITH_WITNESS(txin)) + ::GetSerializeSize(txin.scriptWitness.stack); |
144 | 0 | } Unexecuted instantiation: init.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: net_processing.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: blockmanager_args.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: blockstorage.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: chainstate.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: chainstatemanager_args.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: context.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: interfaces.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: mempool_persist.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: mempool_persist_args.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: miner.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: mini_miner.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: peerman_args.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: transaction.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: txdownloadman_impl.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: fees.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: packages.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: rbf.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: rest.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: blockchain.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: mempool.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: mining.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: net.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: rawtransaction.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: server.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: server_util.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: txoutproof.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: signet.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: txmempool.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: txorphanage.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: validation.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: validationinterface.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: blockencodings.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: tx_verify.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: base.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: blockfilterindex.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: coinstatsindex.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: txindex.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: coinstats.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: coin.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: utxo_snapshot.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: ephemeral_policy.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: truc_policy.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: spend.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: wallet.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: feebumper.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: transactions.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: core_write.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: policy.cpp:GetTransactionInputWeight(CTxIn const&) Unexecuted instantiation: tx_check.cpp:GetTransactionInputWeight(CTxIn const&) |
145 | | |
146 | | /** Compute at which vout of the block's coinbase transaction the witness commitment occurs, or -1 if not found */ |
147 | | inline int GetWitnessCommitmentIndex(const CBlock& block) |
148 | 2.24M | { |
149 | 2.24M | int commitpos = NO_WITNESS_COMMITMENT; |
150 | 2.24M | if (!block.vtx.empty()) { Branch (150:9): [True: 2.24M, False: 0]
|
151 | 6.73M | for (size_t o = 0; o < block.vtx[0]->vout.size(); o++) { Branch (151:28): [True: 4.48M, False: 2.24M]
|
152 | 4.48M | const CTxOut& vout = block.vtx[0]->vout[o]; |
153 | 4.48M | if (vout.scriptPubKey.size() >= MINIMUM_WITNESS_COMMITMENT && Branch (153:17): [True: 2.24M, False: 2.24M]
|
154 | 4.48M | vout.scriptPubKey[0] == OP_RETURN && Branch (154:17): [True: 2.24M, False: 0]
|
155 | 4.48M | vout.scriptPubKey[1] == 0x24 && Branch (155:17): [True: 2.24M, False: 0]
|
156 | 4.48M | vout.scriptPubKey[2] == 0xaa && Branch (156:17): [True: 2.24M, False: 0]
|
157 | 4.48M | vout.scriptPubKey[3] == 0x21 && Branch (157:17): [True: 2.24M, False: 0]
|
158 | 4.48M | vout.scriptPubKey[4] == 0xa9 && Branch (158:17): [True: 2.24M, False: 0]
|
159 | 4.48M | vout.scriptPubKey[5] == 0xed) { Branch (159:17): [True: 2.24M, False: 0]
|
160 | 2.24M | commitpos = o; |
161 | 2.24M | } |
162 | 4.48M | } |
163 | 2.24M | } |
164 | 2.24M | return commitpos; |
165 | 2.24M | } |
166 | | |
167 | | #endif // BITCOIN_CONSENSUS_VALIDATION_H |