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

Method GetAddressBalances

src/wallet/wallet.cpp:3528–3566  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3526}
3527
3528std::map<CTxDestination, CAmount> CWallet::GetAddressBalances()
3529{
3530 std::map<CTxDestination, CAmount> balances;
3531
3532 {
3533 LOCK(cs_wallet);
3534 for (const auto& walletEntry : mapWallet)
3535 {
3536 const CWalletTx *pcoin = &walletEntry.second;
3537
3538 if (!pcoin->IsTrusted())
3539 continue;
3540
3541 if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
3542 continue;
3543
3544 int nDepth = pcoin->GetDepthInMainChain();
3545 if (nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? 0 : 1))
3546 continue;
3547
3548 for (unsigned int i = 0; i < pcoin->tx->vout.size(); i++)
3549 {
3550 CTxDestination addr;
3551 if (!IsMine(pcoin->tx->vout[i]))
3552 continue;
3553 if(!ExtractDestination(pcoin->tx->vout[i].scriptPubKey, addr))
3554 continue;
3555
3556 CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->tx->vout[i].nValue;
3557
3558 if (!balances.count(addr))
3559 balances[addr] = 0;
3560 balances[addr] += n;
3561 }
3562 }
3563 }
3564
3565 return balances;
3566}
3567
3568std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings()
3569{

Callers 1

listaddressgroupingsFunction · 0.80

Calls 9

IsMineFunction · 0.85
ExtractDestinationFunction · 0.85
IsTrustedMethod · 0.80
GetBlocksToMaturityMethod · 0.80
GetDepthInMainChainMethod · 0.80
IsCoinBaseMethod · 0.45
IsFromMeMethod · 0.45
sizeMethod · 0.45
countMethod · 0.45

Tested by

no test coverage detected