if(curr_value+curr_available_value<selection_target||// Cannot possibly reach target with the amount remaining in the curr_available_value.
if(curr_value+curr_available_value<selection_target||// Cannot possibly reach target with the amount remaining in the curr_available_value.
curr_value>selection_target+cost_of_change||// Selected value is out of range, go back and try other branch
curr_value>selection_target+cost_of_change||// Selected value is out of range, go back and try other branch
(curr_waste>best_waste&&(utxo_pool.at(0).fee-utxo_pool.at(0).long_term_fee)>0)){// Don't select things which we know will be more wasteful if the waste is increasing
(curr_waste>best_waste&&(utxo_pool.at(0).fee-utxo_pool.at(0).long_term_fee)>0)){// Don't select things which we know will be more wasteful if the waste is increasing
backtrack=true;
backtrack=true;
}elseif(curr_value>=selection_target){// Selected value is within range
}elseif(curr_value>=selection_target){// Selected value is within range
// Remove this utxo from the curr_available_value utxo amount
// Remove this utxo from the curr_available_value utxo amount
curr_available_value-=utxo.GetSelectionAmount();
curr_available_value-=utxo.GetSelectionAmount();
// Avoid searching a branch if the previous UTXO has the same value and same waste and was excluded. Since the ratio of fee to
// long term fee is the same, we only need to check if one of those values match in order to know that the waste is the same.
if(curr_selection.empty()||
if(curr_selection.empty()||
// The previous index is included and therefore not relevant for exclusion shortcut
// The previous index is included and therefore not relevant for exclusion shortcut
(utxo_pool_index-1)==curr_selection.back()||
(utxo_pool_index-1)==curr_selection.back()||
// Avoid searching a branch if the previous UTXO has the same value and same waste and was excluded.
// Since the ratio of fee to long term fee is the same, we only need to check if one of those values match in order to know that the waste is the same.