Repository navigation
backport: bitcoin#27800, bitcoin#28125, bitcoin#28232, bitcoin#27695 #7916
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. Weβll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
2d7b155
a579bef
3e2077c
8cfc3c4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,7 +7,7 @@ | |
| import os | ||
| import random | ||
| import shutil | ||
| from test_framework.address import key_to_p2pkh | ||
| from test_framework.address import key_to_p2pkh, script_to_p2sh | ||
| from test_framework.descriptors import descsum_create | ||
| from test_framework.key import ECPubKey | ||
| from test_framework.test_framework import BitcoinTestFramework | ||
|
|
@@ -620,6 +620,21 @@ def send_to_script(script, amount): | |
| wallet.rpc.importaddress(address=script_pkh.hex(), label="raw_spk", rescan=True, p2sh=True) | ||
| assert_equal(wallet.getbalances()['watchonly']['trusted'], 2) | ||
|
|
||
| # Import sh(pkh()) script, by using importaddress(), with the p2sh flag enabled. | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I confirm failure on this test; it worths to backport to 24.0
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No change needed on this branch: line 623 is part of the bitcoin#28125 test this branch adds, and the comment confirms the bug it fixes. Backporting it to the 24.0 release branch is a separate backport outside this PR. π€ backportsys, on behalf of the Dash backport pipeline. |
||
| # This will wrap the script under another sh level, which is invalid!, and store it inside the wallet. | ||
| # The migration process must skip the invalid scripts and the addressbook records linked to them. | ||
| # They are not being watched by the current wallet, nor should be watched by the migrated one. | ||
| label_sh_pkh = "raw_sh_pkh" | ||
| script_pkh = key_to_p2pkh_script(df_wallet.getaddressinfo(df_wallet.getnewaddress())["pubkey"]) | ||
| script_sh_pkh = script_to_p2sh_script(script_pkh) | ||
| addy_script_sh_pkh = script_to_p2sh(script_pkh) # valid script address | ||
| addy_script_double_sh_pkh = script_to_p2sh(script_sh_pkh) # invalid script address | ||
|
|
||
| # Note: 'importaddress()' will add two scripts, a valid one sh(pkh()) and an invalid one 'sh(sh(pkh()))'. | ||
| # Both of them will be stored with the same addressbook label. And only the latter one should | ||
| # be discarded during migration. The first one must be migrated. | ||
| wallet.rpc.importaddress(address=script_sh_pkh.hex(), label=label_sh_pkh, rescan=False, p2sh=True) | ||
|
|
||
| # Migrate wallet and re-check balance | ||
| info_migration = self.migrate_wallet(wallet) | ||
| wallet_wo = self.nodes[0].get_wallet_rpc(info_migration["watchonly_name"]) | ||
|
|
@@ -629,6 +644,20 @@ def send_to_script(script, amount): | |
| # The watch-only scripts are no longer part of the main wallet | ||
| assert_equal(wallet.getbalances()['mine']['trusted'], 0) | ||
|
|
||
| # The invalid sh(sh(pk())) script label must not be part of the main wallet anymore | ||
| assert label_sh_pkh not in wallet.listlabels() | ||
| # But, the standard sh(pkh()) script should be part of the watch-only wallet. | ||
| addrs_by_label = wallet_wo.getaddressesbylabel(label_sh_pkh) | ||
| assert addy_script_sh_pkh in addrs_by_label | ||
| assert addy_script_double_sh_pkh not in addrs_by_label | ||
|
|
||
| # Also, the watch-only wallet should have the descriptor for the standard sh(pkh()) | ||
| desc = descsum_create(f"addr({addy_script_sh_pkh})") | ||
| assert next(it['desc'] for it in wallet_wo.listdescriptors()['descriptors'] if it['desc'] == desc) | ||
| # And doesn't have a descriptor for the invalid one | ||
| desc_invalid = descsum_create(f"addr({addy_script_double_sh_pkh})") | ||
| assert_equal(next((it['desc'] for it in wallet_wo.listdescriptors()['descriptors'] if it['desc'] == desc_invalid), None), None) | ||
|
|
||
| # Just in case, also verify wallet restart | ||
| self.nodes[0].unloadwallet(info_migration["watchonly_name"]) | ||
| self.nodes[0].loadwallet(info_migration["watchonly_name"]) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although this hunk adds the bitcoin#28125 migration fix,
CWallet::Create's existing-wallet branch atsrc/wallet/wallet.cpp:3390-3412still appends no warning for a non-descriptor wallet, and a repo-wide search found no legacy-wallet load warning elsewhere. Consequently users do not receive the behavior attributed to bitcoin#27869 in this commit's title/table; either apply that upstream hunk and its test or remove bitcoin#27869 from the advertised batch so the backport history is accurate.AGENTS.md reference: AGENTS.md:L193-L198
Useful? React with πΒ / π.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This batch doesn't include bitcoin#27869: the commit messages list only bitcoin#27800, bitcoin#28125, bitcoin#28232 and bitcoin#27695, and the bitcoin#28125 commit claims only its own migration fix. The legacy-wallet load warning is upstream behaviour from a PR outside this batch, so there's nothing to backport or drop here.
π€ backportsys, on behalf of the Dash backport pipeline.