LCOV - code coverage report
Current view: top level - src/wallet - coincontrol.h (source / functions) Hit Total Coverage
Test: total_coverage.info Lines: 17 23 73.9 %
Date: 2020-09-26 01:30:44 Functions: 10 12 83.3 %

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

Generated by: LCOV version 1.15