diff options
| author | Ross Nicoll <[email protected]> | 2014-04-06 11:37:20 +0100 |
|---|---|---|
| committer | Ross Nicoll <[email protected]> | 2014-04-06 11:37:20 +0100 |
| commit | 0f1f94b08ee95d5e005e5dce0226e33ccad258fd (patch) | |
| tree | 3ff286e9eb29a7ad220e05c365cf6bc8fa972066 /src/wallet.cpp | |
| parent | Document the -change option. (diff) | |
| download | discoin-0f1f94b08ee95d5e005e5dce0226e33ccad258fd.tar.xz discoin-0f1f94b08ee95d5e005e5dce0226e33ccad258fd.zip | |
Reworked fixed change address handling to parse addresses on init and store in a vector
within the wallet code.
Diffstat (limited to 'src/wallet.cpp')
| -rw-r--r-- | src/wallet.cpp | 22 |
1 files changed, 12 insertions, 10 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp index bd9d901cc..87b5d457e 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -18,6 +18,7 @@ using namespace std; // Settings int64_t nTransactionFee = 0; bool bSpendZeroConfChange = true; +static std::vector<CKeyID> vChangeAddresses; ////////////////////////////////////////////////////////////////////////////// // @@ -1398,17 +1399,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend, if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange)) scriptChange.SetDestination(coinControl->destChange); - // send change to one of the specified change addresses - else if (mapArgs.count("-change") && mapMultiArgs["-change"].size() > 0) + // send change to one of the specified change addresses, if specified at init + else if (vChangeAddresses.size()) { - CBitcoinAddress address(mapMultiArgs["-change"][GetRandInt(mapMultiArgs["-change"].size())]); - - CKeyID keyID; - if (!address.GetKeyID(keyID)) { - strFailReason = _("Bad change address"); - return false; - } - + CKeyID keyID = vChangeAddresses[GetRandInt(vChangeAddresses.size())]; scriptChange.SetDestination(keyID); } @@ -2197,3 +2191,11 @@ bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, st } return false; } + +// Add an address to the list of fixed change addresses to use. Fixed +// addresses can be used to reduce the pace at which wallets expand +// due to number of change addresses +void AddFixedChangeAddress(const CKeyID &changeAddress) +{ + vChangeAddresses.push_back(changeAddress); +}
\ No newline at end of file |