Skip to content

Commit 19e5b9d

Browse files
committed
Merge pull request #3651
1bbca24 Add option to avoid spending unconfirmed change (Wladimir J. van der Laan)
2 parents 2bc52f1 + 1bbca24 commit 19e5b9d

File tree

3 files changed

+5
-1
lines changed

3 files changed

+5
-1
lines changed

src/init.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ std::string HelpMessage(HelpMessageMode hmm)
274274
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
275275
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + "\n";
276276
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
277+
strUsage += " -spendzeroconfchange " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n";
277278
#endif
278279
strUsage += "\n" + _("Block creation options:") + "\n";
279280
strUsage += " -blockminsize=<n> " + _("Set minimum block size in bytes (default: 0)") + "\n";
@@ -539,6 +540,7 @@ bool AppInit2(boost::thread_group& threadGroup)
539540
if (nTransactionFee > 0.25 * COIN)
540541
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
541542
}
543+
bSpendZeroConfChange = GetArg("-spendzeroconfchange", true);
542544

543545
strWalletFile = GetArg("-wallet", "wallet.dat");
544546
#endif

src/wallet.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ using namespace std;
1818

1919
// Settings
2020
int64_t nTransactionFee = 0;
21+
bool bSpendZeroConfChange = true;
2122

2223
//////////////////////////////////////////////////////////////////////////////
2324
//
@@ -1192,7 +1193,7 @@ bool CWallet::SelectCoins(int64_t nTargetValue, set<pair<const CWalletTx*,unsign
11921193

11931194
return (SelectCoinsMinConf(nTargetValue, 1, 6, vCoins, setCoinsRet, nValueRet) ||
11941195
SelectCoinsMinConf(nTargetValue, 1, 1, vCoins, setCoinsRet, nValueRet) ||
1195-
SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet));
1196+
(bSpendZeroConfChange && SelectCoinsMinConf(nTargetValue, 0, 1, vCoins, setCoinsRet, nValueRet)));
11961197
}
11971198

11981199

src/wallet.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525

2626
// Settings
2727
extern int64_t nTransactionFee;
28+
extern bool bSpendZeroConfChange;
2829

2930
class CAccountingEntry;
3031
class CCoinControl;

0 commit comments

Comments
 (0)