Skip to content

Commit bb629cb

Browse files
committed
Add -avoidpartialspends and m_avoid_partial_spends
1 parent 65b3eda commit bb629cb

File tree

5 files changed

+30
-13
lines changed

5 files changed

+30
-13
lines changed

src/Makefile.am

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ libbitcoin_wallet_a_CPPFLAGS = $(AM_CPPFLAGS) $(BITCOIN_INCLUDES)
274274
libbitcoin_wallet_a_CXXFLAGS = $(AM_CXXFLAGS) $(PIE_FLAGS)
275275
libbitcoin_wallet_a_SOURCES = \
276276
interfaces/wallet.cpp \
277+
wallet/coincontrol.cpp \
277278
wallet/crypter.cpp \
278279
wallet/db.cpp \
279280
wallet/feebumper.cpp \

src/wallet/coincontrol.cpp

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
// Copyright (c) 2018 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+
#include <wallet/coincontrol.h>
6+
7+
#include <util.h>
8+
9+
void CCoinControl::SetNull()
10+
{
11+
destChange = CNoDestination();
12+
m_change_type.reset();
13+
fAllowOtherInputs = false;
14+
fAllowWatchOnly = false;
15+
m_avoid_partial_spends = gArgs.GetBoolArg("-avoidpartialspends", DEFAULT_AVOIDPARTIALSPENDS);
16+
setSelected.clear();
17+
m_feerate.reset();
18+
fOverrideFeeRate = false;
19+
m_confirm_target.reset();
20+
m_signal_bip125_rbf.reset();
21+
m_fee_mode = FeeEstimateMode::UNSET;
22+
}
23+

src/wallet/coincontrol.h

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,8 @@ class CCoinControl
3232
boost::optional<unsigned int> m_confirm_target;
3333
//! Override the wallet's m_signal_rbf if set
3434
boost::optional<bool> m_signal_bip125_rbf;
35+
//! Avoid partial use of funds sent to a given address
36+
bool m_avoid_partial_spends;
3537
//! Fee estimation mode to control arguments to estimateSmartFee
3638
FeeEstimateMode m_fee_mode;
3739

@@ -40,19 +42,7 @@ class CCoinControl
4042
SetNull();
4143
}
4244

43-
void SetNull()
44-
{
45-
destChange = CNoDestination();
46-
m_change_type.reset();
47-
fAllowOtherInputs = false;
48-
fAllowWatchOnly = false;
49-
setSelected.clear();
50-
m_feerate.reset();
51-
fOverrideFeeRate = false;
52-
m_confirm_target.reset();
53-
m_signal_bip125_rbf.reset();
54-
m_fee_mode = FeeEstimateMode::UNSET;
55-
}
45+
void SetNull();
5646

5747
bool HasSelected() const
5848
{

src/wallet/init.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ const WalletInitInterface& g_wallet_init_interface = WalletInit();
5454
void WalletInit::AddWalletOptions() const
5555
{
5656
gArgs.AddArg("-addresstype", strprintf("What type of addresses to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default: \"%s\")", FormatOutputType(DEFAULT_ADDRESS_TYPE)), false, OptionsCategory::WALLET);
57+
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);
5758
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);
5859
gArgs.AddArg("-disablewallet", "Do not load the wallet and disable wallet RPC calls", false, OptionsCategory::WALLET);
5960
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). "

src/wallet/wallet.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,8 @@ static const CAmount WALLET_INCREMENTAL_RELAY_FEE = 5000;
5555
static const bool DEFAULT_SPEND_ZEROCONF_CHANGE = true;
5656
//! Default for -walletrejectlongchains
5757
static const bool DEFAULT_WALLET_REJECT_LONG_CHAINS = false;
58+
//! Default for -avoidpartialspends
59+
static const bool DEFAULT_AVOIDPARTIALSPENDS = false;
5860
//! -txconfirmtarget default
5961
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 6;
6062
//! -walletrbf default

0 commit comments

Comments
 (0)