receive.h raw
1 // Copyright (c) 2021-2022 The Limenka 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 LIMENKA_WALLET_RECEIVE_H
6 #define LIMENKA_WALLET_RECEIVE_H
7
8 #include <consensus/amount.h>
9 #include <wallet/transaction.h>
10 #include <wallet/types.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
16 /** Returns whether all of the inputs match the filter */
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)
28 EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
29 //! filter decides which addresses will count towards the debit
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)
33 EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
34 CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter = ISMINE_SPENDABLE)
35 EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet);
36 struct COutputEntry
37 {
38 CTxDestination destination;
39 CAmount amount;
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 {
52 CAmount m_mine_trusted{0}; //!< Trusted, at depth=GetBalance.min_depth or more
53 CAmount m_mine_untrusted_pending{0}; //!< Untrusted, but in mempool (pending)
54 CAmount m_mine_immature{0}; //!< Immature coinbases in the main chain
55 CAmount m_watchonly_trusted{0};
56 CAmount m_watchonly_untrusted_pending{0};
57 CAmount m_watchonly_immature{0};
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 // LIMENKA_WALLET_RECEIVE_H
66