Skip to content

Commit 15b5838

Browse files
committed
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.
1 parent 912f1ed commit 15b5838

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/wallet/spend.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
438438
SelectionResult result(nTargetValue, SelectionAlgorithm::MANUAL);
439439
result.AddInput(preset_inputs);
440440
if (result.GetSelectedValue() < nTargetValue) return std::nullopt;
441+
result.ComputeAndSetWaste(coin_selection_params.m_cost_of_change);
441442
return result;
442443
}
443444

@@ -573,6 +574,9 @@ std::optional<SelectionResult> SelectCoins(const CWallet& wallet, const std::vec
573574

574575
// Add preset inputs to result
575576
res->AddInput(preset_inputs);
577+
if (res->m_algo == SelectionAlgorithm::MANUAL) {
578+
res->ComputeAndSetWaste(coin_selection_params.m_cost_of_change);
579+
}
576580

577581
return res;
578582
}

0 commit comments

Comments
 (0)