Reworked fixed change address handling to parse addresses on init and store in a vector
within the wallet code.
This commit is contained in:
parent
fa3a670560
commit
0f1f94b08e
21
src/init.cpp
21
src/init.cpp
|
@ -2,6 +2,7 @@
|
||||||
// Copyright (c) 2009-2014 The Bitcoin developers
|
// Copyright (c) 2009-2014 The Bitcoin developers
|
||||||
// Copyright (c) 2011-2013 The Litecoin developers
|
// Copyright (c) 2011-2013 The Litecoin developers
|
||||||
// Copyright (c) 2014 The Inutoshi developers
|
// Copyright (c) 2014 The Inutoshi developers
|
||||||
|
// Copyright (c) 2014 The Dogecoin developers
|
||||||
// Distributed under the MIT/X11 software license, see the accompanying
|
// Distributed under the MIT/X11 software license, see the accompanying
|
||||||
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
|
||||||
|
|
||||||
|
@ -12,7 +13,9 @@
|
||||||
#include "init.h"
|
#include "init.h"
|
||||||
|
|
||||||
#include "addrman.h"
|
#include "addrman.h"
|
||||||
|
#include "base58.h"
|
||||||
#include "checkpoints.h"
|
#include "checkpoints.h"
|
||||||
|
#include "key.h"
|
||||||
#include "main.h"
|
#include "main.h"
|
||||||
#include "miner.h"
|
#include "miner.h"
|
||||||
#include "net.h"
|
#include "net.h"
|
||||||
|
@ -207,7 +210,6 @@ std::string HelpMessage(HelpMessageMode hmm)
|
||||||
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";
|
strUsage += " -maxconnections=<n> " + _("Maintain at most <n> connections to peers (default: 125)") + "\n";
|
||||||
strUsage += " -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n";
|
strUsage += " -addnode=<ip> " + _("Add a node to connect to and attempt to keep the connection open") + "\n";
|
||||||
strUsage += " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n";
|
strUsage += " -connect=<ip> " + _("Connect only to the specified node(s)") + "\n";
|
||||||
strUsage += " -change=<address> " + _("Send change only to the specified address(es)") + "\n" +
|
|
||||||
strUsage += " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n";
|
strUsage += " -seednode=<ip> " + _("Connect to a node to retrieve peer addresses, and disconnect") + "\n";
|
||||||
strUsage += " -externalip=<ip> " + _("Specify your own public address") + "\n";
|
strUsage += " -externalip=<ip> " + _("Specify your own public address") + "\n";
|
||||||
strUsage += " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n";
|
strUsage += " -onlynet=<net> " + _("Only connect to nodes in network <net> (IPv4, IPv6 or Tor)") + "\n";
|
||||||
|
@ -220,7 +222,7 @@ std::string HelpMessage(HelpMessageMode hmm)
|
||||||
strUsage += " -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n";
|
strUsage += " -bantime=<n> " + _("Number of seconds to keep misbehaving peers from reconnecting (default: 86400)") + "\n";
|
||||||
strUsage += " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n";
|
strUsage += " -maxreceivebuffer=<n> " + _("Maximum per-connection receive buffer, <n>*1000 bytes (default: 5000)") + "\n";
|
||||||
strUsage += " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n";
|
strUsage += " -maxsendbuffer=<n> " + _("Maximum per-connection send buffer, <n>*1000 bytes (default: 1000)") + "\n";
|
||||||
strUsage += " -bloomfilters " + _("Allow peers to set bloom filters (default: 1)") + "\n" +
|
strUsage += " -bloomfilters " + _("Allow peers to set bloom filters (default: 1)") + "\n" +
|
||||||
#ifdef USE_UPNP
|
#ifdef USE_UPNP
|
||||||
#if USE_UPNP
|
#if USE_UPNP
|
||||||
strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n";
|
strUsage += " -upnp " + _("Use UPnP to map the listening port (default: 1 when listening)") + "\n";
|
||||||
|
@ -278,6 +280,7 @@ std::string HelpMessage(HelpMessageMode hmm)
|
||||||
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
|
strUsage += " -upgradewallet " + _("Upgrade wallet to latest format") + "\n";
|
||||||
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + "\n";
|
strUsage += " -wallet=<file> " + _("Specify wallet file (within data directory)") + "\n";
|
||||||
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
|
strUsage += " -walletnotify=<cmd> " + _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)") + "\n";
|
||||||
|
strUsage += " -change=<address> " + _("Send change only to the specified address(es)") + "\n" +
|
||||||
strUsage += " -spendzeroconfchange " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n";
|
strUsage += " -spendzeroconfchange " + _("Spend unconfirmed change when sending transactions (default: 1)") + "\n";
|
||||||
#endif
|
#endif
|
||||||
strUsage += "\n" + _("Block creation options:") + "\n";
|
strUsage += "\n" + _("Block creation options:") + "\n";
|
||||||
|
@ -559,6 +562,20 @@ bool AppInit2(boost::thread_group& threadGroup)
|
||||||
if (nTransactionFee > 25 * COIN)
|
if (nTransactionFee > 25 * COIN)
|
||||||
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
|
InitWarning(_("Warning: -paytxfee is set very high! This is the transaction fee you will pay if you send a transaction."));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (mapArgs.count("-change"))
|
||||||
|
{
|
||||||
|
BOOST_FOREACH(std::string strChange, mapMultiArgs["-change"]) {
|
||||||
|
CBitcoinAddress address(strChange);
|
||||||
|
CKeyID keyID;
|
||||||
|
|
||||||
|
if (!address.GetKeyID(keyID)) {
|
||||||
|
return InitError(strprintf(_("Bad -change address: '%s'"), strChange));
|
||||||
|
}
|
||||||
|
AddFixedChangeAddress(keyID);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
bSpendZeroConfChange = GetArg("-spendzeroconfchange", true);
|
bSpendZeroConfChange = GetArg("-spendzeroconfchange", true);
|
||||||
|
|
||||||
strWalletFile = GetArg("-wallet", "wallet.dat");
|
strWalletFile = GetArg("-wallet", "wallet.dat");
|
||||||
|
|
|
@ -18,6 +18,7 @@ using namespace std;
|
||||||
// Settings
|
// Settings
|
||||||
int64_t nTransactionFee = 0;
|
int64_t nTransactionFee = 0;
|
||||||
bool bSpendZeroConfChange = true;
|
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))
|
if (coinControl && !boost::get<CNoDestination>(&coinControl->destChange))
|
||||||
scriptChange.SetDestination(coinControl->destChange);
|
scriptChange.SetDestination(coinControl->destChange);
|
||||||
|
|
||||||
// send change to one of the specified change addresses
|
// send change to one of the specified change addresses, if specified at init
|
||||||
else if (mapArgs.count("-change") && mapMultiArgs["-change"].size() > 0)
|
else if (vChangeAddresses.size())
|
||||||
{
|
{
|
||||||
CBitcoinAddress address(mapMultiArgs["-change"][GetRandInt(mapMultiArgs["-change"].size())]);
|
CKeyID keyID = vChangeAddresses[GetRandInt(vChangeAddresses.size())];
|
||||||
|
|
||||||
CKeyID keyID;
|
|
||||||
if (!address.GetKeyID(keyID)) {
|
|
||||||
strFailReason = _("Bad change address");
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
scriptChange.SetDestination(keyID);
|
scriptChange.SetDestination(keyID);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2197,3 +2191,11 @@ bool CWallet::GetDestData(const CTxDestination &dest, const std::string &key, st
|
||||||
}
|
}
|
||||||
return false;
|
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);
|
||||||
|
}
|
|
@ -53,6 +53,9 @@ static void WriteOrderPos(const int64_t& nOrderPos, mapValue_t& mapValue)
|
||||||
mapValue["n"] = i64tostr(nOrderPos);
|
mapValue["n"] = i64tostr(nOrderPos);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Add an address to the list of fixed change addresses to use.
|
||||||
|
void AddFixedChangeAddress(const CKeyID &changeAddress);
|
||||||
|
|
||||||
/** (client) version numbers for particular wallet features */
|
/** (client) version numbers for particular wallet features */
|
||||||
enum WalletFeature
|
enum WalletFeature
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue