| 384 | } |
| 385 | |
| 386 | std::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 | |
| 427 | std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet) |
| 428 | { |
no test coverage detected