From bfc0df86735f26a69192b7bb06ed881ab61e54c1 Mon Sep 17 00:00:00 2001 From: Chris Moore Date: Sat, 1 Feb 2014 08:06:22 -0800 Subject: [PATCH] Allow a fixed list of change addresses. --- src/wallet.cpp | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/wallet.cpp b/src/wallet.cpp index cd3e5af4c..604068ee7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1248,6 +1248,19 @@ bool CWallet::CreateTransaction(const vector >& vecSend, if (coinControl && !boost::get(&coinControl->destChange)) scriptChange.SetDestination(coinControl->destChange); + // send change to one of the specified change addresses + else if (mapArgs.count("-change") && mapMultiArgs["-change"].size() > 0) + { + CBitcoinAddress address(mapMultiArgs["-change"][GetRandInt(mapMultiArgs["-change"].size())]); + + CKeyID keyID; + if (!address.GetKeyID(keyID)) { + strFailReason = _("Bad change address"); + return false; + } + + scriptChange.SetDestination(keyID); + } // no coin control: send change to newly generated address else {