MCPcopy Create free account
hub / github.com/LUX-Core/lux / GetAddressBalances

Method GetAddressBalances

src/wallet.cpp:3810–3846  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3808}
3809
3810std::map<CTxDestination, CAmount> CWallet::GetAddressBalances()
3811{
3812 map<CTxDestination, CAmount> balances;
3813
3814 {
3815 LOCK(cs_wallet);
3816 for (const auto& walletEntry : mapWallet) {
3817 const CWalletTx* pcoin = &walletEntry.second;
3818
3819 if (!IsFinalTx(*pcoin) || !pcoin->IsTrusted())
3820 continue;
3821
3822 if (pcoin->IsCoinBase() && pcoin->GetBlocksToMaturity() > 0)
3823 continue;
3824
3825 int nDepth = pcoin->GetDepthInMainChain();
3826 if (nDepth < (pcoin->IsFromMe(ISMINE_ALL) ? 0 : 1))
3827 continue;
3828
3829 for (unsigned int i = 0; i < pcoin->vout.size(); i++) {
3830 CTxDestination addr;
3831 if (!IsMine(pcoin->vout[i]))
3832 continue;
3833 if (!ExtractDestination(pcoin->vout[i].scriptPubKey, addr))
3834 continue;
3835
3836 CAmount n = IsSpent(walletEntry.first, i) ? 0 : pcoin->vout[i].nValue;
3837
3838 if (!balances.count(addr))
3839 balances[addr] = 0;
3840 balances[addr] += n;
3841 }
3842 }
3843 }
3844
3845 return balances;
3846}
3847
3848set<set<CTxDestination> > CWallet::GetAddressGroupings()
3849{

Callers 2

listaddressgroupingsFunction · 0.80
listaddressbalancesFunction · 0.80

Calls 10

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

Tested by

no test coverage detected