diff options
author | Andrew Chow <achow101-github@achow101.com> | 2021-09-16 18:05:44 -0400 |
---|---|---|
committer | Andrew Chow <achow101-github@achow101.com> | 2021-09-17 13:32:06 -0400 |
commit | 9c1052a5218e191fd23c0d9fc06f2fca34b03411 (patch) | |
tree | 25711a12887709bacbbe58fa4c291da0ae57fe81 /src/wallet/wallettool.cpp | |
parent | f19ad404631010a5e2dac2c7cbecd057b005fe2a (diff) |
wallet: Default new wallets to descriptor wallets
Diffstat (limited to 'src/wallet/wallettool.cpp')
-rw-r--r-- | src/wallet/wallettool.cpp | 18 |
1 files changed, 17 insertions, 1 deletions
diff --git a/src/wallet/wallettool.cpp b/src/wallet/wallettool.cpp index 50b6c9d29f..4000c08ea9 100644 --- a/src/wallet/wallettool.cpp +++ b/src/wallet/wallettool.cpp @@ -116,6 +116,10 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command) tfm::format(std::cerr, "The -descriptors option can only be used with the 'create' command.\n"); return false; } + if (args.IsArgSet("-legacy") && command != "create") { + tfm::format(std::cerr, "The -legacy option can only be used with the 'create' command.\n"); + return false; + } if (command == "create" && !args.IsArgSet("-wallet")) { tfm::format(std::cerr, "Wallet name must be provided when creating a new wallet.\n"); return false; @@ -126,7 +130,19 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command) if (command == "create") { DatabaseOptions options; options.require_create = true; - if (args.GetBoolArg("-descriptors", false)) { + // If -legacy is set, use it. Otherwise default to false. + bool make_legacy = args.GetBoolArg("-legacy", false); + // If neither -legacy nor -descriptors is set, default to true. If -descriptors is set, use its value. + bool make_descriptors = (!args.IsArgSet("-descriptors") && !args.IsArgSet("-legacy")) || (args.IsArgSet("-descriptors") && args.GetBoolArg("-descriptors", true)); + if (make_legacy && make_descriptors) { + tfm::format(std::cerr, "Only one of -legacy or -descriptors can be set to true, not both\n"); + return false; + } + if (!make_legacy && !make_descriptors) { + tfm::format(std::cerr, "One of -legacy or -descriptors must be set to true (or omitted)\n"); + return false; + } + if (make_descriptors) { options.create_flags |= WALLET_FLAG_DESCRIPTORS; options.require_format = DatabaseFormat::SQLITE; } |