aboutsummaryrefslogtreecommitdiff
path: root/src/wallet/init.cpp
diff options
context:
space:
mode:
authorPieter Wuille <pieter.wuille@gmail.com>2017-11-30 16:49:11 -0800
committerPieter Wuille <pieter.wuille@gmail.com>2018-01-09 15:35:31 -0800
commit940a21932ba769ba5829cba713579db84f96d2f8 (patch)
tree2f1db2f007ef50255baddae3ef712831ad46ab58 /src/wallet/init.cpp
parentf37c64e477d679853a4076f2f7888568bb034e90 (diff)
downloadbitcoin-940a21932ba769ba5829cba713579db84f96d2f8.tar.xz
SegWit wallet support
This introduces two command line flags (-addresstype and -changetype) which control the type of addresses/outputs created by the GUI and RPCs. Certain RPCs allow overriding these (`getnewaddress` and `getrawchangeaddress`). Supported types are "legacy" (P2PKH and P2SH-multisig), "p2sh-segwit" (P2SH-P2WPKH and P2SH-P2WSH-multisig), and "bech32" (P2WPKH and P2WSH-multisig). A few utility functions are added to the wallet to construct different address type and to add the necessary entries to the wallet file to be compatible with earlier versions (see `CWallet::LearnRelatedScripts`, `GetDestinationForKey`, `GetAllDestinationsForKey`, `CWallet::AddAndGetDestinationForScript`).
Diffstat (limited to 'src/wallet/init.cpp')
-rw-r--r--src/wallet/init.cpp12
1 files changed, 12 insertions, 0 deletions
diff --git a/src/wallet/init.cpp b/src/wallet/init.cpp
index 67c46df87d..8da99f2f7e 100644
--- a/src/wallet/init.cpp
+++ b/src/wallet/init.cpp
@@ -16,6 +16,8 @@
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("-disablewallet", _("Do not load the wallet and disable wallet RPC calls"));
strUsage += HelpMessageOpt("-keypool=<n>", strprintf(_("Set key pool size to <n> (default: %u)"), DEFAULT_KEYPOOL_SIZE));
strUsage += HelpMessageOpt("-fallbackfee=<amt>", strprintf(_("A fee rate (in %s/kB) that will be used when fee estimation has insufficient data (default: %s)"),
@@ -175,6 +177,16 @@ bool WalletParameterInteraction()
bSpendZeroConfChange = gArgs.GetBoolArg("-spendzeroconfchange", DEFAULT_SPEND_ZEROCONF_CHANGE);
fWalletRbf = gArgs.GetBoolArg("-walletrbf", DEFAULT_WALLET_RBF);
+ g_address_type = ParseOutputType(gArgs.GetArg("-addresstype", ""));
+ if (g_address_type == OUTPUT_TYPE_NONE) {
+ 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) {
+ return InitError(strprintf(_("Unknown change type '%s'"), gArgs.GetArg("-changetype", "")));
+ }
+
return true;
}