Select a set of coins such that nTargetValue is met; never select unconfirmed coins if they are not ours
Declared in <wallet/spend.h>
[[requires_capability(0x7f2e1e6568e8)]]
util::Result<SelectionResult>
AutomaticCoinSelection(
CWallet const& wallet,
CoinsResult& available_coins,
CAmount const& nTargetValue,
CoinSelectionParams const& coin_selection_params);
If successful, a SelectionResult containing the selected coins If failed, returns (1) an empty error message if the target was not reached (general "Insufficient funds") or (2) an specific error message if there was something particularly wrong (e.g. a selection result that surpassed the tx max weight size).
| Name | Description |
|---|---|
| wallet [in] | The wallet which provides data necessary to spend the selected coins |
| available_coins [in] | The struct of coins, organized by OutputType, available for selection prior to filtering |
| nTargetValue [in] | The target value |
| coin_selection_params [in] | Parameters for this coin selection such as feerates, whether to avoid partial spends, and whether to subtract the fee from the outputs. |