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) 2021-present The Bitcoin Core developers2// Distributed under the MIT software license, see the accompanying3// file COPYING or http://www.opensource.org/licenses/mit-license.php.5#ifndef BITCOIN_WALLET_RECEIVE_H6#define BITCOIN_WALLET_RECEIVE_H8#include <consensus/amount.h>9#include <primitives/transaction_identifier.h>10#include <wallet/transaction.h>11#include <wallet/wallet.h>13namespace wallet {14bool InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);16/** Returns whether all of the inputs belong to the wallet*/17bool AllInputsMine(const CWallet& wallet, const CTransaction& tx);19CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout);20CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx);22bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);23bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);24CAmount OutputGetChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);25CAmount TxGetChange(const CWallet& wallet, const CTransaction& tx);27CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, bool avoid_reuse)28EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);29CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, bool avoid_reuse);30CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);31struct COutputEntry32{33CTxDestination destination;34CAmount amount;35int vout;36};37void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,38std::list<COutputEntry>& listReceived,39std::list<COutputEntry>& listSent,40CAmount& nFee,41bool include_change);42bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx);43bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<Txid>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);44bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);46struct Balance {47CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more48CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)49CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain50CAmount m_mine_used{0}; //!< Trusted/untrusted/immature funds in utxos that have already been spent from (only populated if AVOID REUSE wallet flag is set)51CAmount m_mine_nonmempool{0}; //!< Coins spent by wallet txs that are not in the mempool52};53Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true, bool include_nonmempool = false);55std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);56std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);57} // namespace wallet59#endif // BITCOIN_WALLET_RECEIVE_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.