diff options
author | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-07-17 14:26:35 +0900 |
---|---|---|
committer | Karl-Johan Alm <karljohan-alm@garage.co.jp> | 2018-07-24 15:05:37 +0900 |
commit | bb629cb9dc567cc819724d9f4852652926e60cbf (patch) | |
tree | d73ac0990b2f6def9b8b471158d1a8f3913323bd /src | |
parent | 65b3eda458221644616d0fdd6ba0fe01bdbce893 (diff) |
Add -avoidpartialspends and m_avoid_partial_spends
Diffstat (limited to 'src')
-rw-r--r-- | src/Makefile.am | 1 | ||||
-rw-r--r-- | src/wallet/coincontrol.cpp | 23 | ||||
-rw-r--r-- | src/wallet/coincontrol.h | 16 | ||||
-rw-r--r-- | src/wallet/init.cpp | 1 | ||||
-rw-r--r-- | src/wallet/wallet.h | 2 |
5 files changed, 30 insertions, 13 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index 2603dbae56..60ecf07a59 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -274,6 +274,7 @@ libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES) libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS) libbitcoin_wallet_a_SOURCES = \ interfaces/wallet.cpp \ + wallet/coincontrol.cpp \ wallet/crypter.cpp \ wallet/db.cpp \ wallet/feebumper.cpp \ diff --git a/src/wallet/coincontrol.cpp b/src/wallet/coincontrol.cpp new file mode 100644 index 0000000000..645981faa4 --- /dev/null +++ b/src/wallet/coincontrol.cpp @@ -0,0 +1,23 @@ +// Copyright (c) 2018 The Bitcoin Core developers +// Distributed under the MIT software license, see the accompanying +// file COPYING or http://www.opensource.org/licenses/mit-license.php. + +#include <wallet/coincontrol.h> + +#include <util.h> + +void CCoinControl::SetNull() +{ + destChange = CNoDestination(); + m_change_type.reset(); + fAllowOtherInputs = false; + fAllowWatchOnly = false; + m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS); + setSelected.clear(); + m_feerate.reset(); + fOverrideFeeRate = false; + m_confirm_target.reset(); + m_signal_bip125_rbf.reset(); + m_fee_mode = FeeEstimateMode::UNSET; +} + diff --git a/src/wallet/coincontrol.h b/src/wallet/coincontrol.h index 98b4298507..fbe6c43e24 100644 --- a/src/wallet/coincontrol.h +++ b/src/wallet/coincontrol.h @@ -32,6 +32,8 @@ public: boost::optional<unsigned int> m_confirm_target; //! Override the wallet's m_signal_rbf if set boost::optional<bool> m_signal_bip125_rbf; + //! Avoid partial use of funds sent to a given address + bool m_avoid_partial_spends; //! Fee estimation mode to control arguments to estimateSmartFee FeeEstimateMode m_fee_mode; @@ -40,19 +42,7 @@ public: SetNull(); } - void SetNull() - { - destChange = CNoDestination(); - m_change_type.reset(); - fAllowOtherInputs = false; - fAllowWatchOnly = false; - setSelected.clear(); - m_feerate.reset(); - fOverrideFeeRate = false; - m_confirm_target.reset(); - m_signal_bip125_rbf.reset(); - m_fee_mode = FeeEstimateMode::UNSET; - } + void SetNull(); bool HasSelected() const { diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 076134cdd1..52c7e6c70f 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -54,6 +54,7 @@ const WalletInitInterface& g_wallet_init_interface = WalletInit(); void WalletInit::AddWalletOptions() const { gArgs.AddArg("-addresstype", strprintf("What type of addresses to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default: \"%s\")", FormatOutputType(DEFAULT_ADDRESS_TYPE)), false, OptionsCategory::WALLET); + gArgs.AddArg("-avoidpartialspends", strprintf(_("Group outputs by address, selecting all or none, instead of selecting on a per-output basis. Privacy is improved as an address is only used once (unless someone sends to it after spending from it), but may result in slightly higher fees as suboptimal coin selection may result due to the added limitation (default: %u)"), DEFAULT_AVOIDPARTIALSPENDS), false, OptionsCategory::WALLET); gArgs.AddArg("-changetype", "What type of change to use (\"legacy\", \"p2sh-segwit\", or \"bech32\"). Default is same as -addresstype, except when -addresstype=p2sh-segwit a native segwit output is used when sending to a native segwit address)", false, OptionsCategory::WALLET); gArgs.AddArg("-disablewallet", "Do not load the wallet and disable wallet RPC calls", false, OptionsCategory::WALLET); gArgs.AddArg("-discardfee=<amt>", strprintf("The fee rate (in %s/kB) that indicates your tolerance for discarding change by adding it to the fee (default: %s). " diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 4a38545146..b636924fe2 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -55,6 +55,8 @@ static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000; static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true; //! Default for -walletrejectlongchains static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false; +//! Default for -avoidpartialspends +static const bool DEFAULT_AVOIDPARTIALSPENDS = false; //! -txconfirmtarget default static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6; //! -walletrbf default |