diff options
| author | João Barbosa <[email protected]> | 2018-02-02 11:37:50 +0000 |
|---|---|---|
| committer | João Barbosa <[email protected]> | 2018-02-08 18:18:28 +0000 |
| commit | 1beea7af92994dca83facb11bbef82b24b538400 (patch) | |
| tree | b0864ca2b002fb57e38a80f7902eb3ce0aced1fd /src/wallet/wallet.cpp | |
| parent | Merge #11869: QA: segwit.py: s/find_unspent/find_spendable_utxo/ (diff) | |
| download | discoin-1beea7af92994dca83facb11bbef82b24b538400.tar.xz discoin-1beea7af92994dca83facb11bbef82b24b538400.zip | |
[wallet] Make CWallet::ListCoins atomic
Diffstat (limited to 'src/wallet/wallet.cpp')
| -rw-r--r-- | src/wallet/wallet.cpp | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 2b8019395..e89921e95 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2198,11 +2198,12 @@ CAmount CWallet::GetAvailableBalance(const CCoinControl* coinControl) const void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, const CCoinControl *coinControl, const CAmount &nMinimumAmount, const CAmount &nMaximumAmount, const CAmount &nMinimumSumAmount, const uint64_t nMaximumCount, const int nMinDepth, const int nMaxDepth) const { + AssertLockHeld(cs_main); + AssertLockHeld(cs_wallet); + vCoins.clear(); { - LOCK2(cs_main, cs_wallet); - CAmount nTotal = 0; for (const auto& entry : mapWallet) @@ -2320,11 +2321,11 @@ std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const // avoid adding some extra complexity to the Qt code. std::map<CTxDestination, std::vector<COutput>> result; - std::vector<COutput> availableCoins; - AvailableCoins(availableCoins); LOCK2(cs_main, cs_wallet); + AvailableCoins(availableCoins); + for (auto& coin : availableCoins) { CTxDestination address; if (coin.fSpendable && |