From 596c44633fd03e76cc12f2fd37452e223ba43115 Mon Sep 17 00:00:00 2001 From: Sjors Provoost Date: Tue, 23 Jan 2018 17:56:15 +0100 Subject: [wallet] use P2WPKH change output if any destination is P2WPKH or P2WSH Only if -changetype is not set and -addresstype is not "legacy". --- src/wallet/init.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/wallet/init.cpp') diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp index 0f453f154f..7d61d708a1 100644 --- a/src/wallet/init.cpp +++ b/src/wallet/init.cpp @@ -17,7 +17,7 @@ std::string GetWalletHelpString(bool showDebug) { std::string strUsage = HelpMessageGroup(_("Wallet options:")); strUsage += HelpMessageOpt("-addresstype", strprintf(_("What type of addresses to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default: \"%s\")"), FormatOutputType(OUTPUT_TYPE_DEFAULT))); - strUsage += HelpMessageOpt("-changetype", _("What type of change to use (\"legacy\", \"p2sh-segwit\", or \"bech32\", default is same as -addresstype)")); + strUsage += HelpMessageOpt("-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)")); strUsage += HelpMessageOpt("-disablewallet", _("Do not load the wallet and disable wallet RPC calls")); strUsage += HelpMessageOpt("-keypool=", strprintf(_("Set key pool size to (default: %u)"), DEFAULT_KEYPOOL_SIZE)); strUsage += HelpMessageOpt("-fallbackfee=", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"), @@ -182,8 +182,10 @@ bool WalletParameterInteraction() return InitError(strprintf(_("Unknown address type '%s'"), gArgs.GetArg("-addresstype", ""))); } - g_change_type = ParseOutputType(gArgs.GetArg("-changetype", ""), g_address_type); - if (g_change_type == OUTPUT_TYPE_NONE) { + // If changetype is set in config file or parameter, check that it's valid. + // Default to OUTPUT_TYPE_NONE if not set. + g_change_type = ParseOutputType(gArgs.GetArg("-changetype", ""), OUTPUT_TYPE_NONE); + if (g_change_type == OUTPUT_TYPE_NONE && !gArgs.GetArg("-changetype", "").empty()) { return InitError(strprintf(_("Unknown change type '%s'"), gArgs.GetArg("-changetype", ""))); } -- cgit v1.2.3