wallet: compute waste for SelectionResults of preset inputs

When we use only manually specified inputs, we should still calculate
the waste so that if anything later on calls GetWaste (in order to log
it), there won't be an error.
This commit is contained in:
Andrew Chow committed 2022-04-14 12:40:36 -04:00
1 parent 912f1ed181
commit 15b58383d0
1 file changed
+4
+4
View File
@@ -438,6 +438,7 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
SelectionResult result(nTargetValue, SelectionAlgorithm::MANUAL);
result.AddInput(preset_inputs);
if (result.GetSelectedValue() < nTargetValue) return std::nullopt;
result.ComputeAndSetWaste(coin_selection_params.m_cost_of_change);
return result;
}
@@ -573,6 +574,9 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
// Add preset inputs to result
res->AddInput(preset_inputs);
if (res->m_algo == SelectionAlgorithm::MANUAL) {
res->ComputeAndSetWaste(coin_selection_params.m_cost_of_change);
}
return res;
}