MCPcopy Create free account
hub / github.com/ElementsProject/elements / GetAddressBalances

Function GetAddressBalances

src/wallet/receive.cpp:386–425  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

384}
385
386std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet)
387{
388 std::map<CTxDestination, CAmount> balances;
389
390 {
391 LOCK(wallet.cs_wallet);
392 std::set<uint256> trusted_parents;
393 for (const auto& walletEntry : wallet.mapWallet)
394 {
395 const CWalletTx& wtx = walletEntry.second;
396
397 if (!CachedTxIsTrusted(wallet, wtx, trusted_parents))
398 continue;
399
400 if (wallet.IsTxImmatureCoinBase(wtx))
401 continue;
402
403 int nDepth = wallet.GetTxDepthInMainChain(wtx);
404 if (nDepth < (CachedTxIsFromMe(wallet, wtx, ISMINE_ALL) ? 0 : 1))
405 continue;
406
407 for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
408 {
409 CTxDestination addr;
410 if (!wallet.IsMine(wtx.tx->vout[i]))
411 continue;
412 if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
413 continue;
414
415 CAmount n = wallet.IsSpent(walletEntry.first, i) ? 0 : wtx.GetOutputValueOut(wallet, i);
416 if (n < 0) {
417 continue;
418 }
419 balances[addr] += n;
420 }
421 }
422 }
423
424 return balances;
425}
426
427std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet)
428{

Callers 1

listaddressgroupingsFunction · 0.85

Calls 9

CachedTxIsTrustedFunction · 0.85
CachedTxIsFromMeFunction · 0.85
ExtractDestinationFunction · 0.85
IsTxImmatureCoinBaseMethod · 0.80
GetTxDepthInMainChainMethod · 0.80
GetOutputValueOutMethod · 0.80
sizeMethod · 0.45
IsMineMethod · 0.45
IsSpentMethod · 0.45

Tested by

no test coverage detected