Bitcoin Core  22.99.0
P2P Digital Currency
receive.cpp
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 #include <consensus/consensus.h>
6 #include <wallet/receive.h>
7 #include <wallet/transaction.h>
8 #include <wallet/wallet.h>
9 
11 {
12  AssertLockHeld(wallet.cs_wallet);
13  std::map<uint256, CWalletTx>::const_iterator mi = wallet.mapWallet.find(txin.prevout.hash);
14  if (mi != wallet.mapWallet.end())
15  {
16  const CWalletTx& prev = (*mi).second;
17  if (txin.prevout.n < prev.tx->vout.size())
18  return wallet.IsMine(prev.tx->vout[txin.prevout.n]);
19  }
20  return ISMINE_NO;
21 }
22 
23 bool AllInputsMine(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter)
24 {
25  LOCK(wallet.cs_wallet);
26 
27  for (const CTxIn& txin : tx.vin)
28  {
29  auto mi = wallet.mapWallet.find(txin.prevout.hash);
30  if (mi == wallet.mapWallet.end())
31  return false; // any unknown inputs can't be from us
32 
33  const CWalletTx& prev = (*mi).second;
34 
35  if (txin.prevout.n >= prev.tx->vout.size())
36  return false; // invalid input!
37 
38  if (!(wallet.IsMine(prev.tx->vout[txin.prevout.n]) & filter))
39  return false;
40  }
41  return true;
42 }
43 
44 CAmount OutputGetCredit(const CWallet& wallet, const CTxOut& txout, const isminefilter& filter)
45 {
46  if (!MoneyRange(txout.nValue))
47  throw std::runtime_error(std::string(__func__) + ": value out of range");
48  LOCK(wallet.cs_wallet);
49  return ((wallet.IsMine(txout) & filter) ? txout.nValue : 0);
50 }
51 
52 CAmount TxGetCredit(const CWallet& wallet, const CTransaction& tx, const isminefilter& filter)
53 {
54  CAmount nCredit = 0;
55  for (const CTxOut& txout : tx.vout)
56  {
57  nCredit += OutputGetCredit(wallet, txout, filter);
58  if (!MoneyRange(nCredit))
59  throw std::runtime_error(std::string(__func__) + ": value out of range");
60  }
61  return nCredit;
62 }
63 
64 bool ScriptIsChange(const CWallet& wallet, const CScript& script)
65 {
66  // TODO: fix handling of 'change' outputs. The assumption is that any
67  // payment to a script that is ours, but is not in the address book
68  // is change. That assumption is likely to break when we implement multisignature
69  // wallets that return change back into a multi-signature-protected address;
70  // a better way of identifying which outputs are 'the send' and which are
71  // 'the change' will need to be implemented (maybe extend CWalletTx to remember
72  // which output, if any, was change).
73  AssertLockHeld(wallet.cs_wallet);
74  if (wallet.IsMine(script))
75  {
76  CTxDestination address;
77  if (!ExtractDestination(script, address))
78  return true;
79  if (!wallet.FindAddressBookEntry(address)) {
80  return true;
81  }
82  }
83  return false;
84 }
85 
86 bool OutputIsChange(const CWallet& wallet, const CTxOut& txout)
87 {
88  return ScriptIsChange(wallet, txout.scriptPubKey);
89 }
90 
92 {
93  AssertLockHeld(wallet.cs_wallet);
94  if (!MoneyRange(txout.nValue))
95  throw std::runtime_error(std::string(__func__) + ": value out of range");
96  return (OutputIsChange(wallet, txout) ? txout.nValue : 0);
97 }
98 
100 {
101  LOCK(wallet.cs_wallet);
102  CAmount nChange = 0;
103  for (const CTxOut& txout : tx.vout)
104  {
105  nChange += OutputGetChange(wallet, txout);
106  if (!MoneyRange(nChange))
107  throw std::runtime_error(std::string(__func__) + ": value out of range");
108  }
109  return nChange;
110 }
111 
112 static CAmount GetCachableAmount(const CWallet& wallet, const CWalletTx& wtx, CWalletTx::AmountType type, const isminefilter& filter, bool recalculate = false)
113 {
114  auto& amount = wtx.m_amounts[type];
115  if (recalculate || !amount.m_cached[filter]) {
116  amount.Set(filter, type == CWalletTx::DEBIT ? wallet.GetDebit(*wtx.tx, filter) : TxGetCredit(wallet, *wtx.tx, filter));
117  wtx.m_is_cache_empty = false;
118  }
119  return amount.m_value[filter];
120 }
121 
122 CAmount CachedTxGetCredit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
123 {
124  // Must wait until coinbase is safely deep enough in the chain before valuing it
125  if (wallet.IsTxImmatureCoinBase(wtx))
126  return 0;
127 
128  CAmount credit = 0;
129  if (filter & ISMINE_SPENDABLE) {
130  // GetBalance can assume transactions in mapWallet won't change
132  }
133  if (filter & ISMINE_WATCH_ONLY) {
135  }
136  return credit;
137 }
138 
139 CAmount CachedTxGetDebit(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
140 {
141  if (wtx.tx->vin.empty())
142  return 0;
143 
144  CAmount debit = 0;
145  if (filter & ISMINE_SPENDABLE) {
147  }
148  if (filter & ISMINE_WATCH_ONLY) {
150  }
151  return debit;
152 }
153 
155 {
156  if (wtx.fChangeCached)
157  return wtx.nChangeCached;
158  wtx.nChangeCached = TxGetChange(wallet, *wtx.tx);
159  wtx.fChangeCached = true;
160  return wtx.nChangeCached;
161 }
162 
163 CAmount CachedTxGetImmatureCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache)
164 {
165  if (wallet.IsTxImmatureCoinBase(wtx) && wallet.IsTxInMainChain(wtx)) {
167  }
168 
169  return 0;
170 }
171 
172 CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet& wallet, const CWalletTx& wtx, const bool fUseCache)
173 {
174  if (wallet.IsTxImmatureCoinBase(wtx) && wallet.IsTxInMainChain(wtx)) {
176  }
177 
178  return 0;
179 }
180 
181 CAmount CachedTxGetAvailableCredit(const CWallet& wallet, const CWalletTx& wtx, bool fUseCache, const isminefilter& filter)
182 {
183  // Avoid caching ismine for NO or ALL cases (could remove this check and simplify in the future).
184  bool allow_cache = (filter & ISMINE_ALL) && (filter & ISMINE_ALL) != ISMINE_ALL;
185 
186  // Must wait until coinbase is safely deep enough in the chain before valuing it
187  if (wallet.IsTxImmatureCoinBase(wtx))
188  return 0;
189 
190  if (fUseCache && allow_cache && wtx.m_amounts[CWalletTx::AVAILABLE_CREDIT].m_cached[filter]) {
191  return wtx.m_amounts[CWalletTx::AVAILABLE_CREDIT].m_value[filter];
192  }
193 
194  bool allow_used_addresses = (filter & ISMINE_USED) || !wallet.IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE);
195  CAmount nCredit = 0;
196  uint256 hashTx = wtx.GetHash();
197  for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
198  {
199  if (!wallet.IsSpent(hashTx, i) && (allow_used_addresses || !wallet.IsSpentKey(hashTx, i))) {
200  const CTxOut &txout = wtx.tx->vout[i];
201  nCredit += OutputGetCredit(wallet, txout, filter);
202  if (!MoneyRange(nCredit))
203  throw std::runtime_error(std::string(__func__) + " : value out of range");
204  }
205  }
206 
207  if (allow_cache) {
208  wtx.m_amounts[CWalletTx::AVAILABLE_CREDIT].Set(filter, nCredit);
209  wtx.m_is_cache_empty = false;
210  }
211 
212  return nCredit;
213 }
214 
215 void CachedTxGetAmounts(const CWallet& wallet, const CWalletTx& wtx,
216  std::list<COutputEntry>& listReceived,
217  std::list<COutputEntry>& listSent, CAmount& nFee, const isminefilter& filter)
218 {
219  nFee = 0;
220  listReceived.clear();
221  listSent.clear();
222 
223  // Compute fee:
224  CAmount nDebit = CachedTxGetDebit(wallet, wtx, filter);
225  if (nDebit > 0) // debit>0 means we signed/sent this transaction
226  {
227  CAmount nValueOut = wtx.tx->GetValueOut();
228  nFee = nDebit - nValueOut;
229  }
230 
231  LOCK(wallet.cs_wallet);
232  // Sent/received.
233  for (unsigned int i = 0; i < wtx.tx->vout.size(); ++i)
234  {
235  const CTxOut& txout = wtx.tx->vout[i];
236  isminetype fIsMine = wallet.IsMine(txout);
237  // Only need to handle txouts if AT LEAST one of these is true:
238  // 1) they debit from us (sent)
239  // 2) the output is to us (received)
240  if (nDebit > 0)
241  {
242  // Don't report 'change' txouts
243  if (OutputIsChange(wallet, txout))
244  continue;
245  }
246  else if (!(fIsMine & filter))
247  continue;
248 
249  // In either case, we need to get the destination address
250  CTxDestination address;
251 
252  if (!ExtractDestination(txout.scriptPubKey, address) && !txout.scriptPubKey.IsUnspendable())
253  {
254  wallet.WalletLogPrintf("CWalletTx::GetAmounts: Unknown transaction type found, txid %s\n",
255  wtx.GetHash().ToString());
256  address = CNoDestination();
257  }
258 
259  COutputEntry output = {address, txout.nValue, (int)i};
260 
261  // If we are debited by the transaction, add the output as a "sent" entry
262  if (nDebit > 0)
263  listSent.push_back(output);
264 
265  // If we are receiving the output, add it as a "received" entry
266  if (fIsMine & filter)
267  listReceived.push_back(output);
268  }
269 
270 }
271 
272 bool CachedTxIsFromMe(const CWallet& wallet, const CWalletTx& wtx, const isminefilter& filter)
273 {
274  return (CachedTxGetDebit(wallet, wtx, filter) > 0);
275 }
276 
277 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx, std::set<uint256>& trusted_parents)
278 {
279  AssertLockHeld(wallet.cs_wallet);
280  // Quick answer in most cases
281  if (!wallet.chain().checkFinalTx(*wtx.tx)) return false;
282  int nDepth = wallet.GetTxDepthInMainChain(wtx);
283  if (nDepth >= 1) return true;
284  if (nDepth < 0) return false;
285  // using wtx's cached debit
286  if (!wallet.m_spend_zero_conf_change || !CachedTxIsFromMe(wallet, wtx, ISMINE_ALL)) return false;
287 
288  // Don't trust unconfirmed transactions from us unless they are in the mempool.
289  if (!wtx.InMempool()) return false;
290 
291  // Trusted if all inputs are from us and are in the mempool:
292  for (const CTxIn& txin : wtx.tx->vin)
293  {
294  // Transactions not sent by us: not trusted
295  const CWalletTx* parent = wallet.GetWalletTx(txin.prevout.hash);
296  if (parent == nullptr) return false;
297  const CTxOut& parentOut = parent->tx->vout[txin.prevout.n];
298  // Check that this specific input being spent is trusted
299  if (wallet.IsMine(parentOut) != ISMINE_SPENDABLE) return false;
300  // If we've already trusted this parent, continue
301  if (trusted_parents.count(parent->GetHash())) continue;
302  // Recurse to check that the parent is also trusted
303  if (!CachedTxIsTrusted(wallet, *parent, trusted_parents)) return false;
304  trusted_parents.insert(parent->GetHash());
305  }
306  return true;
307 }
308 
309 bool CachedTxIsTrusted(const CWallet& wallet, const CWalletTx& wtx)
310 {
311  std::set<uint256> trusted_parents;
312  LOCK(wallet.cs_wallet);
313  return CachedTxIsTrusted(wallet, wtx, trusted_parents);
314 }
315 
316 Balance GetBalance(const CWallet& wallet, const int min_depth, bool avoid_reuse)
317 {
318  Balance ret;
319  isminefilter reuse_filter = avoid_reuse ? ISMINE_NO : ISMINE_USED;
320  {
321  LOCK(wallet.cs_wallet);
322  std::set<uint256> trusted_parents;
323  for (const auto& entry : wallet.mapWallet)
324  {
325  const CWalletTx& wtx = entry.second;
326  const bool is_trusted{CachedTxIsTrusted(wallet, wtx, trusted_parents)};
327  const int tx_depth{wallet.GetTxDepthInMainChain(wtx)};
328  const CAmount tx_credit_mine{CachedTxGetAvailableCredit(wallet, wtx, /* fUseCache */ true, ISMINE_SPENDABLE | reuse_filter)};
329  const CAmount tx_credit_watchonly{CachedTxGetAvailableCredit(wallet, wtx, /* fUseCache */ true, ISMINE_WATCH_ONLY | reuse_filter)};
330  if (is_trusted && tx_depth >= min_depth) {
331  ret.m_mine_trusted += tx_credit_mine;
332  ret.m_watchonly_trusted += tx_credit_watchonly;
333  }
334  if (!is_trusted && tx_depth == 0 && wtx.InMempool()) {
335  ret.m_mine_untrusted_pending += tx_credit_mine;
336  ret.m_watchonly_untrusted_pending += tx_credit_watchonly;
337  }
340  }
341  }
342  return ret;
343 }
344 
345 std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet)
346 {
347  std::map<CTxDestination, CAmount> balances;
348 
349  {
350  LOCK(wallet.cs_wallet);
351  std::set<uint256> trusted_parents;
352  for (const auto& walletEntry : wallet.mapWallet)
353  {
354  const CWalletTx& wtx = walletEntry.second;
355 
356  if (!CachedTxIsTrusted(wallet, wtx, trusted_parents))
357  continue;
358 
359  if (wallet.IsTxImmatureCoinBase(wtx))
360  continue;
361 
362  int nDepth = wallet.GetTxDepthInMainChain(wtx);
363  if (nDepth < (CachedTxIsFromMe(wallet, wtx, ISMINE_ALL) ? 0 : 1))
364  continue;
365 
366  for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
367  {
368  CTxDestination addr;
369  if (!wallet.IsMine(wtx.tx->vout[i]))
370  continue;
371  if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
372  continue;
373 
374  CAmount n = wallet.IsSpent(walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue;
375  balances[addr] += n;
376  }
377  }
378  }
379 
380  return balances;
381 }
382 
383 std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet)
384 {
385  AssertLockHeld(wallet.cs_wallet);
386  std::set< std::set<CTxDestination> > groupings;
387  std::set<CTxDestination> grouping;
388 
389  for (const auto& walletEntry : wallet.mapWallet)
390  {
391  const CWalletTx& wtx = walletEntry.second;
392 
393  if (wtx.tx->vin.size() > 0)
394  {
395  bool any_mine = false;
396  // group all input addresses with each other
397  for (const CTxIn& txin : wtx.tx->vin)
398  {
399  CTxDestination address;
400  if(!InputIsMine(wallet, txin)) /* If this input isn't mine, ignore it */
401  continue;
402  if(!ExtractDestination(wallet.mapWallet.at(txin.prevout.hash).tx->vout[txin.prevout.n].scriptPubKey, address))
403  continue;
404  grouping.insert(address);
405  any_mine = true;
406  }
407 
408  // group change with input addresses
409  if (any_mine)
410  {
411  for (const CTxOut& txout : wtx.tx->vout)
412  if (OutputIsChange(wallet, txout))
413  {
414  CTxDestination txoutAddr;
415  if(!ExtractDestination(txout.scriptPubKey, txoutAddr))
416  continue;
417  grouping.insert(txoutAddr);
418  }
419  }
420  if (grouping.size() > 0)
421  {
422  groupings.insert(grouping);
423  grouping.clear();
424  }
425  }
426 
427  // group lone addrs by themselves
428  for (const auto& txout : wtx.tx->vout)
429  if (wallet.IsMine(txout))
430  {
431  CTxDestination address;
432  if(!ExtractDestination(txout.scriptPubKey, address))
433  continue;
434  grouping.insert(address);
435  groupings.insert(grouping);
436  grouping.clear();
437  }
438  }
439 
440  std::set< std::set<CTxDestination>* > uniqueGroupings; // a set of pointers to groups of addresses
441  std::map< CTxDestination, std::set<CTxDestination>* > setmap; // map addresses to the unique group containing it
442  for (std::set<CTxDestination> _grouping : groupings)
443  {
444  // make a set of all the groups hit by this new group
445  std::set< std::set<CTxDestination>* > hits;
446  std::map< CTxDestination, std::set<CTxDestination>* >::iterator it;
447  for (const CTxDestination& address : _grouping)
448  if ((it = setmap.find(address)) != setmap.end())
449  hits.insert((*it).second);
450 
451  // merge all hit groups into a new single group and delete old groups
452  std::set<CTxDestination>* merged = new std::set<CTxDestination>(_grouping);
453  for (std::set<CTxDestination>* hit : hits)
454  {
455  merged->insert(hit->begin(), hit->end());
456  uniqueGroupings.erase(hit);
457  delete hit;
458  }
459  uniqueGroupings.insert(merged);
460 
461  // update setmap
462  for (const CTxDestination& element : *merged)
463  setmap[element] = merged;
464  }
465 
466  std::set< std::set<CTxDestination> > ret;
467  for (const std::set<CTxDestination>* uniqueGrouping : uniqueGroupings)
468  {
469  ret.insert(*uniqueGrouping);
470  delete uniqueGrouping;
471  }
472 
473  return ret;
474 }
CachedTxGetAvailableCredit
CAmount CachedTxGetAvailableCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache, const isminefilter &filter)
Definition: receive.cpp:181
Balance::m_watchonly_untrusted_pending
CAmount m_watchonly_untrusted_pending
Definition: receive.h:56
CTxIn
An input of a transaction.
Definition: transaction.h:65
CachedTxGetChange
CAmount CachedTxGetChange(const CWallet &wallet, const CWalletTx &wtx)
Definition: receive.cpp:154
CTransaction::vin
const std::vector< CTxIn > vin
Definition: transaction.h:270
OutputIsChange
bool OutputIsChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:86
wallet.h
isminefilter
uint8_t isminefilter
Definition: wallet.h:36
ScriptIsChange
bool ScriptIsChange(const CWallet &wallet, const CScript &script)
Definition: receive.cpp:64
ISMINE_ALL
@ ISMINE_ALL
Definition: ismine.h:44
GetAddressBalances
std::map< CTxDestination, CAmount > GetAddressBalances(const CWallet &wallet)
Definition: receive.cpp:345
CWalletTx::AVAILABLE_CREDIT
@ AVAILABLE_CREDIT
Definition: transaction.h:104
COutPoint::hash
uint256 hash
Definition: transaction.h:29
CachedTxGetImmatureWatchOnlyCredit
CAmount CachedTxGetImmatureWatchOnlyCredit(const CWallet &wallet, const CWalletTx &wtx, const bool fUseCache)
Definition: receive.cpp:172
ISMINE_WATCH_ONLY
@ ISMINE_WATCH_ONLY
Definition: ismine.h:41
CWalletTx::AmountType
AmountType
Definition: transaction.h:104
CachableAmount::m_value
CAmount m_value[ISMINE_ENUM_ELEMENTS]
Definition: ismine.h:58
MoneyRange
bool MoneyRange(const CAmount &nValue)
Definition: amount.h:26
wallet
Definition: interfaces.cpp:50
GetBalance
Balance GetBalance(const CWallet &wallet, const int min_depth, bool avoid_reuse)
Definition: receive.cpp:316
Balance
Definition: receive.h:51
CWalletTx::m_is_cache_empty
bool m_is_cache_empty
This flag is true if all m_amounts caches are empty.
Definition: transaction.h:112
CachedTxIsTrusted
bool CachedTxIsTrusted(const CWallet &wallet, const CWalletTx &wtx, std::set< uint256 > &trusted_parents)
Definition: receive.cpp:277
CachedTxGetCredit
CAmount CachedTxGetCredit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:122
GetAddressGroupings
std::set< std::set< CTxDestination > > GetAddressGroupings(const CWallet &wallet)
Definition: receive.cpp:383
CWalletTx::nChangeCached
CAmount nChangeCached
Definition: transaction.h:115
CTransaction
The basic transaction that is broadcasted on the network and contained in blocks.
Definition: transaction.h:259
AssertLockHeld
AssertLockHeld(pool.cs)
CTxOut::nValue
CAmount nValue
Definition: transaction.h:131
isminetype
isminetype
IsMine() return codes, which depend on ScriptPubKeyMan implementation.
Definition: ismine.h:38
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
AllInputsMine
bool AllInputsMine(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Returns whether all of the inputs match the filter.
Definition: receive.cpp:23
CachableAmount::m_cached
std::bitset< ISMINE_ENUM_ELEMENTS > m_cached
Definition: ismine.h:57
CTxOut
An output of a transaction.
Definition: transaction.h:128
CWalletTx::fChangeCached
bool fChangeCached
Definition: transaction.h:113
CTransaction::vout
const std::vector< CTxOut > vout
Definition: transaction.h:271
CTxOut::scriptPubKey
CScript scriptPubKey
Definition: transaction.h:132
CachableAmount::Set
void Set(isminefilter filter, CAmount value)
Definition: ismine.h:63
Balance::m_watchonly_trusted
CAmount m_watchonly_trusted
Definition: receive.h:55
CWalletTx::tx
CTransactionRef tx
Definition: transaction.h:138
WALLET_FLAG_AVOID_REUSE
@ WALLET_FLAG_AVOID_REUSE
Definition: walletutil.h:41
consensus.h
COutputEntry
Definition: receive.h:37
TxGetCredit
CAmount TxGetCredit(const CWallet &wallet, const CTransaction &tx, const isminefilter &filter)
Definition: receive.cpp:52
CAmount
int64_t CAmount
Amount in satoshis (Can be negative)
Definition: amount.h:12
OutputGetChange
CAmount OutputGetChange(const CWallet &wallet, const CTxOut &txout)
Definition: receive.cpp:91
TxGetChange
CAmount TxGetChange(const CWallet &wallet, const CTransaction &tx)
Definition: receive.cpp:99
Balance::m_mine_immature
CAmount m_mine_immature
Immature coinbases in the main chain.
Definition: receive.h:54
OutputGetCredit
CAmount OutputGetCredit(const CWallet &wallet, const CTxOut &txout, const isminefilter &filter)
Definition: receive.cpp:44
base_blob::ToString
std::string ToString() const
Definition: uint256.cpp:64
uint256
256-bit opaque blob.
Definition: uint256.h:124
ISMINE_NO
@ ISMINE_NO
Definition: ismine.h:40
CScript
Serialized script, used inside transaction inputs and outputs.
Definition: script.h:405
ExtractDestination
bool ExtractDestination(const CScript &scriptPubKey, CTxDestination &addressRet)
Parse a standard scriptPubKey for the destination address.
Definition: standard.cpp:213
CNoDestination
Definition: standard.h:73
ISMINE_SPENDABLE
@ ISMINE_SPENDABLE
Definition: ismine.h:42
transaction.h
CachedTxGetImmatureCredit
CAmount CachedTxGetImmatureCredit(const CWallet &wallet, const CWalletTx &wtx, bool fUseCache)
Definition: receive.cpp:163
GetCachableAmount
static CAmount GetCachableAmount(const CWallet &wallet, const CWalletTx &wtx, CWalletTx::AmountType type, const isminefilter &filter, bool recalculate=false)
Definition: receive.cpp:112
CWalletTx::CREDIT
@ CREDIT
Definition: transaction.h:104
COutPoint::n
uint32_t n
Definition: transaction.h:30
LOCK
#define LOCK(cs)
Definition: sync.h:226
CWallet
A CWallet maintains a set of transactions and balances, and provides the ability to create new transa...
Definition: wallet.h:228
CWalletTx::GetHash
const uint256 & GetHash() const
Definition: transaction.h:266
CWalletTx
A transaction with a bunch of additional info that only the owner cares about.
Definition: transaction.h:46
CachedTxIsFromMe
bool CachedTxIsFromMe(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
Definition: receive.cpp:272
CTxIn::prevout
COutPoint prevout
Definition: transaction.h:68
ISMINE_USED
@ ISMINE_USED
Definition: ismine.h:43
receive.h
Balance::m_mine_trusted
CAmount m_mine_trusted
Trusted, at depth=GetBalance.min_depth or more.
Definition: receive.h:52
CWalletTx::IMMATURE_CREDIT
@ IMMATURE_CREDIT
Definition: transaction.h:104
CWalletTx::DEBIT
@ DEBIT
Definition: transaction.h:104
InputIsMine
isminetype InputIsMine(const CWallet &wallet, const CTxIn &txin)
Definition: receive.cpp:10
CScript::IsUnspendable
bool IsUnspendable() const
Returns whether the script is guaranteed to fail at execution, regardless of the initial stack.
Definition: script.h:544
CWalletTx::m_amounts
CachableAmount m_amounts[AMOUNTTYPE_ENUM_ELEMENTS]
Definition: transaction.h:105
Balance::m_mine_untrusted_pending
CAmount m_mine_untrusted_pending
Untrusted, but in mempool (pending)
Definition: receive.h:53
CWalletTx::InMempool
bool InMempool() const
Definition: transaction.cpp:16
CachedTxGetDebit
CAmount CachedTxGetDebit(const CWallet &wallet, const CWalletTx &wtx, const isminefilter &filter)
filter decides which addresses will count towards the debit
Definition: receive.cpp:139
Balance::m_watchonly_immature
CAmount m_watchonly_immature
Definition: receive.h:57
CachedTxGetAmounts
void CachedTxGetAmounts(const CWallet &wallet, const CWalletTx &wtx, std::list< COutputEntry > &listReceived, std::list< COutputEntry > &listSent, CAmount &nFee, const isminefilter &filter)
Definition: receive.cpp:215