diff options
author | Karl-Johan Alm <kalle.alm@gmail.com> | 2018-07-31 04:42:41 +0900 |
---|---|---|
committer | Karl-Johan Alm <kalle.alm@gmail.com> | 2018-07-31 04:54:41 +0900 |
commit | 23fbbb100f63cb621b4b901dac0c0f16d7d74bc7 (patch) | |
tree | a0e2a633d738d5f7fd58854fa4342c23fa41e89f /src | |
parent | 4d550ffab64d79a44fcaa76f6e30c28f01614d3f (diff) |
wallet: sum ancestors rather than taking max in output groups
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/coinselection.cpp | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/wallet/coinselection.cpp b/src/wallet/coinselection.cpp index 1a810e763f..710146ef96 100644 --- a/src/wallet/coinselection.cpp +++ b/src/wallet/coinselection.cpp @@ -299,12 +299,12 @@ void OutputGroup::Insert(const CInputCoin& output, int depth, bool from_me, size m_from_me &= from_me; m_value += output.effective_value; m_depth = std::min(m_depth, depth); - // m_ancestors is currently the max ancestor count for all coins in the group; however, this is - // not ideal, as a wallet will consider e.g. thirty 2-ancestor coins as having two ancestors, - // when in reality it has 60 ancestors. - m_ancestors = std::max(m_ancestors, ancestors); - // m_descendants is the count as seen from the top ancestor, not the descendants as seen from the - // coin itself; thus, this value is accurate + // 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 + // have common ancestors + m_ancestors += ancestors; + // descendants is the count as seen from the top ancestor, not the descendants as seen from the + // coin itself; thus, this value is counted as the max, not the sum m_descendants = std::max(m_descendants, descendants); effective_value = m_value; } |