From 15b58383d0029c4ae7b487e03cd451e1580eb91d Mon Sep 17 00:00:00 2001 From: Andrew Chow Date: Wed, 23 Mar 2022 13:17:07 -0400 Subject: [PATCH] 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. --- src/wallet/spend.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/wallet/spend.cpp b/src/wallet/spend.cpp index b4b726d4fd9..233478af41e 100644 --- a/src/wallet/spend.cpp +++ b/src/wallet/spend.cpp @@ -438,6 +438,7 @@ std::optional 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 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; }