![]() |
Bitcoin Core 31.0.0
P2P Digital Currency
|
#include <coinselection.h>
Public Member Functions | |
| SelectionResult (const CAmount target, SelectionAlgorithm algo) | |
| SelectionResult ()=delete | |
| CAmount | GetSelectedValue () const |
| Get the sum of the input values. | |
| CAmount | GetSelectedEffectiveValue () const |
| CAmount | GetTotalBumpFees () const |
| void | Clear () |
| void | AddInput (const OutputGroup &group) |
| void | AddInputs (const OutputSet &inputs, bool subtract_fee_outputs) |
| void | SetBumpFeeDiscount (CAmount discount) |
| How much individual inputs overestimated the bump fees for shared ancestries. | |
| void | RecalculateWaste (CAmount min_viable_change, CAmount change_cost, CAmount change_fee) |
| Calculates and stores the waste for this result given the cost of change and the opportunity cost of spending these inputs now vs in the future. | |
| CAmount | GetWaste () const |
| void | SetAlgoCompleted (bool algo_completed) |
| Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries. | |
| bool | GetAlgoCompleted () const |
| Get m_algo_completed. | |
| void | SetSelectionsEvaluated (size_t attempts) |
| Record the number of selections that were evaluated. | |
| size_t | GetSelectionsEvaluated () const |
| Get selections_evaluated. | |
| void | Merge (const SelectionResult &other) |
| Combines the. | |
| const OutputSet & | GetInputSet () const |
| Get m_selected_inputs. | |
| std::vector< std::shared_ptr< COutput > > | GetShuffledInputVector () const |
| Get the vector of COutputs that will be used to fill in a CTransaction's vin. | |
| bool | operator< (SelectionResult other) const |
| CAmount | GetChange (CAmount min_viable_change, CAmount change_fee) const |
| Get the amount for the change output after paying needed fees. | |
| CAmount | GetTarget () const |
| SelectionAlgorithm | GetAlgo () const |
| int | GetWeight () const |
Private Member Functions | |
| template<typename T > | |
| void | InsertInputs (const T &inputs) |
Private Attributes | |
| OutputSet | m_selected_inputs |
| Set of inputs selected by the algorithm to use in the transaction. | |
| CAmount | m_target |
| The target the algorithm selected for. | |
| SelectionAlgorithm | m_algo |
| The algorithm used to produce this result. | |
| bool | m_use_effective {false} |
| Whether the input values for calculations should be the effective value (true) or normal value (false) | |
| std::optional< CAmount > | m_waste |
| The computed waste. | |
| bool | m_algo_completed {true} |
| False if algorithm was cut short by hitting limit of attempts and solution is non-optimal. | |
| size_t | m_selections_evaluated |
| The count of selections that were evaluated by this coin selection attempt. | |
| int | m_weight {0} |
| Total weight of the selected inputs. | |
| CAmount | bump_fee_group_discount {0} |
| How much individual inputs overestimated the bump fees for the shared ancestry. | |
Definition at line 330 of file coinselection.h.
|
inlineexplicit |
Definition at line 364 of file coinselection.h.
|
delete |
| void wallet::SelectionResult::AddInput | ( | const OutputGroup & | group | ) |
Definition at line 902 of file coinselection.cpp.
Definition at line 911 of file coinselection.cpp.
| void wallet::SelectionResult::Clear | ( | ) |
|
inline |
| bool wallet::SelectionResult::GetAlgoCompleted | ( | ) | const |
Get m_algo_completed.
Definition at line 860 of file coinselection.cpp.
Get the amount for the change output after paying needed fees.
The change amount is not 100% precise due to discrepancies in fee calculation. The final change amount (if any) should be corrected after calculating the final tx fees. When there is a discrepancy, most of the time the final change would be slightly bigger than estimated.
Following are the possible factors of discrepancy:
| [in] | min_viable_change | Minimum amount for change output, if change would be less then we forgo change |
| [in] | change_fee | Fees to include change output in the tx |
Definition at line 975 of file coinselection.cpp.
| const OutputSet & wallet::SelectionResult::GetInputSet | ( | ) | const |
Get m_selected_inputs.
Definition at line 936 of file coinselection.cpp.
| CAmount wallet::SelectionResult::GetSelectedEffectiveValue | ( | ) | const |
| CAmount wallet::SelectionResult::GetSelectedValue | ( | ) | const |
Get the sum of the input values.
Definition at line 880 of file coinselection.cpp.
| size_t wallet::SelectionResult::GetSelectionsEvaluated | ( | ) | const |
Get selections_evaluated.
Definition at line 870 of file coinselection.cpp.
| std::vector< std::shared_ptr< COutput > > wallet::SelectionResult::GetShuffledInputVector | ( | ) | const |
Get the vector of COutputs that will be used to fill in a CTransaction's vin.
Definition at line 941 of file coinselection.cpp.
|
inline |
| CAmount wallet::SelectionResult::GetTotalBumpFees | ( | ) | const |
Definition at line 890 of file coinselection.cpp.
| CAmount wallet::SelectionResult::GetWaste | ( | ) | const |
|
inline |
Definition at line 353 of file coinselection.h.
| void wallet::SelectionResult::Merge | ( | const SelectionResult & | other | ) |
Combines the.
| [in] | other | selection result into 'this' selection result. |
Important note: There must be no shared 'COutput' among the two selection results being combined.
Definition at line 922 of file coinselection.cpp.
| bool wallet::SelectionResult::operator< | ( | SelectionResult | other | ) | const |
Definition at line 948 of file coinselection.cpp.
| void wallet::SelectionResult::RecalculateWaste | ( | CAmount | min_viable_change, |
| CAmount | change_cost, | ||
| CAmount | change_fee ) |
Calculates and stores the waste for this result given the cost of change and the opportunity cost of spending these inputs now vs in the future.
If change exists, waste = change_cost + inputs * (effective_feerate - long_term_feerate) - bump_fee_group_discount If no change, waste = excess + inputs * (effective_feerate - long_term_feerate) - bump_fee_group_discount where excess = selected_effective_value - target change_cost = effective_feerate * change_output_size + long_term_feerate * change_spend_size
| [in] | min_viable_change | The minimum amount necessary to make a change output economic |
| [in] | change_cost | The cost of creating a change output and spending it in the future. Only used if there is change, in which case it must be non-negative. |
| [in] | change_fee | The fee for creating a change output |
Definition at line 827 of file coinselection.cpp.
Tracks that algorithm was able to exhaustively search the entire combination space before hitting limit of tries.
Definition at line 855 of file coinselection.cpp.
How much individual inputs overestimated the bump fees for shared ancestries.
Definition at line 820 of file coinselection.cpp.
Record the number of selections that were evaluated.
Definition at line 865 of file coinselection.cpp.
|
private |
How much individual inputs overestimated the bump fees for the shared ancestry.
Definition at line 350 of file coinselection.h.
|
private |
The algorithm used to produce this result.
Definition at line 338 of file coinselection.h.
False if algorithm was cut short by hitting limit of attempts and solution is non-optimal.
Definition at line 344 of file coinselection.h.
|
private |
Set of inputs selected by the algorithm to use in the transaction.
Definition at line 334 of file coinselection.h.
|
private |
The count of selections that were evaluated by this coin selection attempt.
Definition at line 346 of file coinselection.h.
|
private |
The target the algorithm selected for.
Equal to the recipient amount plus non-input fees
Definition at line 336 of file coinselection.h.
Whether the input values for calculations should be the effective value (true) or normal value (false)
Definition at line 340 of file coinselection.h.
|
private |
The computed waste.
Definition at line 342 of file coinselection.h.
|
private |
Total weight of the selected inputs.
Definition at line 348 of file coinselection.h.