Bitcoin Core 31.0.0
P2P Digital Currency
Loading...
Searching...
No Matches
spend.cpp File Reference
#include <algorithm>
#include <common/args.h>
#include <common/messages.h>
#include <common/system.h>
#include <consensus/amount.h>
#include <consensus/validation.h>
#include <interfaces/chain.h>
#include <node/types.h>
#include <numeric>
#include <policy/policy.h>
#include <policy/truc_policy.h>
#include <primitives/transaction.h>
#include <primitives/transaction_identifier.h>
#include <script/script.h>
#include <script/signingprovider.h>
#include <script/solver.h>
#include <util/check.h>
#include <util/moneystr.h>
#include <util/rbf.h>
#include <util/trace.h>
#include <util/translation.h>
#include <wallet/coincontrol.h>
#include <wallet/fees.h>
#include <wallet/receive.h>
#include <wallet/spend.h>
#include <wallet/transaction.h>
#include <wallet/wallet.h>
#include <cmath>
Include dependency graph for spend.cpp:

Go to the source code of this file.

Namespaces

namespace  wallet

Enumerations

enum class  TransactionError

Functions

 TRACEPOINT_SEMAPHORE (coin_selection, selected_coins)
 TRACEPOINT_SEMAPHORE (coin_selection, normal_create_tx_internal)
 TRACEPOINT_SEMAPHORE (coin_selection, attempting_aps_create_tx)
 TRACEPOINT_SEMAPHORE (coin_selection, aps_create_tx_internal)
static bool wallet::IsSegwit (const Descriptor &desc)
 Whether the descriptor represents, directly or not, a witness program.
static bool wallet::UseMaxSig (const std::optional< CTxIn > &txin, const CCoinControl *coin_control)
 Whether to assume ECDSA signatures' will be high-r.
static std::optional< int64_t > wallet::MaxInputWeight (const Descriptor &desc, const std::optional< CTxIn > &txin, const CCoinControl *coin_control, const bool tx_is_segwit, const bool can_grind_r)
 Get the size of an input (in witness units) once it's signed.
int wallet::CalculateMaximumSignedInputSize (const CTxOut &txout, const COutPoint outpoint, const SigningProvider *provider, bool can_grind_r, const CCoinControl *coin_control)
int wallet::CalculateMaximumSignedInputSize (const CTxOut &txout, const CWallet *pwallet, const CCoinControl *coin_control)
 Get the marginal bytes if spending the specified output from this transaction.
static std::unique_ptr< Descriptorwallet::GetDescriptor (const CWallet *wallet, const CCoinControl *coin_control, const CScript script_pubkey)
 Infer a descriptor for the given output script.
static std::optional< int64_t > wallet::GetSignedTxinWeight (const CWallet *wallet, const CCoinControl *coin_control, const CTxIn &txin, const CTxOut &txo, const bool tx_is_segwit, const bool can_grind_r)
 Infer the maximum size of this input after it will be signed.
TxSize wallet::CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const std::vector< CTxOut > &txouts, const CCoinControl *coin_control=nullptr)
 Calculate the size of the transaction using CoinControl to determine whether to expect signature grinding when calculating the size of the input spend.
TxSize wallet::CalculateMaximumSignedTxSize (const CTransaction &tx, const CWallet *wallet, const CCoinControl *coin_control)
static OutputType wallet::GetOutputType (TxoutType type, bool is_from_p2sh)
util::Result< CoinsResultwallet::FetchSelectedInputs (const CWallet &wallet, const CCoinControl &coin_control, const CoinSelectionParams &coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Fetch and validate coin control selected inputs.
CoinsResult wallet::AvailableCoins (const CWallet &wallet, const CCoinControl *coinControl=nullptr, std::optional< CFeeRate > feerate=std::nullopt, const CoinFilterParams &params={}) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Populate the CoinsResult struct with vectors of available COutputs, organized by OutputType.
const CTxOutwallet::FindNonChangeParentOutput (const CWallet &wallet, const COutPoint &outpoint) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Find non-change parent output.
std::map< CTxDestination, std::vector< COutput > > wallet::ListCoins (const CWallet &wallet) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Return list of available coins and locked coins grouped by non-change output address.
FilteredOutputGroups wallet::GroupOutputs (const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters, std::vector< OutputGroup > &ret_discarded_groups)
FilteredOutputGroups wallet::GroupOutputs (const CWallet &wallet, const CoinsResult &coins, const CoinSelectionParams &coin_sel_params, const std::vector< SelectionFilter > &filters)
 Group coins by the provided filters.
static bool wallet::HasErrorMsg (const util::Result< SelectionResult > &res)
util::Result< SelectionResultwallet::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< SelectionResultwallet::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< SelectionResultwallet::SelectCoins (const CWallet &wallet, CoinsResult &available_coins, const CoinsResult &pre_set_inputs, const CAmount &nTargetValue, const CCoinControl &coin_control, const CoinSelectionParams &coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Select all coins from coin_control, and if coin_control 'm_allow_other_inputs=true', call 'AutomaticCoinSelection' to select a set of coins such that nTargetValue - pre_set_inputs.total_amount is met.
util::Result< SelectionResultwallet::AutomaticCoinSelection (const CWallet &wallet, CoinsResult &available_coins, const CAmount &nTargetValue, const CoinSelectionParams &coin_selection_params) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
 Select a set of coins such that nTargetValue is met; never select unconfirmed coins if they are not ours.
static bool wallet::IsCurrentForAntiFeeSniping (interfaces::Chain &chain, const uint256 &block_hash)
void wallet::DiscourageFeeSniping (CMutableTransaction &tx, FastRandomContext &rng_fast, interfaces::Chain &chain, const uint256 &block_hash, int block_height)
 Set a height-based locktime for new transactions (uses the height of the current chain tip unless we are not synced with the current chain.
uint64_t wallet::GetSerializeSizeForRecipient (const CRecipient &recipient)
bool wallet::IsDust (const CRecipient &recipient, const CFeeRate &dustRelayFee)
static util::Result< CreatedTransactionResultwallet::CreateTransactionInternal (CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign) EXCLUSIVE_LOCKS_REQUIRED(wallet.cs_wallet)
util::Result< CreatedTransactionResultwallet::CreateTransaction (CWallet &wallet, const std::vector< CRecipient > &vecSend, std::optional< unsigned int > change_pos, const CCoinControl &coin_control, bool sign=true)
 Create a new transaction paying the recipients with a set of coins selected by SelectCoins(); Also create the change output, when needed.
util::Result< CreatedTransactionResultwallet::FundTransaction (CWallet &wallet, const CMutableTransaction &tx, const std::vector< CRecipient > &recipients, std::optional< unsigned int > change_pos, bool lockUnspents, CCoinControl)
 Insert additional inputs into the transaction by calling CreateTransaction();.
std::string StringForFeeReason (FeeReason reason)
bilingual_str TransactionErrorString (const TransactionError err)

Variables

static constexpr size_t wallet::OUTPUT_GROUP_MAX_ENTRIES {100}

Enumeration Type Documentation

◆ TransactionError

enum class node::TransactionError
strong

Definition at line 28 of file types.h.

Function Documentation

◆ StringForFeeReason()

std::string common::StringForFeeReason ( FeeReason reason)

Definition at line 27 of file messages.cpp.

◆ TRACEPOINT_SEMAPHORE() [1/4]

TRACEPOINT_SEMAPHORE ( coin_selection ,
aps_create_tx_internal  )

◆ TRACEPOINT_SEMAPHORE() [2/4]

TRACEPOINT_SEMAPHORE ( coin_selection ,
attempting_aps_create_tx  )

◆ TRACEPOINT_SEMAPHORE() [3/4]

TRACEPOINT_SEMAPHORE ( coin_selection ,
normal_create_tx_internal  )

◆ TRACEPOINT_SEMAPHORE() [4/4]

TRACEPOINT_SEMAPHORE ( coin_selection ,
selected_coins  )

◆ TransactionErrorString()