Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,681 Lines • ▼ Show 20 Lines | |||||
} | } | ||||
void CWallet::AvailableCoins(interfaces::Chain::Lock &locked_chain, | void CWallet::AvailableCoins(interfaces::Chain::Lock &locked_chain, | ||||
std::vector<COutput> &vCoins, bool fOnlySafe, | 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 { | ||||
const int nMaxDepth) const { | |||||
AssertLockHeld(cs_wallet); | AssertLockHeld(cs_wallet); | ||||
vCoins.clear(); | vCoins.clear(); | ||||
Amount nTotal = Amount::zero(); | Amount nTotal = Amount::zero(); | ||||
// Either the WALLET_FLAG_AVOID_REUSE flag is not set (in which case we | // Either the WALLET_FLAG_AVOID_REUSE flag is not set (in which case we | ||||
// always allow), or we default to avoiding, and only in the case where a | // always allow), or we default to avoiding, and only in the case where a | ||||
// coin control object is provided, and has the avoid address reuse flag set | // coin control object is provided, and has the avoid address reuse flag set | ||||
// to false, do we allow already used addresses | // to false, do we allow already used addresses | ||||
bool allow_used_addresses = | bool allow_used_addresses = | ||||
!IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE) || | !IsWalletFlagSet(WALLET_FLAG_AVOID_REUSE) || | ||||
(coinControl && !coinControl->m_avoid_address_reuse); | (coinControl && !coinControl->m_avoid_address_reuse); | ||||
const int min_depth = {coinControl ? coinControl->m_min_depth | |||||
: DEFAULT_MIN_DEPTH}; | |||||
const int max_depth = {coinControl ? coinControl->m_max_depth | |||||
: DEFAULT_MAX_DEPTH}; | |||||
const Consensus::Params params = Params().GetConsensus(); | const Consensus::Params params = Params().GetConsensus(); | ||||
for (const auto &entry : mapWallet) { | for (const auto &entry : mapWallet) { | ||||
const TxId &wtxid = entry.first; | const TxId &wtxid = entry.first; | ||||
const CWalletTx &wtx = entry.second; | const CWalletTx &wtx = entry.second; | ||||
TxValidationState state; | TxValidationState state; | ||||
Show All 39 Lines | for (const auto &entry : mapWallet) { | ||||
if (nDepth == 0 && wtx.mapValue.count("replaced_by_txid")) { | if (nDepth == 0 && wtx.mapValue.count("replaced_by_txid")) { | ||||
safeTx = false; | safeTx = false; | ||||
} | } | ||||
if (fOnlySafe && !safeTx) { | if (fOnlySafe && !safeTx) { | ||||
continue; | continue; | ||||
} | } | ||||
if (nDepth < nMinDepth || nDepth > nMaxDepth) { | if (nDepth < min_depth || nDepth > max_depth) { | ||||
continue; | continue; | ||||
} | } | ||||
for (uint32_t i = 0; i < wtx.tx->vout.size(); i++) { | for (uint32_t i = 0; i < wtx.tx->vout.size(); i++) { | ||||
if (wtx.tx->vout[i].nValue < nMinimumAmount || | if (wtx.tx->vout[i].nValue < nMinimumAmount || | ||||
wtx.tx->vout[i].nValue > nMaximumAmount) { | wtx.tx->vout[i].nValue > nMaximumAmount) { | ||||
continue; | continue; | ||||
} | } | ||||
▲ Show 20 Lines • Show All 2,689 Lines • Show Last 20 Lines |