LCOV - code coverage report
Current view: top level - src/wallet - types.h (source / functions) Coverage Total Hit
Test: fuzz_coverage.info Lines: 0.0 % 3 0
Test Date: 2026-07-31 11:32:36 Functions: 0.0 % 1 0
Branches: 0.0 % 24 0

             Branch data     Line data    Source code
       1                 :             : // Copyright (c) 2009-2010 Satoshi Nakamoto
       2                 :             : // Copyright (c) 2009-present The Bitcoin Core 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 BITCOIN_WALLET_TYPES_H
      15                 :             : #define BITCOIN_WALLET_TYPES_H
      16                 :             : 
      17                 :             : #include <policy/fees/block_policy_estimator.h>
      18                 :             : #include <util/translation.h>
      19                 :             : 
      20                 :             : namespace wallet {
      21                 :             : /**
      22                 :             :  * Address purpose field that has been been stored with wallet sending and
      23                 :             :  * receiving addresses since BIP70 payment protocol support was added in
      24                 :             :  * https://github.com/bitcoin/bitcoin/pull/2539. This field is not currently
      25                 :             :  * used for any logic inside the wallet, but it is still shown in RPC and GUI
      26                 :             :  * interfaces and saved for new addresses. It is basically redundant with an
      27                 :             :  * address's IsMine() result.
      28                 :             :  */
      29                 :             : enum class AddressPurpose {
      30                 :             :     RECEIVE,
      31                 :             :     SEND,
      32                 :             :     REFUND, //!< Never set in current code may be present in older wallet databases
      33                 :             : };
      34                 :             : 
      35 [ #  # ][ #  #  :           0 : struct CreatedTransactionResult
             #  #  #  # ]
           [ #  #  #  #  
          #  #  #  #  #  
             #  #  #  #  
                      # ]
      36                 :             : {
      37                 :             :     CTransactionRef tx;
      38                 :             :     CAmount fee;
      39                 :             :     FeeCalculation fee_calc;
      40                 :             :     std::optional<unsigned int> change_pos;
      41                 :             : 
      42                 :           0 :     CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional<unsigned int> _change_pos, const FeeCalculation& _fee_calc)
      43         [ #  # ]:           0 :             : tx(_tx), fee(_fee), fee_calc(_fee_calc), change_pos(_change_pos) {}
      44                 :             : };
      45                 :             : 
      46                 :             : //! Machine-readable wallet error codes.
      47                 :             : //!
      48                 :             : //! @note Add new codes only when callers need to handle the condition
      49                 :             : //! differently. For errors that should only be displayed to the user, use
      50                 :             : //! WalletErrorCode::GenericError and provide the user-facing details in WalletError::message.
      51                 :             : enum class WalletErrorCode {
      52                 :             :     //! Generic wallet error. Callers may present the accompanying message to
      53                 :             :     //! the user.
      54                 :             :     GenericError,
      55                 :             : 
      56                 :             :     //! The wallet is locked and the operation requires access to private keys.
      57                 :             :     //! Callers may ask the user to unlock the wallet and retry the operation.
      58                 :             :     UnlockNeeded,
      59                 :             : };
      60                 :             : 
      61                 :             : //! Wallet-layer error with both programmatic and user-facing information.
      62                 :             : //!
      63                 :             : //! Wallet methods should return a specific WalletErrorCode only when callers
      64                 :             : //! can handle that condition differently. Otherwise, use WalletErrorCode::GenericError
      65                 :             : //! and describe the failure in `message`.
      66                 :             : struct WalletError {
      67                 :             :     //! Machine-readable error code for callers that need programmatic handling.
      68                 :             :     WalletErrorCode code;
      69                 :             :     //! User-facing translated error message
      70                 :             :     bilingual_str message;
      71                 :             : };
      72                 :             : 
      73                 :             : } // namespace wallet
      74                 :             : 
      75                 :             : #endif // BITCOIN_WALLET_TYPES_H
        

Generated by: LCOV version