https://travis-ci.org/github/bitcoin/bitcoin/jobs/679885530#L8791
{
    std::map<CTxDestination, CAmount> balances;
    {
        LOCK(cs_wallet);
        std::set<uint256> trusted_parents;
        for (const auto& walletEntry : mapWallet)
        {
            const CWalletTx& wtx = walletEntry.second;
            if (!IsTrusted(wtx, trusted_parents))
                continue;
            if (wtx.IsImmatureCoinBase())
                continue;
            int nDepth = wtx.GetDepthInMainChain();
            if (nDepth < (wtx.IsFromMe(ISMINE_ALL) ? 0 : 1))
                continue;
            for (unsigned int i = 0; i < wtx.tx->vout.size(); i++)
            {
                CTxDestination addr;
                if (!IsMine(wtx.tx->vout[i]))
                    continue;
                if(!ExtractDestination(wtx.tx->vout[i].scriptPubKey, addr))
                    continue;
                CAmount n = IsSpent(walletEntry.first, i) ? 0 : wtx.tx->vout[i].nValue;
                balances[addr] += n;
            }
        }
    }
    return balances;
}
std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() const