Bitcoin Core  24.99.0
P2P Digital Currency
Classes | Namespaces | Enumerations | Functions | Variables
coinselection.h File Reference
#include <consensus/amount.h>
#include <consensus/consensus.h>
#include <policy/feerate.h>
#include <primitives/transaction.h>
#include <random.h>
#include <util/system.h>
#include <util/check.h>
#include <optional>
Include dependency graph for coinselection.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  wallet::COutput
 A UTXO under consideration for use in funding a new transaction. More...
 
struct  wallet::CoinSelectionParams
 Parameters for one iteration of Coin Selection. More...
 
struct  wallet::CoinEligibilityFilter
 Parameters for filtering which OutputGroups we may use in coin selection. More...
 
struct  wallet::OutputGroup
 A group of UTXOs paid to the same output script. More...
 
struct  wallet::SelectionResult
 

Namespaces

 wallet
 

Enumerations

enum class  wallet::SelectionAlgorithm : uint8_t { wallet::BNB = 0 , wallet::KNAPSACK = 1 , wallet::SRD = 2 , wallet::MANUAL = 3 }
 

Functions

CAmount wallet::GetSelectionWaste (const std::set< COutput > &inputs, CAmount change_cost, CAmount target, bool use_effective_value=true)
 Compute the waste for this result given the cost of change and the opportunity cost of spending these inputs now vs in the future. More...
 
CAmount wallet::GenerateChangeTarget (const CAmount payment_value, const CAmount change_fee, FastRandomContext &rng)
 Choose a random change target for each transaction to make it harder to fingerprint the Core wallet based on the change output values of transactions it creates. More...
 
std::string wallet::GetAlgorithmName (const SelectionAlgorithm algo)
 
std::optional< SelectionResult > wallet::SelectCoinsBnB (std::vector< OutputGroup > &utxo_pool, const CAmount &selection_target, const CAmount &cost_of_change)
 
std::optional< SelectionResult > wallet::SelectCoinsSRD (const std::vector< OutputGroup > &utxo_pool, CAmount target_value, FastRandomContext &rng)
 Select coins by Single Random Draw. More...
 
std::optional< SelectionResult > wallet::KnapsackSolver (std::vector< OutputGroup > &groups, const CAmount &nTargetValue, CAmount change_target, FastRandomContext &rng)
 

Variables

static constexpr CAmount wallet::CHANGE_LOWER {50000}
 lower bound for randomly-chosen target change amount More...
 
static constexpr CAmount wallet::CHANGE_UPPER {1000000}
 upper bound for randomly-chosen target change amount More...