types.h raw

   1  // Copyright (c) 2009-2010 Satoshi Nakamoto
   2  // Copyright (c) 2009-2021 The Limenka developers
   3  // Distributed under the MIT software license, see the accompanying
   4  // file COPYING or http://www.opensource.org/licenses/mit-license.php.
   5  
   6  //! @file wallet/types.h is a home for public enum and struct type definitions
   7  //! that are used by internally by wallet code, but also used externally by node
   8  //! or GUI code.
   9  //!
  10  //! This file is intended to define only simple types that do not have external
  11  //! dependencies. More complicated public wallet types like CCoinControl should
  12  //! be defined in dedicated header files.
  13  
  14  #ifndef LIMENKA_WALLET_TYPES_H
  15  #define LIMENKA_WALLET_TYPES_H
  16  
  17  #include <type_traits>
  18  
  19  namespace wallet {
  20  /**
  21   * IsMine() return codes, which depend on ScriptPubKeyMan implementation.
  22   * Not every ScriptPubKeyMan covers all types, please refer to
  23   * https://github.com/limenka/limenka/blob/master/doc/release-notes/release-notes-0.21.0.md#ismine-semantics
  24   * for better understanding.
  25   *
  26   * For LegacyScriptPubKeyMan,
  27   * ISMINE_NO: the scriptPubKey is not in the wallet;
  28   * ISMINE_WATCH_ONLY: the scriptPubKey has been imported into the wallet;
  29   * ISMINE_SPENDABLE: the scriptPubKey corresponds to an address owned by the wallet user (can spend with the private key);
  30   * ISMINE_USED: the scriptPubKey corresponds to a used address owned by the wallet user;
  31   * ISMINE_ALL: all ISMINE flags except for USED;
  32   * ISMINE_ALL_USED: all ISMINE flags including USED;
  33   * ISMINE_ENUM_ELEMENTS: the number of isminetype enum elements.
  34   *
  35   * For DescriptorScriptPubKeyMan and future ScriptPubKeyMan,
  36   * ISMINE_NO: the scriptPubKey is not in the wallet;
  37   * ISMINE_SPENDABLE: the scriptPubKey matches a scriptPubKey in the wallet.
  38   * ISMINE_USED: the scriptPubKey corresponds to a used address owned by the wallet user.
  39   *
  40   */
  41  enum isminetype : unsigned int {
  42      ISMINE_NO         = 0,
  43      ISMINE_WATCH_ONLY = 1 << 0,
  44      ISMINE_SPENDABLE  = 1 << 1,
  45      ISMINE_USED       = 1 << 2,
  46      ISMINE_ALL        = ISMINE_WATCH_ONLY | ISMINE_SPENDABLE,
  47      ISMINE_ALL_USED   = ISMINE_ALL | ISMINE_USED,
  48      ISMINE_ENUM_ELEMENTS,
  49  };
  50  /** used for bitflags of isminetype */
  51  using isminefilter = std::underlying_type<isminetype>::type;
  52  
  53  /**
  54   * Address purpose field that has been been stored with wallet sending and
  55   * receiving addresses since BIP70 payment protocol support was added in
  56   * https://github.com/limenka/limenka/pull/2539. This field is not currently
  57   * used for any logic inside the wallet, but it is still shown in RPC and GUI
  58   * interfaces and saved for new addresses. It is basically redundant with an
  59   * address's IsMine() result.
  60   */
  61  enum class AddressPurpose {
  62      RECEIVE,
  63      SEND,
  64      REFUND, //!< Never set in current code may be present in older wallet databases
  65  };
  66  } // namespace wallet
  67  
  68  #endif // LIMENKA_WALLET_TYPES_H
  69