mirror of
https://github.com/bitcoin/bitcoin.git
synced 2026-04-03 20:35:17 +02:00
qa: timelock coinbase transactions created in fuzz targets
This commit is contained in:
@@ -17,6 +17,8 @@
|
||||
#include <validationinterface.h>
|
||||
#include <versionbits.h>
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
using node::BlockAssembler;
|
||||
using node::NodeContext;
|
||||
|
||||
@@ -34,12 +36,15 @@ std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const
|
||||
{
|
||||
std::vector<std::shared_ptr<CBlock>> ret{total_height};
|
||||
auto time{params.GenesisBlock().nTime};
|
||||
// NOTE: here `height` does not correspond to the block height but the block height - 1.
|
||||
for (size_t height{0}; height < total_height; ++height) {
|
||||
CBlock& block{*(ret.at(height) = std::make_shared<CBlock>())};
|
||||
|
||||
CMutableTransaction coinbase_tx;
|
||||
coinbase_tx.nLockTime = static_cast<uint32_t>(height);
|
||||
coinbase_tx.vin.resize(1);
|
||||
coinbase_tx.vin[0].prevout.SetNull();
|
||||
coinbase_tx.vin[0].nSequence = CTxIn::MAX_SEQUENCE_NONFINAL; // Make sure timelock is enforced.
|
||||
coinbase_tx.vout.resize(1);
|
||||
coinbase_tx.vout[0].scriptPubKey = P2WSH_OP_TRUE;
|
||||
coinbase_tx.vout[0].nValue = GetBlockSubsidy(height + 1, params.GetConsensus());
|
||||
|
||||
Reference in New Issue
Block a user