types.h raw

   1  // Copyright (c) 2010-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  //! @file common/types.h is a home for simple enum and struct type definitions
   6  //! that can be used internally by functions in the libbitcoin_common library,
   7  //! but also used externally by node, wallet, and 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_COMMON_TYPES_H
  14  #define BITCOIN_COMMON_TYPES_H
  15  
  16  #include <optional>
  17  
  18  namespace common {
  19  enum class PSBTError {
  20      MISSING_INPUTS,
  21      SIGHASH_MISMATCH,
  22      EXTERNAL_SIGNER_NOT_FOUND,
  23      EXTERNAL_SIGNER_FAILED,
  24      UNSUPPORTED,
  25      INCOMPLETE,
  26      INVALID_TX,
  27      OK,
  28  };
  29  /**
  30   * Instructions for how a PSBT should be signed or filled with information.
  31   */
  32  struct PSBTFillOptions {
  33      /**
  34       * Whether to sign or not.
  35       */
  36      bool sign{true};
  37  
  38      /**
  39       * The sighash type to use when signing (if PSBT does not specify).
  40       */
  41      std::optional<int> sighash_type{std::nullopt};
  42  
  43      /**
  44       * Whether to create the final scriptSig or scriptWitness if possible.
  45       */
  46      bool finalize{true};
  47  
  48      /**
  49       * Whether to fill in bip32 derivation information if available.
  50       */
  51      bool bip32_derivs{true};
  52  };
  53  
  54  } // namespace common
  55  
  56  #endif // BITCOIN_COMMON_TYPES_H
  57