mining.h raw

   1  // Copyright (c) 2019-present The Bitcoin Core developers
   2  // Distributed under the MIT software license, see the accompanying
   3  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   4  
   5  #ifndef BITCOIN_TEST_UTIL_MINING_H
   6  #define BITCOIN_TEST_UTIL_MINING_H
   7  
   8  #include <cstddef>
   9  #include <memory>
  10  #include <string>
  11  #include <vector>
  12  
  13  class CBlock;
  14  class CChainParams;
  15  class COutPoint;
  16  namespace node {
  17  struct BlockCreateOptions;
  18  struct NodeContext;
  19  } // namespace node
  20  
  21  /** Create a blockchain, starting from genesis */
  22  std::vector<std::shared_ptr<CBlock>> CreateBlockChain(size_t total_height, const CChainParams& params);
  23  
  24  /** Returns the generated coin */
  25  COutPoint MineBlock(const node::NodeContext&,
  26                      const node::BlockCreateOptions& assembler_options);
  27  
  28  /**
  29   * Returns the generated coin (or Null if the block was invalid).
  30   * It is recommended to call RegenerateCommitments before mining the block to avoid merkle tree mismatches.
  31   **/
  32  COutPoint MineBlock(const node::NodeContext&, std::shared_ptr<CBlock>& block);
  33  
  34  /**
  35   * Returns the generated coin (or Null if the block was invalid).
  36   */
  37  COutPoint ProcessBlock(const node::NodeContext&, const std::shared_ptr<CBlock>& block);
  38  
  39  /** Prepare a block to be mined */
  40  std::shared_ptr<CBlock> PrepareBlock(const node::NodeContext& node,
  41                                       const node::BlockCreateOptions& assembler_options);
  42  
  43  /** RPC-like helper function, returns the generated coin */
  44  COutPoint generatetoaddress(const node::NodeContext&, const std::string& address);
  45  
  46  #endif // BITCOIN_TEST_UTIL_MINING_H
  47