2019-05-06 14:05:28 -04:00
|
|
|
// Copyright (c) 2011-2019 The Bitcoin Core developers
|
2014-12-13 01:09:33 -03:00
|
|
|
// Distributed under the MIT software license, see the accompanying
|
2013-11-16 13:37:31 -03:00
|
|
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
|
|
|
|
2016-10-21 06:47:10 -03:00
|
|
|
#ifndef BITCOIN_WALLET_COINCONTROL_H
|
|
|
|
#define BITCOIN_WALLET_COINCONTROL_H
|
2013-08-12 11:03:03 -04:00
|
|
|
|
2019-10-30 09:10:02 -03:00
|
|
|
#include <optional.h>
|
2019-11-19 14:39:50 -03:00
|
|
|
#include <outputtype.h>
|
2017-11-09 21:57:53 -03:00
|
|
|
#include <policy/feerate.h>
|
|
|
|
#include <policy/fees.h>
|
|
|
|
#include <primitives/transaction.h>
|
2019-11-19 14:39:50 -03:00
|
|
|
#include <script/standard.h>
|
2013-08-12 11:03:03 -04:00
|
|
|
|
2019-05-09 21:34:38 -04:00
|
|
|
const int DEFAULT_MIN_DEPTH = 0;
|
|
|
|
const int DEFAULT_MAX_DEPTH = 9999999;
|
|
|
|
|
2019-11-19 14:39:50 -03:00
|
|
|
//! Default for -avoidpartialspends
|
|
|
|
static constexpr bool DEFAULT_AVOIDPARTIALSPENDS = false;
|
|
|
|
|
2013-08-12 11:03:03 -04:00
|
|
|
/** Coin Control Features. */
|
|
|
|
class CCoinControl
|
|
|
|
{
|
|
|
|
public:
|
2018-01-15 13:10:13 -03:00
|
|
|
//! Custom change destination, if not set an address is generated
|
2013-08-12 11:03:03 -04:00
|
|
|
CTxDestination destChange;
|
2018-02-10 23:06:35 -03:00
|
|
|
//! Override the default change type if set, ignored if destChange is set
|
2019-10-30 09:10:02 -03:00
|
|
|
Optional<OutputType> m_change_type;
|
2019-07-12 08:30:10 -04:00
|
|
|
//! If false, only selected inputs are used
|
|
|
|
bool m_add_inputs;
|
2015-04-24 22:27:00 -03:00
|
|
|
//! If false, allows unselected inputs, but requires all selected inputs be used
|
|
|
|
bool fAllowOtherInputs;
|
2018-05-01 16:05:55 -03:00
|
|
|
//! Includes watch only addresses which are solvable
|
2015-04-24 01:42:49 -03:00
|
|
|
bool fAllowWatchOnly;
|
2017-06-28 17:23:46 -04:00
|
|
|
//! Override automatic min/max checks on fee, m_feerate must be set if true
|
2016-05-06 06:01:50 -03:00
|
|
|
bool fOverrideFeeRate;
|
2018-04-07 13:12:46 -03:00
|
|
|
//! Override the wallet's m_pay_tx_fee if set
|
2019-10-30 09:10:02 -03:00
|
|
|
Optional<CFeeRate> m_feerate;
|
2017-06-28 17:23:46 -04:00
|
|
|
//! Override the default confirmation target if set
|
2019-10-30 09:10:02 -03:00
|
|
|
Optional<unsigned int> m_confirm_target;
|
2018-04-07 13:12:46 -03:00
|
|
|
//! Override the wallet's m_signal_rbf if set
|
2019-10-30 09:10:02 -03:00
|
|
|
Optional<bool> m_signal_bip125_rbf;
|
2018-07-17 01:26:35 -04:00
|
|
|
//! Avoid partial use of funds sent to a given address
|
|
|
|
bool m_avoid_partial_spends;
|
2018-07-25 03:24:55 -04:00
|
|
|
//! Forbids inclusion of dirty (previously used) addresses
|
|
|
|
bool m_avoid_address_reuse;
|
2017-06-13 11:28:30 -04:00
|
|
|
//! Fee estimation mode to control arguments to estimateSmartFee
|
|
|
|
FeeEstimateMode m_fee_mode;
|
2019-03-06 18:30:00 -03:00
|
|
|
//! Minimum chain depth value for coin availability
|
2019-05-09 21:34:38 -04:00
|
|
|
int m_min_depth = DEFAULT_MIN_DEPTH;
|
|
|
|
//! Maximum chain depth value for coin availability
|
|
|
|
int m_max_depth = DEFAULT_MAX_DEPTH;
|
2013-08-12 11:03:03 -04:00
|
|
|
|
|
|
|
CCoinControl()
|
|
|
|
{
|
|
|
|
SetNull();
|
|
|
|
}
|
|
|
|
|
2018-07-17 01:26:35 -04:00
|
|
|
void SetNull();
|
2013-08-12 11:03:03 -04:00
|
|
|
|
|
|
|
bool HasSelected() const
|
|
|
|
{
|
|
|
|
return (setSelected.size() > 0);
|
|
|
|
}
|
|
|
|
|
2016-02-10 22:07:22 -03:00
|
|
|
bool IsSelected(const COutPoint& output) const
|
2013-08-12 11:03:03 -04:00
|
|
|
{
|
2016-02-10 22:07:22 -03:00
|
|
|
return (setSelected.count(output) > 0);
|
2013-08-12 11:03:03 -04:00
|
|
|
}
|
|
|
|
|
2014-11-08 20:09:06 -03:00
|
|
|
void Select(const COutPoint& output)
|
2013-08-12 11:03:03 -04:00
|
|
|
{
|
|
|
|
setSelected.insert(output);
|
|
|
|
}
|
|
|
|
|
2014-11-08 20:09:06 -03:00
|
|
|
void UnSelect(const COutPoint& output)
|
2013-08-12 11:03:03 -04:00
|
|
|
{
|
|
|
|
setSelected.erase(output);
|
|
|
|
}
|
|
|
|
|
|
|
|
void UnSelectAll()
|
|
|
|
{
|
|
|
|
setSelected.clear();
|
|
|
|
}
|
|
|
|
|
2015-04-24 22:27:00 -03:00
|
|
|
void ListSelected(std::vector<COutPoint>& vOutpoints) const
|
2013-08-12 11:03:03 -04:00
|
|
|
{
|
|
|
|
vOutpoints.assign(setSelected.begin(), setSelected.end());
|
|
|
|
}
|
|
|
|
|
|
|
|
private:
|
|
|
|
std::set<COutPoint> setSelected;
|
|
|
|
};
|
|
|
|
|
2016-10-21 06:47:10 -03:00
|
|
|
#endif // BITCOIN_WALLET_COINCONTROL_H
|