Branch data Line data Source code
# 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 : : # 19 : : //! Default for -avoidpartialspends # 20 : : static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false; # 21 : : # 22 : : /** Coin Control Features. */ # 23 : : class CCoinControl # 24 : : { # 25 : : public: # 26 : : //! Custom change destination, if not set an address is generated # 27 : : CTxDestination destChange = CNoDestination(); # 28 : : //! Override the default change type if set, ignored if destChange is set # 29 : : std::optional<OutputType> m_change_type; # 30 : : //! If false, only selected inputs are used # 31 : : bool m_add_inputs = true; # 32 : : //! If false, only safe inputs will be used # 33 : : bool m_include_unsafe_inputs = false; # 34 : : //! If false, allows unselected inputs, but requires all selected inputs be used # 35 : : bool fAllowOtherInputs = false; # 36 : : //! Includes watch only addresses which are solvable # 37 : : bool fAllowWatchOnly = false; # 38 : : //! Override automatic min/max checks on fee, m_feerate must be set if true # 39 : : bool fOverrideFeeRate = false; # 40 : : //! Override the wallet's m_pay_tx_fee if set # 41 : : std::optional<CFeeRate> m_feerate; # 42 : : //! Override the default confirmation target if set # 43 : : std::optional<unsigned int> m_confirm_target; # 44 : : //! Override the wallet's m_signal_rbf if set # 45 : : std::optional<bool> m_signal_bip125_rbf; # 46 : : //! Avoid partial use of funds sent to a given address # 47 : : bool m_avoid_partial_spends = DEFAULT_AVOIDPARTIALSPENDS; # 48 : : //! Forbids inclusion of dirty (previously used) addresses # 49 : : bool m_avoid_address_reuse = false; # 50 : : //! Fee estimation mode to control arguments to estimateSmartFee # 51 : : FeeEstimateMode m_fee_mode = FeeEstimateMode::UNSET; # 52 : : //! Minimum chain depth value for coin availability # 53 : : int m_min_depth = DEFAULT_MIN_DEPTH; # 54 : : //! Maximum chain depth value for coin availability # 55 : : int m_max_depth = DEFAULT_MAX_DEPTH; # 56 : : # 57 : : CCoinControl(); # 58 : : # 59 : : bool HasSelected() const # 60 : 1828282 : { # 61 : 1828282 : return (setSelected.size() > 0); # 62 : 1828282 : } # 63 : : # 64 : : bool IsSelected(const COutPoint& output) const # 65 : 2379 : { # 66 : 2379 : return (setSelected.count(output) > 0); # 67 : 2379 : } # 68 : : # 69 : : void Select(const COutPoint& output) # 70 : 650 : { # 71 : 650 : setSelected.insert(output); # 72 : 650 : } # 73 : : # 74 : : void UnSelect(const COutPoint& output) # 75 : 0 : { # 76 : 0 : setSelected.erase(output); # 77 : 0 : } # 78 : : # 79 : : void UnSelectAll() # 80 : 0 : { # 81 : 0 : setSelected.clear(); # 82 : 0 : } # 83 : : # 84 : : void ListSelected(std::vector<COutPoint>& vOutpoints) const # 85 : 5055 : { # 86 : 5055 : vOutpoints.assign(setSelected.begin(), setSelected.end()); # 87 : 5055 : } # 88 : : # 89 : : private: # 90 : : std::set<COutPoint> setSelected; # 91 : : }; # 92 : : # 93 : : #endif // BITCOIN_WALLET_COINCONTROL_H