wallettool, test: Remove BDB/ legacy wallets dump feature #33161

pull pablomartin4btc wants to merge 1 commits into bitcoin:master from pablomartin4btc:wallet-tool-remove-bdb-dump changing 2 files +47 −13
  1. pablomartin4btc commented at 2:58 am on August 9, 2025: member

    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
    • 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).
  2. wallettool, test: Remove BDB check and read-only format set
    Removed the unnecessary BDB format check and the read-only set
    from the dump command section, as legacy wallet features are no
    longer supported.
    
    Added a new test verifying that trying to dump a legacy wallet
    will raise an error.
    8c794e499e
  3. DrahtBot commented at 2:58 am on August 9, 2025: contributor

    The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.

    Code Coverage & Benchmarks

    For details see: https://corecheck.dev/bitcoin/bitcoin/pulls/33161.

    Reviews

    See the guideline for information on the review process. A summary of reviews will appear here.

  4. in test/functional/tool_wallet.py:41 in 8c794e499e
    37+        self.init_wallet(node=0)
    38 
    39     def skip_test_if_missing_module(self):
    40         self.skip_if_no_wallet()
    41         self.skip_if_no_wallet_tool()
    42+        self.skip_if_no_previous_releases()
    


    w0xlt commented at 5:49 pm on August 12, 2025:
    This will prevent all tests in this file from running if there are no previous releases. Is that the idea?

    pablomartin4btc commented at 0:18 am on August 13, 2025:

    Exactly, otherwise it would fail in some CIs that, I think, don’t have previous releases disabled/ /releases/ subdir not available.

    As you can see for this PR in CI “ASan + LSan + UBSan + integer, no depends, USDT” and others:

     0...
     1wallet_txn_doublespend.py                              |  Passed  | 11 s
     2wallet_txn_doublespend.py --mineblock                  |  Passed  | 11 s
     3feature_bind_port_discover.py                          |  Skipped | 1 s
     4feature_bind_port_externalip.py                        |  Skipped | 1 s
     5feature_unsupported_utxo_db.py                         |  Skipped | 1 s
     6mempool_compatibility.py                               |  Skipped | 1 s
     7tool_bitcoin_chainstate.py                             |  Skipped | 1 s
     8tool_wallet.py                                         |  Skipped | 0 s
     9wallet_backwards_compatibility.py                      |  Skipped | 1 s
    10wallet_migration.py                                    |  Skipped | 1 s
    11
    12ALL                                                    |  Passed  | 11070 s (accumulated) 
    13Runtime: 1590 s
    14...
    

    But it runs fine in: -previous releases, depends DEBUG -Windows, test cross build


github-metadata-mirror

This is a metadata mirror of the GitHub repository bitcoin/bitcoin. This site is not affiliated with GitHub. Content is generated from a GitHub metadata backup.
generated: 2025-08-13 06:13 UTC

This site is hosted by @0xB10C
More mirrored repositories can be found on mirror.b10c.me