Inside Bitcoin
Opening the selected file…
Opening the selected file…
The code behind the network, with room to understand it.
Release published 2026-10-28 · Snapshot fetched 2026-11-01. Latest stable release at fetch time; development branches and Git history are excluded. Only the selected code window and visible folders load here.
1// Copyright (c) 2009-2010 Satoshi Nakamoto2// Copyright (c) 2009-present The Bitcoin Core developers3// Distributed under the MIT software license, see the accompanying4// file COPYING or http://www.opensource.org/licenses/mit-license.php.6//! @file wallet/types.h is a home for public enum and struct type definitions7//! that are used by internally by wallet code, but also used externally by node8//! or GUI code.9//!10//! This file is intended to define only simple types that do not have external11//! dependencies. More complicated public wallet types like CCoinControl should12//! be defined in dedicated header files.14#ifndef BITCOIN_WALLET_TYPES_H15#define BITCOIN_WALLET_TYPES_H17#include <consensus/amount.h>18#include <policy/feerate.h>19#include <primitives/transaction.h>20#include <util/fees.h>21#include <util/translation.h>23#include <optional>24#include <utility>26namespace wallet {27struct MinimumFeeRateResult {28CFeeRate fee_rate;29FeeReason fee_reason;30std::optional<int> returned_target;32MinimumFeeRateResult(CFeeRate fee_rate, FeeReason fee_reason, std::optional<int> returned_target)33: fee_rate{fee_rate}, fee_reason{fee_reason}, returned_target{std::move(returned_target)} {}34};36/**37* Address purpose field that has been been stored with wallet sending and38* receiving addresses since BIP70 payment protocol support was added in39* https://github.com/bitcoin/bitcoin/pull/2539. This field is not currently40* used for any logic inside the wallet, but it is still shown in RPC and GUI41* interfaces and saved for new addresses. It is basically redundant with an42* address's IsMine() result.43*/44enum class AddressPurpose {45RECEIVE,46SEND,47REFUND, //!< Never set in current code may be present in older wallet databases48};50struct CreatedTransactionResult51{52CTransactionRef tx;53CAmount fee;54FeeReason fee_reason;55std::optional<unsigned int> change_pos;57CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional<unsigned int> _change_pos, FeeReason _fee_reason)58: tx(_tx), fee(_fee), fee_reason(_fee_reason), change_pos(_change_pos) {}59};61//! Machine-readable wallet error codes.62//!63//! @note Add new codes only when callers need to handle the condition64//! differently. For errors that should only be displayed to the user, use65//! WalletErrorCode::GenericError and provide the user-facing details in WalletError::message.66enum class WalletErrorCode {67//! Generic wallet error. Callers may present the accompanying message to68//! the user.69GenericError,71//! The wallet is locked and the operation requires access to private keys.72//! Callers may ask the user to unlock the wallet and retry the operation.73UnlockNeeded,74};76//! Wallet-layer error with both programmatic and user-facing information.77//!78//! Wallet methods should return a specific WalletErrorCode only when callers79//! can handle that condition differently. Otherwise, use WalletErrorCode::GenericError80//! and describe the failure in `message`.81struct WalletError {82//! Machine-readable error code for callers that need programmatic handling.83WalletErrorCode code;84//! User-facing translated error message85bilingual_str message;86};88} // namespace wallet90#endif // BITCOIN_WALLET_TYPES_H
Independent explanations by MyBitcoinExplorer. Not affiliated with or endorsed by Bitcoin Core. Guides are educational and do not replace the source or its tests.
Bitcoin Core source © its contributors, distributed under the MIT license. Original notices and bundled third-party licenses are retained in the source tree.