Branch data Line data Source code
1 : : // Copyright (c) 2021-2022 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 <util/transaction_identifier.h>
10 : : #include <wallet/transaction.h>
11 : : #include <wallet/types.h>
12 : : #include <wallet/wallet.h>
13 : :
14 : : namespace wallet {
15 : : isminetype InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
16 : :
17 : : /** Returns whether all of the inputs match the filter */
18 : : bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
19 : :
20 : : CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter);
21 : : CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter);
22 : :
23 : : bool ScriptIsChange(const CWallet& wallet, const CScript& script) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
24 : : bool OutputIsChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
25 : : CAmount OutputGetChange(const CWallet& wallet, const CTxOut& txout) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
26 : : CAmount TxGetChange(const CWallet& wallet, const CTransaction& tx);
27 : :
28 : : CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
29 : : EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
30 : : //! filter decides which addresses will count towards the debit
31 : : CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
32 : : CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
33 : : CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
34 : : EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
35 : : CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter = ISMINE_SPENDABLE)
36 : : EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
37 [ # # ]: 0 : struct COutputEntry
38 : : {
39 : : CTxDestination destination;
40 : : CAmount amount;
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 include_change);
48 : : bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter);
49 : : bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<Txid>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
50 : : bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
51 : :
52 : : struct Balance {
53 : : CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
54 : : CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
55 : : CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain
56 : : CAmount m_watchonly_trusted{0};
57 : : CAmount m_watchonly_untrusted_pending{0};
58 : : CAmount m_watchonly_immature{0};
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
|