/ src / node / types.h
types.h
  1  // Copyright (c) 2010-2021 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  //! @file node/types.h is a home for public enum and struct type definitions
  6  //! that are used internally by node code, but also used externally by wallet,
  7  //! mining or GUI code.
  8  //!
  9  //! This file is intended to define only simple types that do not have external
 10  //! dependencies. More complicated types should be defined in dedicated header
 11  //! files.
 12  
 13  #ifndef BITCOIN_NODE_TYPES_H
 14  #define BITCOIN_NODE_TYPES_H
 15  
 16  #include <consensus/amount.h>
 17  #include <cstddef>
 18  #include <cstdint>
 19  #include <policy/policy.h>
 20  #include <script/script.h>
 21  #include <uint256.h>
 22  #include <util/time.h>
 23  
 24  namespace node {
 25  enum class TransactionError {
 26      OK, //!< No error
 27      MISSING_INPUTS,
 28      ALREADY_IN_UTXO_SET,
 29      MEMPOOL_REJECTED,
 30      MEMPOOL_ERROR,
 31      MAX_FEE_EXCEEDED,
 32      MAX_BURN_EXCEEDED,
 33      INVALID_PACKAGE,
 34  };
 35  
 36  struct BlockCreateOptions {
 37      /**
 38       * Set false to omit mempool transactions
 39       */
 40      bool use_mempool{true};
 41      /**
 42       * The default reserved weight for the fixed-size block header,
 43       * transaction count and coinbase transaction.
 44       */
 45      size_t block_reserved_weight{DEFAULT_BLOCK_RESERVED_WEIGHT};
 46      /**
 47       * The maximum additional sigops which the pool will add in coinbase
 48       * transaction outputs.
 49       */
 50      size_t coinbase_output_max_additional_sigops{400};
 51      /**
 52       * Script to put in the coinbase transaction. The default is an
 53       * anyone-can-spend dummy.
 54       *
 55       * Should only be used for tests, when the default doesn't suffice.
 56       *
 57       * Note that higher level code like the getblocktemplate RPC may omit the
 58       * coinbase transaction entirely. It's instead constructed by pool software
 59       * using fields like coinbasevalue, coinbaseaux and default_witness_commitment.
 60       * This software typically also controls the payout outputs, even for solo
 61       * mining.
 62       *
 63       * The size and sigops are not checked against
 64       * coinbase_max_additional_weight and coinbase_output_max_additional_sigops.
 65       */
 66      CScript coinbase_output_script{CScript() << OP_TRUE};
 67  };
 68  
 69  struct BlockWaitOptions {
 70      /**
 71       * How long to wait before returning nullptr instead of a new template.
 72       * Default is to wait forever.
 73       */
 74      MillisecondsDouble timeout{MillisecondsDouble::max()};
 75  
 76      /**
 77       * The wait method will not return a new template unless it has fees at
 78       * least fee_threshold sats higher than the current template, or unless
 79       * the chain tip changes and the previous template is no longer valid.
 80       *
 81       * A caller may not be interested in templates with higher fees, and
 82       * determining whether fee_threshold is reached is also expensive. So as
 83       * an optimization, when fee_threshold is set to MAX_MONEY (default), the
 84       * implementation is able to be much more efficient, skipping expensive
 85       * checks and only returning new templates when the chain tip changes.
 86       */
 87      CAmount fee_threshold{MAX_MONEY};
 88  };
 89  
 90  struct BlockCheckOptions {
 91      /**
 92       * Set false to omit the merkle root check
 93       */
 94      bool check_merkle_root{true};
 95  
 96      /**
 97       * Set false to omit the proof-of-work check
 98       */
 99      bool check_pow{true};
100  };
101  
102  /**
103   * How to broadcast a local transaction.
104   * Used to influence `BroadcastTransaction()` and its callers.
105   */
106  enum class TxBroadcast : uint8_t {
107      /// Add the transaction to the mempool and broadcast to all peers for which tx relay is enabled.
108      MEMPOOL_AND_BROADCAST_TO_ALL,
109      /// Add the transaction to the mempool, but don't broadcast to anybody.
110      MEMPOOL_NO_BROADCAST,
111  };
112  
113  } // namespace node
114  
115  #endif // BITCOIN_NODE_TYPES_H