Drop script_pub_key arg from createNewBlock

Providing a script for the coinbase transaction is only done in test code
and for CPU solo mining.

Production miners use the getblocktemplate RPC which omits the coinbase
transaction entirely from its block template, leaving it to external (pool)
software to construct it.

A coinbase script can still be passed via BlockCreateOptions instead.

A temporary overload is added so that the test can be modified in the
next commit.
This commit is contained in:
Sjors Provoost
2024-11-21 10:48:26 +01:00
parent 7ab733ede4
commit ff41b9e296
7 changed files with 39 additions and 16 deletions

View File

@@ -169,14 +169,22 @@ public:
explicit BlockAssembler(Chainstate& chainstate, const CTxMemPool* mempool, const Options& options);
/** Construct a new block template with coinbase to scriptPubKeyIn */
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn);
/** Construct a new block template */
std::unique_ptr<CBlockTemplate> CreateNewBlock();
/** Temporary overload for tests */
std::unique_ptr<CBlockTemplate> CreateNewBlock(const CScript& scriptPubKeyIn)
{
m_options.coinbase_output_script = scriptPubKeyIn;
return CreateNewBlock();
};
inline static std::optional<int64_t> m_last_block_num_txs{};
inline static std::optional<int64_t> m_last_block_weight{};
private:
const Options m_options;
// TODO: make const again
Options m_options;
// utility functions
/** Clear the block's state and prepare for assembling a new block */