Skip to content

Commit 2de222c

Browse files
committed
wallet: Use GetSelectionAmount for target value calculations
For target value calculations, GetSelectionAmount should be used, not m_effective_value or m_value. Specifically, ApproximateBestSubset mistakenly uses m_value when calculating whether the target value has been met. This has been changed to use GetSelectionAmount.
1 parent 77e23ca commit 2de222c

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/wallet/coinselection.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,7 @@ static void ApproximateBestSubset(const std::vector<OutputGroup>& groups, const
195195
//the selection random.
196196
if (nPass == 0 ? insecure_rand.randbool() : !vfIncluded[i])
197197
{
198-
nTotal += groups[i].m_value;
198+
nTotal += groups[i].GetSelectionAmount();
199199
vfIncluded[i] = true;
200200
if (nTotal >= nTargetValue)
201201
{
@@ -205,7 +205,7 @@ static void ApproximateBestSubset(const std::vector<OutputGroup>& groups, const
205205
nBest = nTotal;
206206
vfBest = vfIncluded;
207207
}
208-
nTotal -= groups[i].m_value;
208+
nTotal -= groups[i].GetSelectionAmount();
209209
vfIncluded[i] = false;
210210
}
211211
}

0 commit comments

Comments
 (0)