Skip to content

Commit 9c1052a

Browse files
committed
wallet: Default new wallets to descriptor wallets
1 parent f19ad40 commit 9c1052a

File tree

5 files changed

+25
-5
lines changed

5 files changed

+25
-5
lines changed

src/bitcoin-wallet.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ static void SetupWalletToolArgs(ArgsManager& argsman)
3030
argsman.AddArg("-dumpfile=<file name>", "When used with 'dump', writes out the records to this file. When used with 'createfromdump', loads the records into a new wallet.", ArgsManager::ALLOW_STRING, OptionsCategory::OPTIONS);
3131
argsman.AddArg("-debug=<category>", "Output debugging information (default: 0).", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
3232
argsman.AddArg("-descriptors", "Create descriptors wallet. Only for 'create'", ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);
33+
argsman.AddArg("-legacy", "Create legacy wallet. Only for 'create'", ArgsManager::ALLOW_BOOL, OptionsCategory::OPTIONS);
3334
argsman.AddArg("-format=<format>", "The format of the wallet file to create. Either \"bdb\" or \"sqlite\". Only used with 'createfromdump'", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
3435
argsman.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -debug is true, 0 otherwise).", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
3536

src/qt/forms/createwalletdialog.ui

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,9 @@
107107
<property name="text">
108108
<string>Descriptor Wallet</string>
109109
</property>
110+
<property name="checked">
111+
<bool>true</bool>
112+
</property>
110113
</widget>
111114
</item>
112115
<item>

src/wallet/rpcwallet.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2724,7 +2724,7 @@ static RPCHelpMan createwallet()
27242724
{"blank", RPCArg::Type::BOOL, RPCArg::Default{false}, "Create a blank wallet. A blank wallet has no keys or HD seed. One can be set using sethdseed."},
27252725
{"passphrase", RPCArg::Type::STR, RPCArg::Optional::OMITTED_NAMED_ARG, "Encrypt the wallet with this passphrase."},
27262726
{"avoid_reuse", RPCArg::Type::BOOL, RPCArg::Default{false}, "Keep track of coin reuse, and treat dirty and clean coins differently with privacy considerations in mind."},
2727-
{"descriptors", RPCArg::Type::BOOL, RPCArg::Default{false}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
2727+
{"descriptors", RPCArg::Type::BOOL, RPCArg::Default{true}, "Create a native descriptor wallet. The wallet will use descriptors internally to handle address creation"},
27282728
{"load_on_startup", RPCArg::Type::BOOL, RPCArg::Optional::OMITTED_NAMED_ARG, "Save wallet name to persistent settings and load on startup. True to add wallet to startup list, false to remove, null to leave unchanged."},
27292729
{"external_signer", RPCArg::Type::BOOL, RPCArg::Default{false}, "Use an external signer such as a hardware wallet. Requires -signer to be configured. Wallet creation will fail if keys cannot be fetched. Requires disable_private_keys and descriptors set to true."},
27302730
},
@@ -2766,7 +2766,7 @@ static RPCHelpMan createwallet()
27662766
if (!request.params[4].isNull() && request.params[4].get_bool()) {
27672767
flags |= WALLET_FLAG_AVOID_REUSE;
27682768
}
2769-
if (!request.params[5].isNull() && request.params[5].get_bool()) {
2769+
if (request.params[5].isNull() || request.params[5].get_bool()) {
27702770
#ifndef USE_SQLITE
27712771
throw JSONRPCError(RPC_WALLET_ERROR, "Compiled without sqlite support (required for descriptor wallets)");
27722772
#endif

src/wallet/wallettool.cpp

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,10 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
116116
tfm::format(std::cerr, "The -descriptors option can only be used with the 'create' command.\n");
117117
return false;
118118
}
119+
if (args.IsArgSet("-legacy") && command != "create") {
120+
tfm::format(std::cerr, "The -legacy option can only be used with the 'create' command.\n");
121+
return false;
122+
}
119123
if (command == "create" && !args.IsArgSet("-wallet")) {
120124
tfm::format(std::cerr, "Wallet name must be provided when creating a new wallet.\n");
121125
return false;
@@ -126,7 +130,19 @@ bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
126130
if (command == "create") {
127131
DatabaseOptions options;
128132
options.require_create = true;
129-
if (args.GetBoolArg("-descriptors", false)) {
133+
// If -legacy is set, use it. Otherwise default to false.
134+
bool make_legacy = args.GetBoolArg("-legacy", false);
135+
// If neither -legacy nor -descriptors is set, default to true. If -descriptors is set, use its value.
136+
bool make_descriptors = (!args.IsArgSet("-descriptors") && !args.IsArgSet("-legacy")) || (args.IsArgSet("-descriptors") && args.GetBoolArg("-descriptors", true));
137+
if (make_legacy && make_descriptors) {
138+
tfm::format(std::cerr, "Only one of -legacy or -descriptors can be set to true, not both\n");
139+
return false;
140+
}
141+
if (!make_legacy && !make_descriptors) {
142+
tfm::format(std::cerr, "One of -legacy or -descriptors must be set to true (or omitted)\n");
143+
return false;
144+
}
145+
if (make_descriptors) {
130146
options.create_flags |= WALLET_FLAG_DESCRIPTORS;
131147
options.require_format = DatabaseFormat::SQLITE;
132148
}

test/functional/tool_wallet.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,8 @@ def skip_test_if_missing_module(self):
3131
def bitcoin_wallet_process(self, *args):
3232
binary = self.config["environment"]["BUILDDIR"] + '/src/bitcoin-wallet' + self.config["environment"]["EXEEXT"]
3333
default_args = ['-datadir={}'.format(self.nodes[0].datadir), '-chain=%s' % self.chain]
34-
if self.options.descriptors and 'create' in args:
35-
default_args.append('-descriptors')
34+
if not self.options.descriptors and 'create' in args:
35+
default_args.append('-legacy')
3636

3737
return subprocess.Popen([binary] + default_args + list(args), stdin=subprocess.PIPE, stdout=subprocess.PIPE, stderr=subprocess.PIPE, universal_newlines=True)
3838

0 commit comments

Comments
 (0)