5#ifndef BITCOIN_WALLET_SPEND_H
6#define BITCOIN_WALLET_SPEND_H
41 std::map<OutputType, std::vector<COutput>>
coins;
44 std::vector<COutput>
All()
const;
52 void Erase(
const std::unordered_set<COutPoint, SaltedOutpointHasher>& coins_to_remove);
63 std::optional<CAmount> total_effective_amount{0};
87 const CCoinControl* coinControl =
nullptr,
88 std::optional<CFeeRate> feerate = std::nullopt,
116 const CoinsResult& coins,
117 const CoinSelectionParams& coin_sel_params,
118 const std::vector<SelectionFilter>& filters);
137 const CoinSelectionParams& coin_selection_params,
bool allow_mixed_output_types);
158 std::set<std::shared_ptr<COutput>>
coins;
166 if (subtract_fee_outputs) {
171 coins.insert(std::make_shared<COutput>(output));
202 const CAmount& nTargetValue,
const CCoinControl& coin_control,
static constexpr CAmount MAX_MONEY
No amount larger than this (in satoshi) is valid.
int64_t CAmount
Amount in satoshis (Can be negative)
An outpoint - a combination of a transaction hash and an index n into its vout.
The basic transaction that is broadcasted on the network and contained in blocks.
An output of a transaction.
An interface to be implemented by keystores that support signing.
Interface giving clients (wallet processes, maybe other analysis tools in the future) ability to acce...
static int sign(const secp256k1_context *ctx, struct signer_secrets *signer_secrets, struct signer *signer, const secp256k1_musig_keyagg_cache *cache, const unsigned char *msg32, unsigned char *sig64)
const CTxOut & FindNonChangeParentOutput(const CWallet &wallet, const COutPoint &outpoint)
Find non-change parent output.
CreatedTransactionResult FundTransaction(CWallet &wallet, const CMutableTransaction &tx, const std::vector< CRecipient > &recipients, const UniValue &options, CCoinControl &coinControl, bool override_min_fee)
util::Result< SelectionResult > AutomaticCoinSelection(const CWallet &wallet, CoinsResult &available_coins, const CAmount &value_to_select, const CoinSelectionParams &coin_selection_params)
Select a set of coins such that nTargetValue is met; never select unconfirmed coins if they are not o...
FilteredOutputGroups GroupOutputs(const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters, std::vector< OutputGroup > &ret_discarded_groups)
util::Result< CreatedTransactionResult > CreateTransaction(CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign)
Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also cr...
util::Result< PreSelectedInputs > FetchSelectedInputs(const CWallet &wallet, const CCoinControl &coin_control, const CoinSelectionParams &coin_selection_params)
Fetch and validate coin control selected inputs.
util::Result< SelectionResult > AttemptSelection(interfaces::Chain &chain, const CAmount &nTargetValue, OutputGroupTypeMap &groups, const CoinSelectionParams &coin_selection_params, bool allow_mixed_output_types)
Attempt to find a valid input set that preserves privacy by not mixing OutputTypes.
util::Result< SelectionResult > ChooseSelectionResult(interfaces::Chain &chain, const CAmount &nTargetValue, Groups &groups, const CoinSelectionParams &coin_selection_params)
Attempt to find a valid input set that meets the provided eligibility filter and target.
util::Result< SelectionResult > SelectCoins(const CWallet &wallet, CoinsResult &available_coins, const PreSelectedInputs &pre_set_inputs, const CAmount &nTargetValue, const CCoinControl &coin_control, const CoinSelectionParams &coin_selection_params)
Select all coins from coin_control, and if coin_control 'm_allow_other_inputs=true',...
std::map< CTxDestination, std::vector< COutput > > ListCoins(const CWallet &wallet)
Return list of available coins and locked coins grouped by non-change output address.
CoinsResult AvailableCoinsListUnspent(const CWallet &wallet, const CCoinControl *coinControl, CoinFilterParams params)
Wrapper function for AvailableCoins which skips the feerate and CoinFilterParams::only_spendable para...
std::map< CoinEligibilityFilter, OutputGroupTypeMap > FilteredOutputGroups
TxSize CalculateMaximumSignedTxSize(const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, const CCoinControl *coin_control)
Calculate the size of the transaction using CoinControl to determine whether to expect signature grin...
int CalculateMaximumSignedInputSize(const CTxOut &txout, const COutPoint outpoint, const SigningProvider *provider, bool can_grind_r, const CCoinControl *coin_control)
CoinsResult AvailableCoins(const CWallet &wallet, const CCoinControl *coinControl, std::optional< CFeeRate > feerate, const CoinFilterParams ¶ms)
Populate the CoinsResult struct with vectors of available COutputs, organized by OutputType.
std::shared_ptr< const CTransaction > CTransactionRef
A mutable version of CTransaction.
A UTXO under consideration for use in funding a new transaction.
CTxOut txout
The output itself.
CAmount GetEffectiveValue() const
Parameters for filtering which OutputGroups we may use in coin selection.
bool include_immature_coinbase
COutputs available for spending, stored by OutputType.
std::optional< CAmount > GetEffectiveTotalAmount()
size_t TypesCount() const
Return how many different output types this struct stores.
std::map< OutputType, std::vector< COutput > > coins
CreatedTransactionResult(CTransactionRef _tx, CAmount _fee, std::optional< unsigned int > _change_pos, const FeeCalculation &_fee_calc)
std::optional< unsigned int > change_pos
bool allow_mixed_output_types
CoinEligibilityFilter filter
#define EXCLUSIVE_LOCKS_REQUIRED(...)