aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAurèle Oulès <aurele@oules.com>2022-09-29 14:54:16 +0200
committerglozow <gloriajzhao@gmail.com>2022-10-04 09:58:16 +0100
commit21f96f40d18e0b052cb4ef24cda7847051ca16d8 (patch)
tree9b3cda5d0cb0f29bc6d72066fb4cea008f1beda7
parent4be489d4d4a1b8ef64d9f6dcdbc0c6574f934aa4 (diff)
downloadbitcoin-21f96f40d18e0b052cb4ef24cda7847051ca16d8.tar.xz
wallet: Use correct effective value when checking target
-rw-r--r--src/wallet/spend.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp
index d84310c323..ce41a4e954 100644
--- a/src/wallet/spend.cpp
+++ b/src/wallet/spend.cpp
@@ -590,7 +590,13 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, CoinsResult& a
if (coin_control.HasSelected() && !coin_control.m_allow_other_inputs) {
SelectionResult result(nTargetValue, SelectionAlgorithm::MANUAL);
result.AddInput(preset_inputs);
- if (result.GetSelectedValue() < nTargetValue) return std::nullopt;
+
+ if (!coin_selection_params.m_subtract_fee_outputs && result.GetSelectedEffectiveValue() < nTargetValue) {
+ return std::nullopt;
+ } else if (result.GetSelectedValue() < nTargetValue) {
+ return std::nullopt;
+ }
+
result.ComputeAndSetWaste(coin_selection_params.min_viable_change, coin_selection_params.m_cost_of_change, coin_selection_params.m_change_fee);
return result;
}