| 3526 | } |
| 3527 | |
| 3528 | std::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 | |
| 3568 | std::set< std::set<CTxDestination> > CWallet::GetAddressGroupings() |
| 3569 | { |
no test coverage detected