diff options
author | furszy <matiasfurszyfer@protonmail.com> | 2022-08-05 12:08:18 -0300 |
---|---|---|
committer | furszy <matiasfurszyfer@protonmail.com> | 2022-10-26 15:52:35 -0300 |
commit | 37e7887cb4bfd7db6eb462ed0741c45aea22a990 (patch) | |
tree | 34b74163cde2f0d2c40563c3230a56efb2506726 /src | |
parent | 94c0766b0cd1990c1399a745c88c2ba4c685d8d1 (diff) | |
download | bitcoin-37e7887cb4bfd7db6eb462ed0741c45aea22a990.tar.xz |
wallet: skip manually selected coins from 'AvailableCoins' result
No need to walk through the entire wallet's txes map just to get
coins that we could have gotten by just doing a simple map.find(out.hash).
(Which is what we are doing inside `SelectCoins` anyway)
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/spend.cpp | 12 |
1 files changed, 2 insertions, 10 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index e65644d8e4..cd0c7c4a09 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -230,7 +230,8 @@ CoinsResult AvailableCoins(const CWallet& wallet, if (output.nValue < nMinimumAmount || output.nValue > nMaximumAmount) continue; - if (coinControl && coinControl->HasSelected() && !coinControl->m_allow_other_inputs && !coinControl->IsSelected(outpoint)) + // Skip manually selected coins (the caller can fetch them directly) + if (coinControl && coinControl->HasSelected() && coinControl->IsSelected(outpoint)) continue; if (wallet.IsLockedCoin(outpoint)) @@ -528,9 +529,6 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a OutputGroup preset_inputs(coin_selection_params); - // calculate value from preset inputs and store them - std::set<COutPoint> preset_coins; - std::vector<COutPoint> vPresetInputs; coin_control.ListSelected(vPresetInputs); for (const COutPoint& outpoint : vPresetInputs) { @@ -571,7 +569,6 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a } else { value_to_select -= output.GetEffectiveValue(); } - preset_coins.insert(outpoint); /* Set ancestors and descendants to 0 as they don't matter for preset inputs since no actual selection is being done. * positive_only is set to false because we want to include all preset inputs, even if they are dust. */ @@ -593,11 +590,6 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a return result; } - // remove preset inputs from coins so that Coin Selection doesn't pick them. - if (coin_control.HasSelected()) { - available_coins.Erase(preset_coins); - } - unsigned int limit_ancestor_count = 0; unsigned int limit_descendant_count = 0; wallet.chain().getPackageLimits(limit_ancestor_count, limit_descendant_count); |