Skip to content

wallet: pre-HD HDD migratewallet  #29438

@maflcko

Description

@maflcko

Opening a brainstorming issue, if someone wants to test migratewallet on a pre-HD wallet on a slow storage device (HDD).

Steps to reproduce:

  • Create a wallet in a folder. For example: ./releases/bitcoin-0.11.2/bin/bitcoin-qt -datadir=/tmp/rgw -regtest. Then stop bitcoin-qt.
  • Copy the wallet file to a folder residing on the intended storage device and call migratewallet with the latest version of Bitcoin Core.

The second step can be done by a functional test (I modified an existing test). Callable with:

./test/functional/wallet_disable.py --tracerpc --tmpdir=/run/media/pick_the_storage/folder/temp3 --timeout-factor=0
  • --tracerpc will print the time it took
  • --tmpdir is used to select the location
  • --timeout-factor=0 is needed to disable the client RPC timeout

My diff:

diff --git a/test/functional/wallet_disable.py b/test/functional/wallet_disable.py
index 9c73f7dead..7be397c630 100755
--- a/test/functional/wallet_disable.py
+++ b/test/functional/wallet_disable.py
@@ -12,19 +12,31 @@ from test_framework.test_framework import BitcoinTestFramework
 from test_framework.util import assert_raises_rpc_error
 
 class DisableWalletTest (BitcoinTestFramework):
+    def add_options(self, parser):
+        self.add_wallet_options(parser)
+
     def set_test_params(self):
-        self.setup_clean_chain = True
         self.num_nodes = 1
-        self.extra_args = [["-disablewallet"]]
-        self.wallet_names = []
 
     def run_test (self):
-        # Make sure wallet is really disabled
-        assert_raises_rpc_error(-32601, 'Method not found', self.nodes[0].getwalletinfo)
-        x = self.nodes[0].validateaddress('3J98t1WpEZ73CNmQviecrnyiWrnqRhWNLy')
-        assert x['isvalid'] == False
-        x = self.nodes[0].validateaddress('mneYUmWYsuk7kySiURxCi3AGxrAqZxLgPZ')
-        assert x['isvalid'] == True
+        n = self.nodes[0]
+        (n.wallets_path/"old").mkdir(parents=True)
+        import os
+        os.system(f"cp /tmp/rgw/regtest/wallet.dat {n.wallets_path}/old/")
+
+        n.loadwallet("old")
+        w = n.get_wallet_rpc("old")
+        w.encryptwallet("pw")
+        w.walletpassphrase("pw", 999999999)
+        w.importprivkey(privkey=n.get_deterministic_priv_key().key, label='coinbase', rescan=True)
+
+        for i in range(10):
+            _ = w.getnewaddress()
+            w.sendtoaddress(w.getnewaddress(), round(w.getbalance() / 100, 8))
+            if i % 10:
+                self.generate(n, 1)
+        w.getwalletinfo()
+        w.migratewallet("old", "pw")
 
 
 if __name__ == '__main__':

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions