/ 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 <policy/policy.h>
19  #include <script/script.h>
20  #include <util/time.h>
21  
22  namespace node {
23  enum class TransactionError {
24      OK, //!< No error
25      MISSING_INPUTS,
26      ALREADY_IN_UTXO_SET,
27      MEMPOOL_REJECTED,
28      MEMPOOL_ERROR,
29      MAX_FEE_EXCEEDED,
30      MAX_BURN_EXCEEDED,
31      INVALID_PACKAGE,
32  };
33  
34  struct BlockCreateOptions {
35      /**
36       * Set false to omit mempool transactions
37       */
38      bool use_mempool{true};
39      /**
40       * The default reserved weight for the fixed-size block header,
41       * transaction count and coinbase transaction.
42       */
43      size_t block_reserved_weight{DEFAULT_BLOCK_RESERVED_WEIGHT};
44      /**
45       * The maximum additional sigops which the pool will add in coinbase
46       * transaction outputs.
47       */
48      size_t coinbase_output_max_additional_sigops{400};
49      /**
50       * Script to put in the coinbase transaction. The default is an
51       * anyone-can-spend dummy.
52       *
53       * Should only be used for tests, when the default doesn't suffice.
54       *
55       * Note that higher level code like the getblocktemplate RPC may omit the
56       * coinbase transaction entirely. It's instead constructed by pool software
57       * using fields like coinbasevalue, coinbaseaux and default_witness_commitment.
58       * This software typically also controls the payout outputs, even for solo
59       * mining.
60       *
61       * The size and sigops are not checked against
62       * coinbase_max_additional_weight and coinbase_output_max_additional_sigops.
63       */
64      CScript coinbase_output_script{CScript() << OP_TRUE};
65  };
66  
67  struct BlockWaitOptions {
68      /**
69       * How long to wait before returning nullptr instead of a new template.
70       * Default is to wait forever.
71       */
72      MillisecondsDouble timeout{MillisecondsDouble::max()};
73  
74      /**
75       * The wait method will not return a new template unless it has fees at
76       * least fee_threshold sats higher than the current template, or unless
77       * the chain tip changes and the previous template is no longer valid.
78       *
79       * A caller may not be interested in templates with higher fees, and
80       * determining whether fee_threshold is reached is also expensive. So as
81       * an optimization, when fee_threshold is set to MAX_MONEY (default), the
82       * implementation is able to be much more efficient, skipping expensive
83       * checks and only returning new templates when the chain tip changes.
84       */
85      CAmount fee_threshold{MAX_MONEY};
86  };
87  
88  } // namespace node
89  
90  #endif // BITCOIN_NODE_TYPES_H