@@ -445,10 +445,10 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet,
445445 // OUTPUT_GROUP_MAX_ENTRIES COutputs, a new OutputGroup is added to the end of the vector.
446446 typedef std::map<std::pair<CScript, OutputType>, std::vector<OutputGroup>> ScriptPubKeyToOutgroup;
447447 const auto & group_outputs = [](
448- const COutput& output, OutputType type, size_t ancestors, size_t descendants,
448+ const std::shared_ptr< COutput> & output, OutputType type, size_t ancestors, size_t descendants,
449449 ScriptPubKeyToOutgroup& groups_map, const CoinSelectionParams& coin_sel_params,
450450 bool positive_only) {
451- std::vector<OutputGroup>& groups = groups_map[std::make_pair (output. txout .scriptPubKey ,type)];
451+ std::vector<OutputGroup>& groups = groups_map[std::make_pair (output-> txout .scriptPubKey ,type)];
452452
453453 if (groups.size () == 0 ) {
454454 // No OutputGroups for this scriptPubKey yet, add one
@@ -468,8 +468,8 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet,
468468 }
469469
470470 // Filter for positive only before adding the output to group
471- if (!positive_only || output. GetEffectiveValue () > 0 ) {
472- group->Insert (std::make_shared<COutput>( output) , ancestors, descendants);
471+ if (!positive_only || output-> GetEffectiveValue () > 0 ) {
472+ group->Insert (output, ancestors, descendants);
473473 }
474474 };
475475
@@ -483,8 +483,9 @@ FilteredOutputGroups GroupOutputs(const CWallet& wallet,
483483 size_t ancestors, descendants;
484484 wallet.chain ().getTransactionAncestry (output.outpoint .hash , ancestors, descendants);
485485
486- group_outputs (output, type, ancestors, descendants, spk_to_groups_map, coin_sel_params, /* positive_only=*/ false );
487- group_outputs (output, type, ancestors, descendants, spk_to_positive_groups_map,
486+ const auto & shared_output = std::make_shared<COutput>(output);
487+ group_outputs (shared_output, type, ancestors, descendants, spk_to_groups_map, coin_sel_params, /* positive_only=*/ false );
488+ group_outputs (shared_output, type, ancestors, descendants, spk_to_positive_groups_map,
488489 coin_sel_params, /* positive_only=*/ true );
489490 }
490491 }
0 commit comments