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 <amount.h>
9 #include <wallet/ismine.h>
10 #include <wallet/transaction.h>
11 #include <wallet/wallet.h>
12 
14 
16 bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
17 
18 CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter);
19 CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
20 
21 bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
22 bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
24 CAmount TxGetChange(const CWallet& wallet, const CTransaction& tx);
25 
26 CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
28 CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
30 CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true);
31 CAmount 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.
36 CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS;
38 {
41  int vout;
42 };
43 void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
44  std::list<COutputEntry>& listReceived,
45  std::list<COutputEntry>& listSent,
46  CAmount& nFee, const isminefilter& filter);
47 bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
48 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<uint256>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
49 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
50 
51 struct Balance {
58 };
59 Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
60 
61 std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
62 std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
63 
64 #endif // BITCOIN_WALLET_RECEIVE_H
Balance::m_watchonly_untrusted_pending
CAmount m_watchonly_untrusted_pending
Definition: receive.h:56
CTxIn
An input of a transaction.
Definition: transaction.h:65
OutputIsChange
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:86
TxGetCredit
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Definition: receive.cpp:52
wallet.h
isminefilter
uint8_t isminefilter
Definition: wallet.h:36
CachedTxIsFromMe
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:272
GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:383
GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:345
wallet
Definition: interfaces.cpp:50
Balance
Definition: receive.h:51
CachedTxGetAvailableCredit
CAmount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache=true, const isminefilter &filter=ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS
Definition: receive.cpp:181
InputIsMine
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:10
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
GetBalance
Balance GetBalance(const CWallet &wallet, int min_depth=0, bool avoid_reuse=true)
Definition: receive.cpp:316
CachedTxGetImmatureWatchOnlyCredit
CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet, const CWalletTx &wtx, const bool fUseCache=true)
Definition: receive.cpp:172
ismine.h
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51
isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:38
CachedTxGetDebit
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
Definition: receive.cpp:139
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
CTxOut
An output of a transaction.
Definition: transaction.h:128
OutputGetCredit
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Definition: receive.cpp:44
CachedTxIsTrusted
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< uint256 > &trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:277
COutputEntry::vout
int vout
Definition: receive.h:41
Balance::m_watchonly_trusted
CAmount m_watchonly_trusted
Definition: receive.h:55
COutputEntry::destination
CTxDestination destination
Definition: receive.h:39
COutputEntry
Definition: receive.h:37
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
Balance::m_mine_immature
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:54
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
CachedTxGetAmounts
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter)
Definition: receive.cpp:215
CachedTxGetImmatureCredit
CAmount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache=true)
Definition: receive.cpp:163
ScriptIsChange
bool ScriptIsChange(const CWallet &wallet, const CScript &script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:64
ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:42
transaction.h
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:228
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:46
COutputEntry::amount
CAmount amount
Definition: receive.h:40
CachedTxGetCredit
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:122
Balance::m_mine_trusted
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
Definition: receive.h:52
AllInputsMine
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:23
Balance::m_mine_untrusted_pending
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:53
amount.h
TxGetChange
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:99
CachedTxGetChange
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:154
OutputGetChange
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
Definition: receive.cpp:91
Balance::m_watchonly_immature
CAmount m_watchonly_immature
Definition: receive.h:57