Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,325 Lines • ▼ Show 20 Lines | |||||
void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, | void CWallet::AvailableCoins(std::vector<COutput> &vCoins, bool fOnlySafe, | ||||
const CCoinControl *coinControl, | const CCoinControl *coinControl, | ||||
const Amount nMinimumAmount, | const Amount nMinimumAmount, | ||||
const Amount nMaximumAmount, | const Amount nMaximumAmount, | ||||
const Amount nMinimumSumAmount, | const Amount nMinimumSumAmount, | ||||
const uint64_t nMaximumCount, const int nMinDepth, | const uint64_t nMaximumCount, const int nMinDepth, | ||||
const int nMaxDepth) const { | const int nMaxDepth) const { | ||||
AssertLockHeld(cs_main); | |||||
AssertLockHeld(cs_wallet); | |||||
vCoins.clear(); | vCoins.clear(); | ||||
Amount nTotal = Amount::zero(); | Amount nTotal = Amount::zero(); | ||||
LOCK2(cs_main, cs_wallet); | |||||
for (const auto &entry : mapWallet) { | for (const auto &entry : mapWallet) { | ||||
const TxId &wtxid = entry.first; | const TxId &wtxid = entry.first; | ||||
const CWalletTx *pcoin = &entry.second; | const CWalletTx *pcoin = &entry.second; | ||||
if (!CheckFinalTx(*pcoin->tx)) { | if (!CheckFinalTx(*pcoin->tx)) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Lines | std::map<CTxDestination, std::vector<COutput>> CWallet::ListCoins() const { | ||||
// CWalletTx objects, callers to this function really should acquire the | // CWalletTx objects, callers to this function really should acquire the | ||||
// cs_wallet lock before calling it. However, the current caller doesn't | // cs_wallet lock before calling it. However, the current caller doesn't | ||||
// acquire this lock yet. There was an attempt to add the missing lock in | // acquire this lock yet. There was an attempt to add the missing lock in | ||||
// https://github.com/bitcoin/bitcoin/pull/10340, but that change has been | // https://github.com/bitcoin/bitcoin/pull/10340, but that change has been | ||||
// postponed until after https://github.com/bitcoin/bitcoin/pull/10244 to | // postponed until after https://github.com/bitcoin/bitcoin/pull/10244 to | ||||
// avoid adding some extra complexity to the Qt code. | // avoid adding some extra complexity to the Qt code. | ||||
std::map<CTxDestination, std::vector<COutput>> result; | std::map<CTxDestination, std::vector<COutput>> result; | ||||
std::vector<COutput> availableCoins; | std::vector<COutput> availableCoins; | ||||
AvailableCoins(availableCoins); | |||||
LOCK2(cs_main, cs_wallet); | LOCK2(cs_main, cs_wallet); | ||||
AvailableCoins(availableCoins); | |||||
for (auto &coin : availableCoins) { | for (auto &coin : availableCoins) { | ||||
CTxDestination address; | CTxDestination address; | ||||
if (coin.fSpendable && | if (coin.fSpendable && | ||||
ExtractDestination( | ExtractDestination( | ||||
FindNonChangeParentOutput(*coin.tx->tx, coin.i).scriptPubKey, | FindNonChangeParentOutput(*coin.tx->tx, coin.i).scriptPubKey, | ||||
address)) { | address)) { | ||||
result[address].emplace_back(std::move(coin)); | result[address].emplace_back(std::move(coin)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,105 Lines • Show Last 20 Lines |