Bitcoin Core  31.0.0
P2P Digital Currency
receive.h
Go to the documentation of this file.
1 // Copyright (c) 2021-present 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>
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 
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)
29 CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, bool avoid_reuse);
30 CAmount CachedTxGetChange(const CWallet& wallet, const CWalletTx& wtx);
32 {
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 {
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
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, bool avoid_reuse)
Definition: receive.cpp:122
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< Txid > &trusted_parents)
Definition: receive.cpp:205
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:74
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, bool include_change)
Definition: receive.cpp:139
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:276
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:49
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, bool avoid_reuse)
Definition: receive.cpp:110
int vout
Definition: receive.h:35
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
Definition: receive.cpp:245
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:130
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:196
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:194
An input of a transaction.
Definition: transaction.h:61
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:309
An output of a transaction.
Definition: transaction.h:139
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Definition: receive.cpp:304
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Definition: receive.cpp:52
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:32
#define EXCLUSIVE_LOCKS_REQUIRED(...)
Definition: threadsafety.h:51
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:404
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:79
std::variant< CNoDestination, PubKeyDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, PayToAnchor, WitnessUnknown > CTxDestination
A txout script categorized into standard templates.
Definition: addresstype.h:143
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:48
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
Definition: receive.h:47
CTxDestination destination
Definition: receive.h:33
Definition: receive.h:31
bool InputIsMine(const CWallet &wallet, const CTxIn &txin)
Definition: receive.cpp:13
The basic transaction that is broadcasted on the network and contained in blocks. ...
Definition: transaction.h:280
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:87
CAmount amount
Definition: receive.h:34
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx)
Returns whether all of the inputs belong to the wallet.
Definition: receive.cpp:23
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:40