Bitcoin Core  22.99.0
P2P Digital Currency
coincontrol.h
Go to the documentation of this file.
1 // Copyright (c) 2011-2019 The Bitcoin Core developers
2 // Distributed under the MIT software license, see the accompanying
3 // file COPYING or http://www.opensource.org/licenses/mit-license.php.
4 
5 #ifndef BITCOIN_WALLET_COINCONTROL_H
6 #define BITCOIN_WALLET_COINCONTROL_H
7 
8 #include <outputtype.h>
9 #include <policy/feerate.h>
10 #include <policy/fees.h>
11 #include <primitives/transaction.h>
12 #include <script/standard.h>
13 
14 #include <optional>
15 
16 const int DEFAULT_MIN_DEPTH = 0;
17 const int DEFAULT_MAX_DEPTH = 9999999;
18 
20 static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false;
21 
24 {
25 public:
29  std::optional<OutputType> m_change_type;
31  bool m_add_inputs = true;
35  bool fAllowOtherInputs = false;
37  bool fAllowWatchOnly = false;
39  bool fOverrideFeeRate = false;
41  std::optional<CFeeRate> m_feerate;
43  std::optional<unsigned int> m_confirm_target;
45  std::optional<bool> m_signal_bip125_rbf;
49  bool m_avoid_address_reuse = false;
56 
57  CCoinControl();
58 
59  bool HasSelected() const
60  {
61  return (setSelected.size() > 0);
62  }
63 
64  bool IsSelected(const COutPoint& output) const
65  {
66  return (setSelected.count(output) > 0);
67  }
68 
69  void Select(const COutPoint& output)
70  {
71  setSelected.insert(output);
72  }
73 
74  void UnSelect(const COutPoint& output)
75  {
76  setSelected.erase(output);
77  }
78 
79  void UnSelectAll()
80  {
81  setSelected.clear();
82  }
83 
84  void ListSelected(std::vector<COutPoint>& vOutpoints) const
85  {
86  vOutpoints.assign(setSelected.begin(), setSelected.end());
87  }
88 
89 private:
90  std::set<COutPoint> setSelected;
91 };
92 
93 #endif // BITCOIN_WALLET_COINCONTROL_H
CCoinControl::Select
void Select(const COutPoint &output)
Definition: coincontrol.h:69
CCoinControl::fAllowOtherInputs
bool fAllowOtherInputs
If false, allows unselected inputs, but requires all selected inputs be used.
Definition: coincontrol.h:35
feerate.h
CCoinControl::m_signal_bip125_rbf
std::optional< bool > m_signal_bip125_rbf
Override the wallet's m_signal_rbf if set.
Definition: coincontrol.h:45
CCoinControl::fOverrideFeeRate
bool fOverrideFeeRate
Override automatic min/max checks on fee, m_feerate must be set if true.
Definition: coincontrol.h:39
CCoinControl::CCoinControl
CCoinControl()
Definition: coincontrol.cpp:9
CCoinControl::ListSelected
void ListSelected(std::vector< COutPoint > &vOutpoints) const
Definition: coincontrol.h:84
CCoinControl::m_avoid_partial_spends
bool m_avoid_partial_spends
Avoid partial use of funds sent to a given address.
Definition: coincontrol.h:47
transaction.h
CCoinControl::m_fee_mode
FeeEstimateMode m_fee_mode
Fee estimation mode to control arguments to estimateSmartFee.
Definition: coincontrol.h:51
outputtype.h
CCoinControl
Coin Control Features.
Definition: coincontrol.h:23
CCoinControl::m_include_unsafe_inputs
bool m_include_unsafe_inputs
If false, only safe inputs will be used.
Definition: coincontrol.h:33
CCoinControl::IsSelected
bool IsSelected(const COutPoint &output) const
Definition: coincontrol.h:64
CCoinControl::m_feerate
std::optional< CFeeRate > m_feerate
Override the wallet's m_pay_tx_fee if set.
Definition: coincontrol.h:41
CCoinControl::HasSelected
bool HasSelected() const
Definition: coincontrol.h:59
CCoinControl::m_confirm_target
std::optional< unsigned int > m_confirm_target
Override the default confirmation target if set.
Definition: coincontrol.h:43
CCoinControl::m_change_type
std::optional< OutputType > m_change_type
Override the default change type if set, ignored if destChange is set.
Definition: coincontrol.h:29
CCoinControl::fAllowWatchOnly
bool fAllowWatchOnly
Includes watch only addresses which are solvable.
Definition: coincontrol.h:37
CTxDestination
std::variant< CNoDestination, PKHash, ScriptHash, WitnessV0ScriptHash, WitnessV0KeyHash, WitnessV1Taproot, WitnessUnknown > CTxDestination
A txout script template with a specific destination.
Definition: standard.h:157
CCoinControl::m_avoid_address_reuse
bool m_avoid_address_reuse
Forbids inclusion of dirty (previously used) addresses.
Definition: coincontrol.h:49
FeeEstimateMode
FeeEstimateMode
Definition: feerate.h:18
CCoinControl::UnSelectAll
void UnSelectAll()
Definition: coincontrol.h:79
standard.h
CCoinControl::setSelected
std::set< COutPoint > setSelected
Definition: coincontrol.h:90
FeeEstimateMode::UNSET
@ UNSET
Use default settings based on other criteria.
CCoinControl::m_min_depth
int m_min_depth
Minimum chain depth value for coin availability.
Definition: coincontrol.h:53
CNoDestination
Definition: standard.h:73
CCoinControl::m_max_depth
int m_max_depth
Maximum chain depth value for coin availability.
Definition: coincontrol.h:55
DEFAULT_MAX_DEPTH
const int DEFAULT_MAX_DEPTH
Definition: coincontrol.h:17
DEFAULT_MIN_DEPTH
const int DEFAULT_MIN_DEPTH
Definition: coincontrol.h:16
fees.h
COutPoint
An outpoint - a combination of a transaction hash and an index n into its vout.
Definition: transaction.h:26
CCoinControl::UnSelect
void UnSelect(const COutPoint &output)
Definition: coincontrol.h:74
DEFAULT_AVOIDPARTIALSPENDS
static constexpr bool DEFAULT_AVOIDPARTIALSPENDS
Default for -avoidpartialspends.
Definition: coincontrol.h:20
CCoinControl::m_add_inputs
bool m_add_inputs
If false, only selected inputs are used.
Definition: coincontrol.h:31
CCoinControl::destChange
CTxDestination destChange
Custom change destination, if not set an address is generated.
Definition: coincontrol.h:27