mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-04-29 14:59:39 -04:00
qa: use prev height as nLockTime for coinbase txs created in unit tests
We don't set the nSequence as it will be set directly in the block template generator in a following commit.
This commit is contained in:
parent
c76dbe9b8b
commit
788aeebf34
2 changed files with 4 additions and 1 deletions
|
@ -81,6 +81,7 @@ CBlock BuildChainTestingSetup::CreateBlock(const CBlockIndex* prev,
|
|||
}
|
||||
{
|
||||
CMutableTransaction tx_coinbase{*block.vtx.at(0)};
|
||||
tx_coinbase.nLockTime = static_cast<uint32_t>(prev->nHeight);
|
||||
tx_coinbase.vin.at(0).scriptSig = CScript{} << prev->nHeight + 1;
|
||||
block.vtx.at(0) = MakeTransactionRef(std::move(tx_coinbase));
|
||||
block.hashMerkleRoot = BlockMerkleRoot(block);
|
||||
|
|
|
@ -82,7 +82,9 @@ std::shared_ptr<CBlock> MinerTestingSetup::Block(const uint256& prev_hash)
|
|||
txCoinbase.vout[0].nValue = 0;
|
||||
txCoinbase.vin[0].scriptWitness.SetNull();
|
||||
// Always pad with OP_0 at the end to avoid bad-cb-length error
|
||||
txCoinbase.vin[0].scriptSig = CScript{} << WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight + 1) << OP_0;
|
||||
const int prev_height{WITH_LOCK(::cs_main, return m_node.chainman->m_blockman.LookupBlockIndex(prev_hash)->nHeight)};
|
||||
txCoinbase.vin[0].scriptSig = CScript{} << prev_height + 1 << OP_0;
|
||||
txCoinbase.nLockTime = static_cast<uint32_t>(prev_height);
|
||||
pblock->vtx[0] = MakeTransactionRef(std::move(txCoinbase));
|
||||
|
||||
return pblock;
|
||||
|
|
Loading…
Add table
Reference in a new issue