MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / GetAddressBalances

Function GetAddressBalances

src/wallet/receive.cpp:297–323  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

295}
296
297std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet)
298{
299 std::map<CTxDestination, CAmount> balances;
300
301 {
302 LOCK(wallet.cs_wallet);
303 std::set<Txid> trusted_parents;
304 for (const auto& [outpoint, txo] : wallet.GetTXOs()) {
305 const CWalletTx& wtx = txo.GetWalletTx();
306
307 if (!CachedTxIsTrusted(wallet, wtx, trusted_parents)) continue;
308 if (wallet.IsTxImmatureCoinBase(wtx)) continue;
309
310 int nDepth = wallet.GetTxDepthInMainChain(wtx);
311 if (nDepth < (CachedTxIsFromMe(wallet, wtx) ? 0 : 1)) continue;
312
313 CTxDestination addr;
314 Assume(wallet.IsMine(txo.GetTxOut()));
315 if(!ExtractDestination(txo.GetTxOut().scriptPubKey, addr)) continue;
316
317 CAmount n = wallet.IsSpent(outpoint) ? 0 : txo.GetTxOut().nValue;
318 balances[addr] += n;
319 }
320 }
321
322 return balances;
323}
324
325std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet)
326{

Callers 1

listaddressgroupingsFunction · 0.85

Calls 9

CachedTxIsTrustedFunction · 0.85
CachedTxIsFromMeFunction · 0.85
ExtractDestinationFunction · 0.85
GetWalletTxMethod · 0.80
IsTxImmatureCoinBaseMethod · 0.80
GetTxDepthInMainChainMethod · 0.80
GetTxOutMethod · 0.80
IsMineMethod · 0.45
IsSpentMethod · 0.45

Tested by

no test coverage detected