Bitcoin Core 30.99.0
P2P Digital Currency
coinstatsindex.cpp
Go to the documentation of this file.
1// Copyright (c) 2020-2022 The Bitcoin Core developers
2// Distributed under the MIT software license, see the accompanying
3// file COPYING or http://www.opensource.org/licenses/mit-license.php.
4
6
7#include <arith_uint256.h>
8#include <chain.h>
9#include <chainparams.h>
10#include <coins.h>
11#include <common/args.h>
12#include <consensus/amount.h>
13#include <crypto/muhash.h>
14#include <dbwrapper.h>
15#include <index/base.h>
16#include <interfaces/chain.h>
17#include <interfaces/types.h>
18#include <kernel/coinstats.h>
19#include <logging.h>
20#include <primitives/block.h>
22#include <script/script.h>
23#include <serialize.h>
24#include <uint256.h>
25#include <undo.h>
26#include <util/check.h>
27#include <util/fs.h>
28#include <validation.h>
29
30#include <compare>
31#include <ios>
32#include <limits>
33#include <span>
34#include <string>
35#include <utility>
36#include <vector>
37
42
43static constexpr uint8_t DB_BLOCK_HASH{'s'};
44static constexpr uint8_t DB_BLOCK_HEIGHT{'t'};
45static constexpr uint8_t DB_MUHASH{'M'};
46
47namespace {
48
49struct DBVal {
50 uint256 muhash{uint256::ZERO};
51 uint64_t transaction_output_count{0};
52 uint64_t bogo_size{0};
53 CAmount total_amount{0};
54 CAmount total_subsidy{0};
55 arith_uint256 total_prevout_spent_amount{0};
56 arith_uint256 total_new_outputs_ex_coinbase_amount{0};
57 arith_uint256 total_coinbase_amount{0};
58 CAmount total_unspendables_genesis_block{0};
59 CAmount total_unspendables_bip30{0};
60 CAmount total_unspendables_scripts{0};
61 CAmount total_unspendables_unclaimed_rewards{0};
62
63 SERIALIZE_METHODS(DBVal, obj)
64 {
65 uint256 prevout_spent, new_outputs, coinbase;
66 SER_WRITE(obj, prevout_spent = ArithToUint256(obj.total_prevout_spent_amount));
67 SER_WRITE(obj, new_outputs = ArithToUint256(obj.total_new_outputs_ex_coinbase_amount));
68 SER_WRITE(obj, coinbase = ArithToUint256(obj.total_coinbase_amount));
69
70 READWRITE(obj.muhash);
71 READWRITE(obj.transaction_output_count);
72 READWRITE(obj.bogo_size);
73 READWRITE(obj.total_amount);
74 READWRITE(obj.total_subsidy);
75 READWRITE(prevout_spent);
76 READWRITE(new_outputs);
77 READWRITE(coinbase);
78 READWRITE(obj.total_unspendables_genesis_block);
79 READWRITE(obj.total_unspendables_bip30);
80 READWRITE(obj.total_unspendables_scripts);
81 READWRITE(obj.total_unspendables_unclaimed_rewards);
82
83 SER_READ(obj, obj.total_prevout_spent_amount = UintToArith256(prevout_spent));
84 SER_READ(obj, obj.total_new_outputs_ex_coinbase_amount = UintToArith256(new_outputs));
85 SER_READ(obj, obj.total_coinbase_amount = UintToArith256(coinbase));
86 }
87};
88
89struct DBHeightKey {
90 int height;
91
92 explicit DBHeightKey(int height_in) : height(height_in) {}
93
94 template <typename Stream>
95 void Serialize(Stream& s) const
96 {
98 ser_writedata32be(s, height);
99 }
100
101 template <typename Stream>
102 void Unserialize(Stream& s)
103 {
104 const uint8_t prefix{ser_readdata8(s)};
105 if (prefix != DB_BLOCK_HEIGHT) {
106 throw std::ios_base::failure("Invalid format for coinstatsindex DB height key");
107 }
108 height = ser_readdata32be(s);
109 }
110};
111
112struct DBHashKey {
113 uint256 block_hash;
114
115 explicit DBHashKey(const uint256& hash_in) : block_hash(hash_in) {}
116
117 SERIALIZE_METHODS(DBHashKey, obj)
118 {
119 uint8_t prefix{DB_BLOCK_HASH};
121 if (prefix != DB_BLOCK_HASH) {
122 throw std::ios_base::failure("Invalid format for coinstatsindex DB hash key");
123 }
124
125 READWRITE(obj.block_hash);
126 }
127};
128
129}; // namespace
130
131std::unique_ptr<CoinStatsIndex> g_coin_stats_index;
132
133CoinStatsIndex::CoinStatsIndex(std::unique_ptr<interfaces::Chain> chain, size_t n_cache_size, bool f_memory, bool f_wipe)
134 : BaseIndex(std::move(chain), "coinstatsindex")
135{
136 // An earlier version of the index used "indexes/coinstats" but it contained
137 // a bug and is superseded by a fixed version at "indexes/coinstatsindex".
138 // The original index is kept around until the next release in case users
139 // decide to downgrade their node.
140 auto old_path = gArgs.GetDataDirNet() / "indexes" / "coinstats";
141 if (fs::exists(old_path)) {
142 // TODO: Change this to deleting the old index with v31.
143 LogWarning("Old version of coinstatsindex found at %s. This folder can be safely deleted unless you " \
144 "plan to downgrade your node to version 29 or lower.", fs::PathToString(old_path));
145 }
146 fs::path path{gArgs.GetDataDirNet() / "indexes" / "coinstatsindex"};
148
149 m_db = std::make_unique<CoinStatsIndex::DB>(path / "db", n_cache_size, f_memory, f_wipe);
150}
151
153{
154 const CAmount block_subsidy{GetBlockSubsidy(block.height, Params().GetConsensus())};
155 m_total_subsidy += block_subsidy;
156
157 // Ignore genesis block
158 if (block.height > 0) {
159 uint256 expected_block_hash{*Assert(block.prev_hash)};
160 if (m_current_block_hash != expected_block_hash) {
161 LogError("previous block header belongs to unexpected block %s; expected %s",
162 m_current_block_hash.ToString(), expected_block_hash.ToString());
163 return false;
164 }
165
166 // Add the new utxos created from the block
167 assert(block.data);
168 for (size_t i = 0; i < block.data->vtx.size(); ++i) {
169 const auto& tx{block.data->vtx.at(i)};
170 const bool is_coinbase{tx->IsCoinBase()};
171
172 // Skip duplicate txid coinbase transactions (BIP30).
173 if (is_coinbase && IsBIP30Unspendable(block.hash, block.height)) {
174 m_total_unspendables_bip30 += block_subsidy;
175 continue;
176 }
177
178 for (uint32_t j = 0; j < tx->vout.size(); ++j) {
179 const CTxOut& out{tx->vout[j]};
180 const Coin coin{out, block.height, is_coinbase};
181 const COutPoint outpoint{tx->GetHash(), j};
182
183 // Skip unspendable coins
184 if (coin.out.scriptPubKey.IsUnspendable()) {
185 m_total_unspendables_scripts += coin.out.nValue;
186 continue;
187 }
188
189 ApplyCoinHash(m_muhash, outpoint, coin);
190
191 if (is_coinbase) {
192 m_total_coinbase_amount += coin.out.nValue;
193 } else {
195 }
196
198 m_total_amount += coin.out.nValue;
199 m_bogo_size += GetBogoSize(coin.out.scriptPubKey);
200 }
201
202 // The coinbase tx has no undo data since no former output is spent
203 if (!is_coinbase) {
204 const auto& tx_undo{Assert(block.undo_data)->vtxundo.at(i - 1)};
205
206 for (size_t j = 0; j < tx_undo.vprevout.size(); ++j) {
207 const Coin& coin{tx_undo.vprevout[j]};
208 const COutPoint outpoint{tx->vin[j].prevout.hash, tx->vin[j].prevout.n};
209
210 RemoveCoinHash(m_muhash, outpoint, coin);
211
212 m_total_prevout_spent_amount += coin.out.nValue;
213
215 m_total_amount -= coin.out.nValue;
216 m_bogo_size -= GetBogoSize(coin.out.scriptPubKey);
217 }
218 }
219 }
220 } else {
221 // genesis block
222 m_total_unspendables_genesis_block += block_subsidy;
223 }
224
225 // If spent prevouts + block subsidy are still a higher amount than
226 // new outputs + coinbase + current unspendable amount this means
227 // the miner did not claim the full block reward. Unclaimed block
228 // rewards are also unspendable.
231 assert(unclaimed_rewards <= arith_uint256(std::numeric_limits<CAmount>::max()));
232 m_total_unspendables_unclaimed_rewards += static_cast<CAmount>(unclaimed_rewards.GetLow64());
233
234 std::pair<uint256, DBVal> value;
235 value.first = block.hash;
236 value.second.transaction_output_count = m_transaction_output_count;
237 value.second.bogo_size = m_bogo_size;
238 value.second.total_amount = m_total_amount;
239 value.second.total_subsidy = m_total_subsidy;
240 value.second.total_prevout_spent_amount = m_total_prevout_spent_amount;
241 value.second.total_new_outputs_ex_coinbase_amount = m_total_new_outputs_ex_coinbase_amount;
242 value.second.total_coinbase_amount = m_total_coinbase_amount;
243 value.second.total_unspendables_genesis_block = m_total_unspendables_genesis_block;
244 value.second.total_unspendables_bip30 = m_total_unspendables_bip30;
245 value.second.total_unspendables_scripts = m_total_unspendables_scripts;
246 value.second.total_unspendables_unclaimed_rewards = m_total_unspendables_unclaimed_rewards;
247
248 uint256 out;
250 value.second.muhash = out;
251
253
254 // Intentionally do not update DB_MUHASH here so it stays in sync with
255 // DB_BEST_BLOCK, and the index is not corrupted if there is an unclean shutdown.
256 return m_db->Write(DBHeightKey(block.height), value);
257}
258
259[[nodiscard]] static bool CopyHeightIndexToHashIndex(CDBIterator& db_it, CDBBatch& batch,
260 const std::string& index_name, int height)
261{
262 DBHeightKey key{height};
263 db_it.Seek(key);
264
265 if (!db_it.GetKey(key) || key.height != height) {
266 LogError("unexpected key in %s: expected (%c, %d)",
267 index_name, DB_BLOCK_HEIGHT, height);
268 return false;
269 }
270
271 std::pair<uint256, DBVal> value;
272 if (!db_it.GetValue(value)) {
273 LogError("unable to read value in %s at key (%c, %d)",
274 index_name, DB_BLOCK_HEIGHT, height);
275 return false;
276 }
277
278 batch.Write(DBHashKey(value.first), value.second);
279 return true;
280}
281
283{
284 CDBBatch batch(*m_db);
285 std::unique_ptr<CDBIterator> db_it(m_db->NewIterator());
286
287 // During a reorg, copy the block's hash digest from the height index to the hash index,
288 // ensuring it's still accessible after the height index entry is overwritten.
289 if (!CopyHeightIndexToHashIndex(*db_it, batch, m_name, block.height)) {
290 return false;
291 }
292
293 if (!m_db->WriteBatch(batch)) return false;
294
295 if (!RevertBlock(block)) {
296 return false; // failure cause logged internally
297 }
298
299 return true;
300}
301
302static bool LookUpOne(const CDBWrapper& db, const interfaces::BlockRef& block, DBVal& result)
303{
304 // First check if the result is stored under the height index and the value
305 // there matches the block hash. This should be the case if the block is on
306 // the active chain.
307 std::pair<uint256, DBVal> read_out;
308 if (!db.Read(DBHeightKey(block.height), read_out)) {
309 return false;
310 }
311 if (read_out.first == block.hash) {
312 result = std::move(read_out.second);
313 return true;
314 }
315
316 // If value at the height index corresponds to an different block, the
317 // result will be stored in the hash index.
318 return db.Read(DBHashKey(block.hash), result);
319}
320
321std::optional<CCoinsStats> CoinStatsIndex::LookUpStats(const CBlockIndex& block_index) const
322{
323 CCoinsStats stats{block_index.nHeight, block_index.GetBlockHash()};
324 stats.index_used = true;
325
326 DBVal entry;
327 if (!LookUpOne(*m_db, {block_index.GetBlockHash(), block_index.nHeight}, entry)) {
328 return std::nullopt;
329 }
330
331 stats.hashSerialized = entry.muhash;
332 stats.nTransactionOutputs = entry.transaction_output_count;
333 stats.nBogoSize = entry.bogo_size;
334 stats.total_amount = entry.total_amount;
335 stats.total_subsidy = entry.total_subsidy;
336 stats.total_prevout_spent_amount = entry.total_prevout_spent_amount;
337 stats.total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
338 stats.total_coinbase_amount = entry.total_coinbase_amount;
339 stats.total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
340 stats.total_unspendables_bip30 = entry.total_unspendables_bip30;
341 stats.total_unspendables_scripts = entry.total_unspendables_scripts;
342 stats.total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
343
344 return stats;
345}
346
347bool CoinStatsIndex::CustomInit(const std::optional<interfaces::BlockRef>& block)
348{
349 if (!m_db->Read(DB_MUHASH, m_muhash)) {
350 // Check that the cause of the read failure is that the key does not
351 // exist. Any other errors indicate database corruption or a disk
352 // failure, and starting the index would cause further corruption.
353 if (m_db->Exists(DB_MUHASH)) {
354 LogError("Cannot read current %s state; index may be corrupted",
355 GetName());
356 return false;
357 }
358 }
359
360 if (block) {
361 DBVal entry;
362 if (!LookUpOne(*m_db, *block, entry)) {
363 LogError("Cannot read current %s state; index may be corrupted",
364 GetName());
365 return false;
366 }
367
368 uint256 out;
370 if (entry.muhash != out) {
371 LogError("Cannot read current %s state; index may be corrupted",
372 GetName());
373 return false;
374 }
375
376 m_transaction_output_count = entry.transaction_output_count;
377 m_bogo_size = entry.bogo_size;
378 m_total_amount = entry.total_amount;
379 m_total_subsidy = entry.total_subsidy;
380 m_total_prevout_spent_amount = entry.total_prevout_spent_amount;
381 m_total_new_outputs_ex_coinbase_amount = entry.total_new_outputs_ex_coinbase_amount;
382 m_total_coinbase_amount = entry.total_coinbase_amount;
383 m_total_unspendables_genesis_block = entry.total_unspendables_genesis_block;
384 m_total_unspendables_bip30 = entry.total_unspendables_bip30;
385 m_total_unspendables_scripts = entry.total_unspendables_scripts;
386 m_total_unspendables_unclaimed_rewards = entry.total_unspendables_unclaimed_rewards;
387 m_current_block_hash = block->hash;
388 }
389
390 return true;
391}
392
394{
395 // DB_MUHASH should always be committed in a batch together with DB_BEST_BLOCK
396 // to prevent an inconsistent state of the DB.
397 batch.Write(DB_MUHASH, m_muhash);
398 return true;
399}
400
402{
404 options.connect_undo_data = true;
405 options.disconnect_data = true;
406 options.disconnect_undo_data = true;
407 return options;
408}
409
410// Revert a single block as part of a reorg
412{
413 std::pair<uint256, DBVal> read_out;
414
415 // Ignore genesis block
416 if (block.height > 0) {
417 if (!m_db->Read(DBHeightKey(block.height - 1), read_out)) {
418 return false;
419 }
420
421 uint256 expected_block_hash{*block.prev_hash};
422 if (read_out.first != expected_block_hash) {
423 LogWarning("previous block header belongs to unexpected block %s; expected %s",
424 read_out.first.ToString(), expected_block_hash.ToString());
425
426 if (!m_db->Read(DBHashKey(expected_block_hash), read_out)) {
427 LogError("previous block header not found; expected %s",
428 expected_block_hash.ToString());
429 return false;
430 }
431 }
432 }
433
434 // Roll back muhash by removing the new UTXOs that were created by the
435 // block and reapplying the old UTXOs that were spent by the block
436 assert(block.data);
437 assert(block.undo_data);
438 for (size_t i = 0; i < block.data->vtx.size(); ++i) {
439 const auto& tx{block.data->vtx.at(i)};
440 const bool is_coinbase{tx->IsCoinBase()};
441
442 if (is_coinbase && IsBIP30Unspendable(block.hash, block.height)) {
443 continue;
444 }
445
446 for (uint32_t j = 0; j < tx->vout.size(); ++j) {
447 const CTxOut& out{tx->vout[j]};
448 const COutPoint outpoint{tx->GetHash(), j};
449 const Coin coin{out, block.height, is_coinbase};
450
451 if (!coin.out.scriptPubKey.IsUnspendable()) {
452 RemoveCoinHash(m_muhash, outpoint, coin);
453 }
454 }
455
456 // The coinbase tx has no undo data since no former output is spent
457 if (!is_coinbase) {
458 const auto& tx_undo{block.undo_data->vtxundo.at(i - 1)};
459
460 for (size_t j = 0; j < tx_undo.vprevout.size(); ++j) {
461 const Coin& coin{tx_undo.vprevout[j]};
462 const COutPoint outpoint{tx->vin[j].prevout.hash, tx->vin[j].prevout.n};
463 ApplyCoinHash(m_muhash, outpoint, coin);
464 }
465 }
466 }
467
468 // Check that the rolled back muhash is consistent with the DB read out
469 uint256 out;
471 Assert(read_out.second.muhash == out);
472
473 // Apply the other values from the DB to the member variables
474 m_transaction_output_count = read_out.second.transaction_output_count;
475 m_total_amount = read_out.second.total_amount;
476 m_bogo_size = read_out.second.bogo_size;
477 m_total_subsidy = read_out.second.total_subsidy;
478 m_total_prevout_spent_amount = read_out.second.total_prevout_spent_amount;
479 m_total_new_outputs_ex_coinbase_amount = read_out.second.total_new_outputs_ex_coinbase_amount;
480 m_total_coinbase_amount = read_out.second.total_coinbase_amount;
481 m_total_unspendables_genesis_block = read_out.second.total_unspendables_genesis_block;
482 m_total_unspendables_bip30 = read_out.second.total_unspendables_bip30;
483 m_total_unspendables_scripts = read_out.second.total_unspendables_scripts;
484 m_total_unspendables_unclaimed_rewards = read_out.second.total_unspendables_unclaimed_rewards;
486
487 return true;
488}
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
ArgsManager gArgs
Definition: args.cpp:40
arith_uint256 UintToArith256(const uint256 &a)
uint256 ArithToUint256(const arith_uint256 &a)
const CChainParams & Params()
Return the currently selected parameters.
#define Assert(val)
Identity function.
Definition: check.h:115
fs::path GetDataDirNet() const
Get data directory path with appended network identifier.
Definition: args.h:235
Base class for indices of blockchain data.
Definition: base.h:55
const std::string & GetName() const LIFETIMEBOUND
Get the name of the index for display in logs.
Definition: base.h:151
const std::string m_name
Definition: base.h:118
std::vector< CTransactionRef > vtx
Definition: block.h:72
The block chain is a tree shaped structure starting with the genesis block at the root,...
Definition: chain.h:144
uint256 GetBlockHash() const
Definition: chain.h:248
int nHeight
height of the entry in the chain. The genesis block has height 0
Definition: chain.h:156
std::vector< CTxUndo > vtxundo
Definition: undo.h:65
Batch of changes queued to be written to a CDBWrapper.
Definition: dbwrapper.h:72
void Write(const K &key, const V &value)
Definition: dbwrapper.h:96
bool GetValue(V &value)
Definition: dbwrapper.h:164
bool GetKey(K &key)
Definition: dbwrapper.h:154
void Seek(const K &key)
Definition: dbwrapper.h:145
bool Read(const K &key, V &value) const
Definition: dbwrapper.h:213
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:29
Txid hash
Definition: transaction.h:31
An output of a transaction.
Definition: transaction.h:150
A UTXO entry.
Definition: coins.h:33
CAmount m_total_subsidy
arith_uint256 m_total_new_outputs_ex_coinbase_amount
interfaces::Chain::NotifyOptions CustomOptions() override
Return custom notification options for index.
bool CustomInit(const std::optional< interfaces::BlockRef > &block) override
Initialize internal state from the database and block index.
CAmount m_total_unspendables_genesis_block
bool CustomRemove(const interfaces::BlockInfo &block) override
Rewind index by one block during a chain reorg.
CoinStatsIndex(std::unique_ptr< interfaces::Chain > chain, size_t n_cache_size, bool f_memory=false, bool f_wipe=false)
CAmount m_total_unspendables_scripts
CAmount m_total_amount
uint64_t m_bogo_size
uint64_t m_transaction_output_count
bool CustomAppend(const interfaces::BlockInfo &block) override
Write update index entries for a newly connected block.
arith_uint256 m_total_prevout_spent_amount
uint256 m_current_block_hash
MuHash3072 m_muhash
std::optional< kernel::CCoinsStats > LookUpStats(const CBlockIndex &block_index) const
std::unique_ptr< BaseIndex::DB > m_db
bool CustomCommit(CDBBatch &batch) override
Virtual method called internally by Commit that can be overridden to atomically commit more index sta...
arith_uint256 m_total_coinbase_amount
CAmount m_total_unspendables_bip30
CAmount m_total_unspendables_unclaimed_rewards
bool RevertBlock(const interfaces::BlockInfo &block)
void Finalize(uint256 &out) noexcept
Definition: muhash.cpp:552
256-bit unsigned big integer.
std::string ToString() const
Definition: uint256.cpp:21
256-bit opaque blob.
Definition: uint256.h:196
static const uint256 ZERO
Definition: uint256.h:204
static constexpr uint8_t DB_MUHASH
std::unique_ptr< CoinStatsIndex > g_coin_stats_index
The global UTXO set hash object.
static bool LookUpOne(const CDBWrapper &db, const interfaces::BlockRef &block, DBVal &result)
static constexpr uint8_t DB_BLOCK_HASH
static bool CopyHeightIndexToHashIndex(CDBIterator &db_it, CDBBatch &batch, const std::string &index_name, int height)
static constexpr uint8_t DB_BLOCK_HEIGHT
static bool create_directories(const std::filesystem::path &p)
Create directory (and if necessary its parents), unless the leaf directory already exists or is a sym...
Definition: fs.h:196
static bool exists(const path &p)
Definition: fs.h:95
static std::string PathToString(const path &path)
Convert path object to a byte string.
Definition: fs.h:157
#define LogWarning(...)
Definition: logging.h:369
#define LogError(...)
Definition: logging.h:370
void RemoveCoinHash(MuHash3072 &muhash, const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:70
static void ApplyCoinHash(HashWriter &ss, const COutPoint &outpoint, const Coin &coin)
Definition: coinstats.cpp:58
uint64_t GetBogoSize(const CScript &script_pub_key)
Definition: coinstats.cpp:40
const char * prefix
Definition: rest.cpp:1117
#define SER_WRITE(obj, code)
Definition: serialize.h:147
void Serialize(Stream &, V)=delete
uint8_t ser_readdata8(Stream &s)
Definition: serialize.h:78
void ser_writedata32be(Stream &s, uint32_t obj)
Definition: serialize.h:68
#define SERIALIZE_METHODS(cls, obj)
Implement the Serialize and Unserialize methods by delegating to a single templated static method tha...
Definition: serialize.h:229
void Unserialize(Stream &, V)=delete
#define SER_READ(obj, code)
Definition: serialize.h:146
void ser_writedata8(Stream &s, uint8_t obj)
Definition: serialize.h:54
uint32_t ser_readdata32be(Stream &s)
Definition: serialize.h:96
#define READWRITE(...)
Definition: serialize.h:145
Block data sent with blockConnected, blockDisconnected notifications.
Definition: chain.h:80
const uint256 * prev_hash
Definition: chain.h:82
const CBlock * data
Definition: chain.h:86
const uint256 & hash
Definition: chain.h:81
const CBlockUndo * undo_data
Definition: chain.h:87
Hash/height pair to help track and identify blocks.
Definition: types.h:13
uint256 hash
Definition: types.h:14
Options specifying which chain notifications are required.
Definition: chain.h:332
bool connect_undo_data
Include undo data with block connected notifications.
Definition: chain.h:334
bool disconnect_undo_data
Include undo data with block disconnected notifications.
Definition: chain.h:338
bool disconnect_data
Include block data with block disconnected notifications.
Definition: chain.h:336
CAmount GetBlockSubsidy(int nHeight, const Consensus::Params &consensusParams)
bool IsBIP30Unspendable(const uint256 &block_hash, int block_height)
Identifies blocks which coinbase output was subsequently overwritten in the UTXO set (see BIP30)
assert(!tx.IsCoinBase())