Previously the seed was stored with keypath ’m’ so we need to skip this as well when determining inactive seeds.
Fixes #19051
I think this can be tested in feature_backwards_compatibility.py
. I’ll see if I can write a test.
Otherwise we would need to directly modify the wallet.dat file.
feature_backwards_compatibility.py
to do an up/downgrade test with a 0.16 wallet. This test also checks that there is no warning when loading the wallet. It catches this error.
443@@ -444,7 +444,7 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
444 // Not applicable when path is "s" as that indicates a seed
445 bool internal = false;
446 uint32_t index = 0;
447- if (keyMeta.hdKeypath != "s") {
448+ if (keyMeta.hdKeypath != "s" && keyMeta.hdKeypath != "m") {
In commit “Skip hdKeypath of ’m’” (57acd1b27fb6cf46b919a05e3fe50a1c2947321f)
Would be good to update “Not applicable when…” comment above
339@@ -331,6 +340,29 @@ def run_test(self):
340 hdkeypath = v17_info["hdkeypath"]
341 pubkey = v17_info["pubkey"]
342
343+ # Copy the 0.16 wallet to the last Bitcoin Core version and open it:
In commit “tests: feature_backwards_compatibility.py test 0.16 up/downgrade” (7a872702965755ce28f1f17a8d0e0eb93ae4c907)
Implemention seems ideal for this PR, but for future cleanup it could be nice for someone to write some python helper functions and get rid of duplicate code in the 0.16, 0.17, and 0.19 test cases.
Does this mean that older hd wallets opened prior to this fix have been corrupted?
Also, post-fix does this mean that the #17681 functionality (following old hd chains forward) will silently not work for these wallets (since their hd keys just get skipped)?
Does this mean that older hd wallets opened prior to this fix have been corrupted?
Also, post-fix does this mean that the #17681 functionality (following old hd chains forward) will silently not work for these wallets (since their hd keys just get skipped)?
No to both. #17681 functionality works regardless of this fix, regardless of age of the HD wallet. This fix is to merely remove an erroneous warning for those older HD wallets.
This fix does not skip any HD keys at all. It just skips the keymeta record for the HD seed when it is computing the inactive HD chain from those keymetadata records. The record for the HD seed is not used in that process, hence this patch to skip it.
440@@ -441,10 +441,10 @@ ReadKeyValue(CWallet* pwallet, CDataStream& ssKey, CDataStream& ssValue,
441 // Extract some CHDChain info from this metadata if it has any
442 if (keyMeta.nVersion >= CKeyMetadata::VERSION_WITH_HDDATA && !keyMeta.hd_seed_id.IsNull() && keyMeta.hdKeypath.size() > 0) {
443 // Get the path from the key origin or from the path string
444- // Not applicable when path is "s" as that indicates a seed
445+ // Not applicable when path is "s" or "m" as those indicates a seed
321@@ -322,6 +322,15 @@ def run_test(self):
322 info = wallet.getwalletinfo()
323 assert info['keypoolsize'] == 1
324
325+ # Create upgrade wallet in v0.16
326+ self.stop_node(5)
-1
instead. Maybe cherry-pick 99d9f7cf7b7460c976d6ca7508e77b4ee31bf576
344+ shutil.copyfile(
345+ os.path.join(node_v16_wallets_dir, "wallets/u1_v16"),
346+ os.path.join(node_master_wallets_dir, "u1_v16")
347+ )
348+ load_res = node_master.loadwallet("u1_v16")
349+ assert_equal(load_res['warning'], '')
Concept ACK. When I run the new test without 5fb09ed it catches a warning.
For future reference, the change from ~“s” to “m”~ “m” to “s” was introduced in #12924 (cc @jnewbery, @jonasschnelli). At the time this change wasn’t a problem, because the data was serialised, but afaik not used anywhere.
Previously the seed was stored with keypath 'm' so we need to skip this
as well when determining inactive seeds.
The following sections might be updated with supplementary metadata relevant to reviewers and maintainers.
Reviewers, this pull request conflicts with the following ones:
If you consider this pull request important, please also help to review the conflicting pull requests. Ideally, start with the one that should be merged first.