| 443 | ******************************************************************************/ |
| 444 | |
| 445 | void OutputGroup::Insert(const CInputCoin& output, int depth, bool from_me, size_t ancestors, size_t descendants, bool positive_only) { |
| 446 | // Compute the effective value first |
| 447 | const CAmount coin_fee = output.m_input_bytes < 0 ? 0 : m_effective_feerate.GetFee(output.m_input_bytes); |
| 448 | // ELEMENTS: "effective value" only comes from the policy asset |
| 449 | const CAmount ev = output.value * (output.asset == ::policyAsset) - coin_fee; |
| 450 | |
| 451 | // Filter for positive only here before adding the coin |
| 452 | if (positive_only && ev <= 0) return; |
| 453 | |
| 454 | m_outputs.push_back(output); |
| 455 | CInputCoin& coin = m_outputs.back(); |
| 456 | |
| 457 | coin.m_fee = coin_fee; |
| 458 | fee += coin.m_fee; |
| 459 | |
| 460 | coin.m_long_term_fee = coin.m_input_bytes < 0 ? 0 : m_long_term_feerate.GetFee(coin.m_input_bytes); |
| 461 | long_term_fee += coin.m_long_term_fee; |
| 462 | |
| 463 | coin.effective_value = ev; |
| 464 | effective_value += coin.effective_value; |
| 465 | |
| 466 | m_from_me &= from_me; |
| 467 | m_value += output.value; |
| 468 | m_depth = std::min(m_depth, depth); |
| 469 | // ancestors here express the number of ancestors the new coin will end up having, which is |
| 470 | // the sum, rather than the max; this will overestimate in the cases where multiple inputs |
| 471 | // have common ancestors |
| 472 | m_ancestors += ancestors; |
| 473 | // descendants is the count as seen from the top ancestor, not the descendants as seen from the |
| 474 | // coin itself; thus, this value is counted as the max, not the sum |
| 475 | m_descendants = std::max(m_descendants, descendants); |
| 476 | } |
| 477 | |
| 478 | bool OutputGroup::EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const |
| 479 | { |