| 295 | } |
| 296 | |
| 297 | std::map<CTxDestination, CAmount> GetAddressBalances(const CWallet& wallet) |
| 298 | { |
| 299 | std::map<CTxDestination, CAmount> balances; |
| 300 | |
| 301 | { |
| 302 | LOCK(wallet.cs_wallet); |
| 303 | std::set<Txid> trusted_parents; |
| 304 | for (const auto& [outpoint, txo] : wallet.GetTXOs()) { |
| 305 | const CWalletTx& wtx = txo.GetWalletTx(); |
| 306 | |
| 307 | if (!CachedTxIsTrusted(wallet, wtx, trusted_parents)) continue; |
| 308 | if (wallet.IsTxImmatureCoinBase(wtx)) continue; |
| 309 | |
| 310 | int nDepth = wallet.GetTxDepthInMainChain(wtx); |
| 311 | if (nDepth < (CachedTxIsFromMe(wallet, wtx) ? 0 : 1)) continue; |
| 312 | |
| 313 | CTxDestination addr; |
| 314 | Assume(wallet.IsMine(txo.GetTxOut())); |
| 315 | if(!ExtractDestination(txo.GetTxOut().scriptPubKey, addr)) continue; |
| 316 | |
| 317 | CAmount n = wallet.IsSpent(outpoint) ? 0 : txo.GetTxOut().nValue; |
| 318 | balances[addr] += n; |
| 319 | } |
| 320 | } |
| 321 | |
| 322 | return balances; |
| 323 | } |
| 324 | |
| 325 | std::set< std::set<CTxDestination> > GetAddressGroupings(const CWallet& wallet) |
| 326 | { |
no test coverage detected