Skip to content

Commit 23fbbb1

Browse files
committed
wallet: sum ancestors rather than taking max in output groups
1 parent 4d550ff commit 23fbbb1

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/wallet/coinselection.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,12 +299,12 @@ void OutputGroup::Insert(const CInputCoin& output, int depth, bool from_me, size
299299
m_from_me &= from_me;
300300
m_value += output.effective_value;
301301
m_depth = std::min(m_depth, depth);
302-
// m_ancestors is currently the max ancestor count for all coins in the group; however, this is
303-
// not ideal, as a wallet will consider e.g. thirty 2-ancestor coins as having two ancestors,
304-
// when in reality it has 60 ancestors.
305-
m_ancestors = std::max(m_ancestors, ancestors);
306-
// m_descendants is the count as seen from the top ancestor, not the descendants as seen from the
307-
// coin itself; thus, this value is accurate
302+
// ancestors here express the number of ancestors the new coin will end up having, which is
303+
// the sum, rather than the max; this will overestimate in the cases where multiple inputs
304+
// have common ancestors
305+
m_ancestors += ancestors;
306+
// descendants is the count as seen from the top ancestor, not the descendants as seen from the
307+
// coin itself; thus, this value is counted as the max, not the sum
308308
m_descendants = std::max(m_descendants, descendants);
309309
effective_value = m_value;
310310
}

0 commit comments

Comments
 (0)