mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-11-12 23:18:14 +01:00
Use real value when calculating OutputGroup value
OutputGroup::m_value is the true value, not the effective value, so use the true values of the outputs, not their effective values.
This commit is contained in:
@@ -302,7 +302,7 @@ bool KnapsackSolver(const CAmount& nTargetValue, std::vector<OutputGroup>& group
|
|||||||
void OutputGroup::Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants) {
|
void OutputGroup::Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants) {
|
||||||
m_outputs.push_back(output);
|
m_outputs.push_back(output);
|
||||||
m_from_me &= from_me;
|
m_from_me &= from_me;
|
||||||
m_value += output.effective_value;
|
m_value += output.txout.nValue;
|
||||||
m_depth = std::min(m_depth, depth);
|
m_depth = std::min(m_depth, depth);
|
||||||
// ancestors here express the number of ancestors the new coin will end up having, which is
|
// ancestors here express the number of ancestors the new coin will end up having, which is
|
||||||
// the sum, rather than the max; this will overestimate in the cases where multiple inputs
|
// the sum, rather than the max; this will overestimate in the cases where multiple inputs
|
||||||
@@ -318,7 +318,7 @@ std::vector<CInputCoin>::iterator OutputGroup::Discard(const CInputCoin& output)
|
|||||||
auto it = m_outputs.begin();
|
auto it = m_outputs.begin();
|
||||||
while (it != m_outputs.end() && it->outpoint != output.outpoint) ++it;
|
while (it != m_outputs.end() && it->outpoint != output.outpoint) ++it;
|
||||||
if (it == m_outputs.end()) return it;
|
if (it == m_outputs.end()) return it;
|
||||||
m_value -= output.effective_value;
|
m_value -= output.txout.nValue;
|
||||||
effective_value -= output.effective_value;
|
effective_value -= output.effective_value;
|
||||||
return m_outputs.erase(it);
|
return m_outputs.erase(it);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user