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