Changeset View
Changeset View
Standalone View
Standalone View
src/wallet/wallet.cpp
Show First 20 Lines • Show All 2,716 Lines • ▼ Show 20 Lines | bool CWallet::SelectCoins(const std::vector<COutput> &vAvailableCoins, | ||||
// form groups from remaining coins; note that preset coins will not | // form groups from remaining coins; note that preset coins will not | ||||
// automatically have their associated (same address) coins included | // automatically have their associated (same address) coins included | ||||
if (coin_control.m_avoid_partial_spends && | if (coin_control.m_avoid_partial_spends && | ||||
vCoins.size() > OUTPUT_GROUP_MAX_ENTRIES) { | vCoins.size() > OUTPUT_GROUP_MAX_ENTRIES) { | ||||
// Cases where we have 11+ outputs all pointing to the same destination | // Cases where we have 11+ outputs all pointing to the same destination | ||||
// may result in privacy leaks as they will potentially be | // may result in privacy leaks as they will potentially be | ||||
// deterministically sorted. We solve that by explicitly shuffling the | // deterministically sorted. We solve that by explicitly shuffling the | ||||
// outputs before processing | // outputs before processing | ||||
std::shuffle(vCoins.begin(), vCoins.end(), FastRandomContext()); | Shuffle(vCoins.begin(), vCoins.end(), FastRandomContext()); | ||||
} | } | ||||
std::vector<OutputGroup> groups = | std::vector<OutputGroup> groups = | ||||
GroupOutputs(vCoins, !coin_control.m_avoid_partial_spends); | GroupOutputs(vCoins, !coin_control.m_avoid_partial_spends); | ||||
size_t max_ancestors = std::max<size_t>( | size_t max_ancestors = std::max<size_t>( | ||||
1, gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT)); | 1, gArgs.GetArg("-limitancestorcount", DEFAULT_ANCESTOR_LIMIT)); | ||||
size_t max_descendants = std::max<size_t>( | size_t max_descendants = std::max<size_t>( | ||||
1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)); | 1, gArgs.GetArg("-limitdescendantcount", DEFAULT_DESCENDANT_LIMIT)); | ||||
▲ Show 20 Lines • Show All 483 Lines • ▼ Show 20 Lines | assert(txNew.nLockTime < LOCKTIME_THRESHOLD); | ||||
// Return any reserved key if we don't have change | // Return any reserved key if we don't have change | ||||
reservekey.ReturnKey(); | reservekey.ReturnKey(); | ||||
} | } | ||||
// Shuffle selected coins and fill in final vin | // Shuffle selected coins and fill in final vin | ||||
txNew.vin.clear(); | txNew.vin.clear(); | ||||
std::vector<CInputCoin> selected_coins(setCoins.begin(), | std::vector<CInputCoin> selected_coins(setCoins.begin(), | ||||
setCoins.end()); | setCoins.end()); | ||||
std::shuffle(selected_coins.begin(), selected_coins.end(), | Shuffle(selected_coins.begin(), selected_coins.end(), | ||||
FastRandomContext()); | FastRandomContext()); | ||||
// Note how the sequence number is set to non-maxint so that | // Note how the sequence number is set to non-maxint so that | ||||
// the nLockTime set above actually works. | // the nLockTime set above actually works. | ||||
for (const auto &coin : selected_coins) { | for (const auto &coin : selected_coins) { | ||||
txNew.vin.push_back( | txNew.vin.push_back( | ||||
CTxIn(coin.outpoint, CScript(), | CTxIn(coin.outpoint, CScript(), | ||||
std::numeric_limits<uint32_t>::max() - 1)); | std::numeric_limits<uint32_t>::max() - 1)); | ||||
} | } | ||||
▲ Show 20 Lines • Show All 1,461 Lines • Show Last 20 Lines |