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 
13 namespace wallet {
14 isminetype InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
15 
17 bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
18 
19 CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter);
20 CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
21 
22 bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
23 bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
24 CAmount OutputGetChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
25 CAmount TxGetChange(const CWallet& wallet, const CTransaction& tx);
26 
27 CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
29 CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
30 CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
31 CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true);
32 CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletTx& wtx, const bool fUseCache = true);
33 // TODO: Remove "NO_THREAD_SAFETY_ANALYSIS" and replace it with the correct
34 // annotation "EXCLUSIVE_LOCKS_REQUIRED(pwallet->cs_wallet)". The
35 // annotation "NO_THREAD_SAFETY_ANALYSIS" was temporarily added to avoid
36 // having to resolve the issue of member access into incomplete type CWallet.
37 CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache = true, const isminefilter& filter = ISMINE_SPENDABLE) NO_THREAD_SAFETY_ANALYSIS;
39 {
42  int vout;
43 };
44 void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
45  std::list<COutputEntry>& listReceived,
46  std::list<COutputEntry>& listSent,
47  CAmount& nFee, const isminefilter& filter);
48 bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
49 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<uint256>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
50 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
51 
52 struct Balance {
59 };
60 Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
61 
62 std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
63 std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
64 } // namespace wallet
65 
66 #endif // BITCOIN_WALLET_RECEIVE_H
CTxIn
An input of a transaction.
Definition: transaction.h:65
wallet::isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:41
wallet::isminefilter
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
Definition: wallet.h:40
wallet::TxGetChange
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:101
wallet.h
wallet::ScriptIsChange
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Definition: receive.cpp:66
wallet::GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Definition: receive.cpp:385
wallet::COutputEntry::vout
int vout
Definition: receive.h:42
wallet::Balance
Definition: receive.h:52
wallet
Definition: node.h:38
wallet::CachedTxGetImmatureWatchOnlyCredit
CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet, const CWalletTx &wtx, const bool fUseCache)
Definition: receive.cpp:174
wallet::CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:137
wallet::Balance::m_watchonly_immature
CAmount m_watchonly_immature
Definition: receive.h:58
wallet::OutputGetChange
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:93
wallet::InputIsMine
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin)
Definition: receive.cpp:12
wallet::Balance::m_mine_immature
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:55
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
wallet::CachedTxIsTrusted
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< uint256 > &trusted_parents)
Definition: receive.cpp:279
wallet::AllInputsMine
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:25
ismine.h
NO_THREAD_SAFETY_ANALYSIS
#define NO_THREAD_SAFETY_ANALYSIS
Definition: threadsafety.h:51
wallet::GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:347
wallet::CachedTxIsFromMe
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:274
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
wallet::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:217
CTxOut
An output of a transaction.
Definition: transaction.h:128
wallet::CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:232
wallet::COutputEntry::amount
CAmount amount
Definition: receive.h:41
wallet::TxGetCredit
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Definition: receive.cpp:54
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
wallet::OutputGetCredit
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Definition: receive.cpp:46
wallet::CachedTxGetCredit
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:124
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
wallet::Balance::m_watchonly_trusted
CAmount m_watchonly_trusted
Definition: receive.h:56
wallet::ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:44
transaction.h
wallet::CachedTxGetImmatureCredit
CAmount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache)
Definition: receive.cpp:165
EXCLUSIVE_LOCKS_REQUIRED
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49
wallet::Balance::m_watchonly_untrusted_pending
CAmount m_watchonly_untrusted_pending
Definition: receive.h:57
wallet::COutputEntry::destination
CTxDestination destination
Definition: receive.h:40
wallet::GetBalance
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
Definition: receive.cpp:318
wallet::CachedTxGetChange
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:156
wallet::Balance::m_mine_untrusted_pending
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:54
wallet::CachedTxGetDebit
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
Definition: receive.cpp:141
wallet::COutputEntry
Definition: receive.h:38
amount.h
wallet::CachedTxGetAvailableCredit
CAmount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache, const isminefilter &filter)
Definition: receive.cpp:183
wallet::OutputIsChange
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:88
wallet::Balance::m_mine_trusted
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
Definition: receive.h:53