Bitcoin Core  24.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)
30 CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
31 CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
32 CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
34 CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter = ISMINE_SPENDABLE)
37 {
40  int vout;
41 };
42 void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
43  std::list<COutputEntry>& listReceived,
44  std::list<COutputEntry>& listSent,
45  CAmount& nFee, const isminefilter& filter,
46  bool include_change);
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 } // namespace wallet
64 
65 #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:411
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:288
An input of a transaction.
Definition: transaction.h:74
An output of a transaction.
Definition: transaction.h:157
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:236
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:138
Definition: node.h:39
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:73
CAmount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:159
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
Definition: receive.cpp:293
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:86
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Definition: receive.cpp:51
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:251
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
Definition: receive.cpp:126
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter, bool include_change)
Definition: receive.cpp:194
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Definition: receive.cpp:31
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:109
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< uint256 > &trusted_parents)
Definition: receive.cpp:256
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Definition: receive.cpp:39
std::underlying_type< isminetype >::type isminefilter
used for bitflags of isminetype
Definition: wallet.h:41
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:78
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:41
@ ISMINE_SPENDABLE
Definition: ismine.h:44
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:139
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:22
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin)
Definition: receive.cpp:12
CAmount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:148
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:322
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Definition: receive.cpp:360
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:149
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:54
CAmount m_watchonly_trusted
Definition: receive.h:55
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:53
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
Definition: receive.h:37
CAmount amount
Definition: receive.h:39
CTxDestination destination
Definition: receive.h:38
int vout
Definition: receive.h:40
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:49