qa: timelock coinbase transactions created in fuzz targets

This commit is contained in:
Antoine Poinsot
2025-04-21 14:47:39 -04:00
parent 9c94069d8b
commit c76dbe9b8b
3 changed files with 8 additions and 2 deletions

View File

@@ -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());