MCPcopy Create free account
hub / github.com/bitcoin/bitcoin / Insert

Method Insert

src/wallet/coinselection.cpp:829–854  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

827 ******************************************************************************/
828
829void OutputGroup::Insert(const std::shared_ptr<COutput>& output, size_t ancestors, size_t cluster_count) {
830 m_outputs.push_back(output);
831 auto& coin = *m_outputs.back();
832
833 fee += coin.GetFee();
834
835 coin.long_term_fee = coin.input_bytes < 0 ? 0 : m_long_term_feerate.GetFee(coin.input_bytes);
836 long_term_fee += coin.long_term_fee;
837
838 effective_value += coin.GetEffectiveValue();
839
840 m_from_me &= coin.from_me;
841 m_value += coin.txout.nValue;
842 m_depth = std::min(m_depth, coin.depth);
843 // ancestors here express the number of ancestors the new coin will end up having, which is
844 // the sum, rather than the max; this will overestimate in the cases where multiple inputs
845 // have common ancestors
846 m_ancestors += ancestors;
847 // This is the maximum cluster count among all outputs. If these outputs are from distinct clusters but spent in the
848 // same transaction, their clusters will be merged, potentially exceeding the mempool's max cluster count.
849 m_max_cluster_count = std::max(m_max_cluster_count, cluster_count);
850
851 if (output->input_bytes > 0) {
852 m_weight += output->input_bytes * WITNESS_SCALE_FACTOR;
853 }
854}
855
856bool OutputGroup::EligibleForSpending(const CoinEligibilityFilter& eligibility_filter) const
857{

Callers 6

GroupOutputsFunction · 0.45
add_coinFunction · 0.45
MakeCoinFunction · 0.45
GroupCoinsFunction · 0.45
FUZZ_TARGETFunction · 0.45

Calls 4

GetEffectiveValueMethod · 0.80
push_backMethod · 0.45
backMethod · 0.45
GetFeeMethod · 0.45

Tested by 4

add_coinFunction · 0.36
MakeCoinFunction · 0.36
GroupCoinsFunction · 0.36
FUZZ_TARGETFunction · 0.36