2021-12-30 19:36:57 +02:00
|
|
|
// Copyright (c) 2019-2021 The Bitcoin Core developers
|
2019-11-25 02:44:40 +01:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
|
|
|
#ifndef BITCOIN_TEST_UTIL_MINING_H
|
|
|
|
#define BITCOIN_TEST_UTIL_MINING_H
|
|
|
|
|
2022-12-15 15:15:22 +00:00
|
|
|
#include <node/miner.h>
|
|
|
|
|
2019-11-25 02:44:40 +01:00
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
2021-04-03 13:39:42 +02:00
|
|
|
#include <vector>
|
2019-11-25 02:44:40 +01:00
|
|
|
|
|
|
|
class CBlock;
|
2021-04-03 13:39:42 +02:00
|
|
|
class CChainParams;
|
2023-05-02 17:17:10 +02:00
|
|
|
class COutPoint;
|
2019-11-25 02:44:40 +01:00
|
|
|
class CScript;
|
2021-11-12 10:06:00 -05:00
|
|
|
namespace node {
|
2019-12-17 07:11:44 +07:00
|
|
|
struct NodeContext;
|
2021-11-12 10:06:00 -05:00
|
|
|
} // namespace node
|
2019-11-25 02:44:40 +01:00
|
|
|
|
2021-04-03 13:39:42 +02:00
|
|
|
/** Create a blockchain, starting from genesis */
|
|
|
|
std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const CChainParams& params);
|
|
|
|
|
2019-11-25 02:44:40 +01:00
|
|
|
/** Returns the generated coin */
|
2023-05-02 17:17:10 +02:00
|
|
|
COutPoint MineBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Returns the generated coin (or Null if the block was invalid).
|
|
|
|
* It is recommended to call RegenerateCommitments before mining the block to avoid merkle tree mismatches.
|
|
|
|
**/
|
|
|
|
COutPoint MineBlock(const node::NodeContext&, std::shared_ptr<CBlock>& block);
|
2019-11-25 02:44:40 +01:00
|
|
|
|
|
|
|
/** Prepare a block to be mined */
|
2021-11-12 10:06:00 -05:00
|
|
|
std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext&, const CScript& coinbase_scriptPubKey);
|
2022-12-15 15:15:22 +00:00
|
|
|
std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext& node, const CScript& coinbase_scriptPubKey,
|
|
|
|
const node::BlockAssembler::Options& assembler_options);
|
2019-11-25 02:44:40 +01:00
|
|
|
|
|
|
|
/** RPC-like helper function, returns the generated coin */
|
2023-05-02 17:17:10 +02:00
|
|
|
COutPoint generatetoaddress(const node::NodeContext&, const std::string& address);
|
2019-11-25 02:44:40 +01:00
|
|
|
|
|
|
|
#endif // BITCOIN_TEST_UTIL_MINING_H
|