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 <primitives/transaction_identifier.h>
10 : : #include <wallet/transaction.h>
11 : : #include <wallet/wallet.h>
12 : :
13 : : namespace wallet {
14 : : bool InputIsMine(const CWallet& wallet, const CTxIn& txin) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
15 : :
16 : : /** Returns whether all of the inputs belong to the wallet*/
17 : : bool AllInputsMine(const CWallet& wallet, const CTransaction& tx);
18 : :
19 : : CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout);
20 : : CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx);
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, bool avoid_reuse)
28 : : EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
29 : : CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, bool avoid_reuse);
30 : : CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
31 [ + - ]: 6559 : struct COutputEntry
32 : : {
33 : : CTxDestination destination;
34 : : CAmount amount;
35 : : int vout;
36 : : };
37 : : void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
38 : : std::list<COutputEntry>& listReceived,
39 : : std::list<COutputEntry>& listSent,
40 : : CAmount& nFee,
41 : : bool include_change);
42 : : bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx);
43 : : bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<Txid>& trusted_parents) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
44 : : bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx);
45 : :
46 : : struct Balance {
47 : : CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
48 : : CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
49 : : CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain
50 : : };
51 : : Balance GetBalance(const CWallet& wallet, int min_depth = 0, bool avoid_reuse = true);
52 : :
53 : : std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet);
54 : : std::set<std::set<CTxDestination>> GetAddressGroupings(const CWallet& wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
55 : : } // namespace wallet
56 : :
57 : : #endif // BITCOIN_WALLET_RECEIVE_H
|