Bitcoin Core 22.99.0
P2P Digital Currency
receive.h
Go to the documentation of this file.
1// Copyright (c) 2021 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#ifndef BITCOIN_WALLET_RECEIVE_H
6#define BITCOIN_WALLET_RECEIVE_H
7
8#include <consensus/amount.h>
9#include <wallet/ismine.h>
10#include <wallet/transaction.h>
11#include <wallet/wallet.h>
12
14
16bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
17
18CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter);
19CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
20
21bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
22bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
25
26CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
28CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
30CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true);
31CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletTx& wtx, const bool fUseCache = true);
32// TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
33// annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
34// annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
35// having to resolve the issue of member access into incomplete type CWallet.
38{
41 int vout;
42};
43void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
44 std::list<COutputEntry>& listReceived,
45 std::list<COutputEntry>& listSent,
46 CAmount& nFee, const isminefilter& filter);
47bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
48bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<uint256>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
49bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
50
51struct Balance {
58};
59Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
60
61std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
62std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
63
64#endif // BITCOIN_WALLET_RECEIVE_H
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:406
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:260
An input of a transaction.
Definition: transaction.h:66
An output of a transaction.
Definition: transaction.h:129
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:229
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:47
uint8_t isminefilter
Definition: wallet.h:36
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:39
@ ISMINE_SPENDABLE
Definition: ismine.h:42
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:87
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:92
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:273
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Definition: receive.cpp:45
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Definition: receive.cpp:53
CAmount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS
Definition: receive.cpp:182
Balance GetBalance(const CWallet &wallet, int min_depth=0, bool avoid_reuse=true)
Definition: receive.cpp:317
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:100
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:346
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter)
Definition: receive.cpp:216
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:11
bool ScriptIsChange(const CWallet &wallet, const CScript &script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:65
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< uint256 > &trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:278
CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet, const CWalletTx &wtx, const bool fUseCache=true)
Definition: receive.cpp:173
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:24
CAmount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache=true)
Definition: receive.cpp:164
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
Definition: receive.cpp:140
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:155
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:123
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:384
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:54
CAmount m_watchonly_untrusted_pending
Definition: receive.h:56
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
Definition: receive.h:52
CAmount m_watchonly_immature
Definition: receive.h:57
CAmount m_watchonly_trusted
Definition: receive.h:55
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:53
Definition: receive.h:38
CAmount amount
Definition: receive.h:40
int vout
Definition: receive.h:41
CTxDestination destination
Definition: receive.h:39
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51