Disable dump feature in wallet-tool (bitcoin-wallet
) for legacy wallets, which are no longer supported.
Currently, in master
, it’s still possible to dump
legacy wallets, but not to createfromdump
on them, which creates an inconsistency. This PR aligns the behavior by rejecting unsupported legacy wallets in the dump command as well.
0--- a/src/wallet/dump.cpp
1+++ b/src/wallet/dump.cpp
2@@ -23,6 +23,13 @@ uint32_t DUMP_VERSION = 1;
3
4 bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& error)
5 {
6+ // Chek first that DB format is supported
7+ std::string format = db.Format();
8+ if (format != "sqlite") {
9+ error = strprintf(_("Error: Wallet specifies an unsupported database format (%s). Only sqlite database dumps are supported"), format);
10+ return false;
11+ }
12+
13 // Get the dumpfile
14 std::string dump_filename = args.GetArg("-dumpfile", "");
15 if (dump_filename.empty()) {
16@@ -60,12 +67,6 @@ bool DumpWallet(const ArgsManager& args, WalletDatabase& db, bilingual_str& erro
17 hasher << std::span{line};
18
19 // Write out the file format
20- std::string format = db.Format();
21- // BDB files that are opened using BerkeleyRODatabase have its format as "bdb_ro"
22- // We want to override that format back to "bdb"
23- if (format == "bdb_ro") {
24- format = "bdb";
25- }
26 line = strprintf("%s,%s\n", "format", format);
27 dump_file.write(line.data(), line.size());
28 hasher << std::span{line};
0--- a/test/functional/tool_wallet.py
1+++ b/test/functional/tool_wallet.py
2@@ -443,12 +443,7 @@ class ToolWalletTest(BitcoinTestFramework):
3 shutil.copytree(legacy_node.wallets_path / wallet_name, master_node.wallets_path / wallet_name)
4
5 wallet_dump = master_node.datadir_path / (wallet_name + ".dump")
6- self.assert_raises_tool_error(
7- "Failed to open database path '{}'. The wallet appears to be a Legacy wallet, " \
8- "please use the wallet migration tool (migratewallet RPC or the GUI option).".format(master_node.wallets_path / wallet_name),
9- f"-wallet={wallet_name}", f"-dumpfile={wallet_dump}",
10- "dump"
11- )
12+ self.assert_raises_tool_error("Error: Wallet specifies an unsupported database format (bdb_ro). Only sqlite database dumps are supported", f"-wallet={wallet_name}", f"-dumpfile={wallet_dump}", "dump")
13 assert not wallet_dump.exists()
14
15 self.log.info("Test that legacy wallets could be dumped in releases prior to v30.0")
Testing
The new functional test test_legacy_dump_is_no_longer_allowed
in test/functional/tool_wallet.py
will fail in master
if the changes on src/wallet/wallettool.cpp
are rolled back.
- Get previous releases with
test/get_previous_releases.py
. - Start a node with an older release:
./releases/v28.2/bin/bitcoind -regtest -datadir=/tmp/btc -deprecatedrpc=create_bdb
- On a separate terminal create a legacy wallet:
./releases/v28.2/bin/bitcoind -regtest -datadir=/tmp/btc createwallet legacy_1 false false "" false false
- Stop the node.
- To verify that the legacy wallet can be dumped either previous wallet-tool version or
master
could be used:- In older wallet-tool:
./releases/v28.2/bin/bitcoin-wallet -regtest -datadir=/tmp/btc -wallet=legacy_1 -dumpfile=legacy1.dump dump
- In
master
branch (assuming /build is the build directory):./build/bin/bitcoin-wallet -regtest -datadir=/tmp/btc -wallet=legacy_1 -dumpfile=legacy1.dump dump
- In older wallet-tool:
- To verify that the legacy wallet cannot be dumped anymore after this change: build this PR branch and run the latest command above (delete the
.dump
file first if you already ran it).