Skip to content

Commit 7a41c93

Browse files
committed
wallet: Remove -format and bdb from wallet tool's createfromdump
1 parent c847dee commit 7a41c93

File tree

4 files changed

+8
-35
lines changed

4 files changed

+8
-35
lines changed

src/bitcoin-wallet.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@ static void SetupWalletToolArgs(ArgsManager& argsman)
4040
argsman.AddArg("-debug=<category>", "Output debugging information (default: 0).", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
4141
argsman.AddArg("-descriptors", "Create descriptors wallet. Only for 'create'", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
4242
argsman.AddArg("-legacy", "Create legacy wallet. Only for 'create'", ArgsManager::ALLOW_ANY, OptionsCategory::OPTIONS);
43-
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);
4443
argsman.AddArg("-printtoconsole", "Send trace/debug info to console (default: 1 when no -debug is true, 0 otherwise).", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
4544
argsman.AddArg("-withinternalbdb", "Use the internal Berkeley DB parser when dumping a Berkeley DB wallet file (default: false)", ArgsManager::ALLOW_ANY, OptionsCategory::DEBUG_TEST);
4645

src/wallet/dump.cpp

Lines changed: 7 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -175,34 +175,22 @@ bool CreateFromDump(const ArgsManager& args, const std::string& name, const fs::
175175
dump_file.close();
176176
return false;
177177
}
178-
// Get the data file format with format_value as the default
179-
std::string file_format = args.GetArg("-format", format_value);
180-
if (file_format.empty()) {
181-
error = _("No wallet file format provided. To use createfromdump, -format=<format> must be provided.");
178+
// Make sure that the dump was created from a sqlite database only as that is the only
179+
// type of database that we still support.
180+
// Other formats such as BDB should not be loaded into a sqlite database since they also
181+
// use a different type of wallet entirely which is no longer compatible with this software.
182+
if (format_value != "sqlite") {
183+
error = strprintf(_("Error: Dumpfile specifies an unsupported database format (%s). Only sqlite database dumps are supported"), format_value);
182184
return false;
183185
}
184-
DatabaseFormat data_format;
185-
if (file_format == "bdb") {
186-
data_format = DatabaseFormat::BERKELEY;
187-
} else if (file_format == "sqlite") {
188-
data_format = DatabaseFormat::SQLITE;
189-
} else if (file_format == "bdb_swap") {
190-
data_format = DatabaseFormat::BERKELEY_SWAP;
191-
} else {
192-
error = strprintf(_("Unknown wallet file format \"%s\" provided. Please provide one of \"bdb\" or \"sqlite\"."), file_format);
193-
return false;
194-
}
195-
if (file_format != format_value) {
196-
warnings.push_back(strprintf(_("Warning: Dumpfile wallet format \"%s\" does not match command line specified format \"%s\"."), format_value, file_format));
197-
}
198186
std::string format_hasher_line = strprintf("%s,%s\n", format_key, format_value);
199187
hasher << std::span{format_hasher_line};
200188

201189
DatabaseOptions options;
202190
DatabaseStatus status;
203191
ReadDatabaseArgs(args, options);
204192
options.require_create = true;
205-
options.require_format = data_format;
193+
options.require_format = DatabaseFormat::SQLITE;
206194
std::unique_ptr<WalletDatabase> database = MakeDatabase(wallet_path, options, status, error);
207195
if (!database) return false;
208196

src/wallet/wallettool.cpp

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,6 @@ static void WalletShowInfo(CWallet* wallet_instance)
112112

113113
bool ExecuteWalletToolFunc(const ArgsManager& args, const std::string& command)
114114
{
115-
if (args.IsArgSet("-format") && command != "createfromdump") {
116-
tfm::format(std::cerr, "The -format option can only be used with the \"createfromdump\" command.\n");
117-
return false;
118-
}
119115
if (args.IsArgSet("-dumpfile") && command != "dump" && command != "createfromdump") {
120116
tfm::format(std::cerr, "The -dumpfile option can only be used with the \"dump\" and \"createfromdump\" commands.\n");
121117
return false;

test/functional/tool_wallet.py

Lines changed: 1 addition & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -145,21 +145,15 @@ def assert_dump(self, expected, received):
145145
for k, v in e.items():
146146
assert_equal(v, r[k])
147147

148-
def do_tool_createfromdump(self, wallet_name, dumpfile, file_format=None):
148+
def do_tool_createfromdump(self, wallet_name, dumpfile):
149149
dumppath = self.nodes[0].datadir_path / dumpfile
150150
rt_dumppath = self.nodes[0].datadir_path / "rt-{}.dump".format(wallet_name)
151151

152-
dump_data = self.read_dump(dumppath)
153-
154152
args = ["-wallet={}".format(wallet_name),
155153
"-dumpfile={}".format(dumppath)]
156-
if file_format is not None:
157-
args.append("-format={}".format(file_format))
158154
args.append("createfromdump")
159155

160156
load_output = ""
161-
if file_format is not None and file_format != dump_data["format"]:
162-
load_output += "Warning: Dumpfile wallet format \"{}\" does not match command line specified format \"{}\".\n".format(dump_data["format"], file_format)
163157
self.assert_tool_output(load_output, *args)
164158
assert (self.nodes[0].wallets_path / wallet_name).is_dir()
165159

@@ -316,17 +310,13 @@ def test_dump_createfromdump(self):
316310
self.log.info('Checking createfromdump arguments')
317311
self.assert_raises_tool_error('No dump file provided. To use createfromdump, -dumpfile=<filename> must be provided.', '-wallet=todump', 'createfromdump')
318312
non_exist_dump = self.nodes[0].datadir_path / "wallet.nodump"
319-
self.assert_raises_tool_error('Unknown wallet file format "notaformat" provided. Please provide one of "bdb" or "sqlite".', '-wallet=todump', '-format=notaformat', '-dumpfile={}'.format(wallet_dump), 'createfromdump')
320313
self.assert_raises_tool_error('Dump file {} does not exist.'.format(non_exist_dump), '-wallet=todump', '-dumpfile={}'.format(non_exist_dump), 'createfromdump')
321314
wallet_path = self.nodes[0].wallets_path / "todump2"
322315
self.assert_raises_tool_error('Failed to create database path \'{}\'. Database already exists.'.format(wallet_path), '-wallet=todump2', '-dumpfile={}'.format(wallet_dump), 'createfromdump')
323316
self.assert_raises_tool_error("The -descriptors option can only be used with the 'create' command.", '-descriptors', '-wallet=todump2', '-dumpfile={}'.format(wallet_dump), 'createfromdump')
324317

325318
self.log.info('Checking createfromdump')
326319
self.do_tool_createfromdump("load", "wallet.dump")
327-
if self.is_bdb_compiled():
328-
self.do_tool_createfromdump("load-bdb", "wallet.dump", "bdb")
329-
self.do_tool_createfromdump("load-sqlite", "wallet.dump", "sqlite")
330320

331321
self.log.info('Checking createfromdump handling of magic and versions')
332322
bad_ver_wallet_dump = self.nodes[0].datadir_path / "wallet-bad_ver1.dump"

0 commit comments

Comments
 (0)