diff options
author | Ava Chow <github@achow101.com> | 2024-12-16 15:07:19 -0500 |
---|---|---|
committer | Ava Chow <github@achow101.com> | 2025-02-10 10:10:52 -0800 |
commit | af76664b12d8611b606a7e755a103a20542ee539 (patch) | |
tree | df08d66ebd3790be32368b488d37282e1b3391e9 | |
parent | 17f01b0795e1dfa264fb42de65339bd18abb7f97 (diff) |
test: Test migration of a solvable script with no privkeys
The legacy wallet will be able to solve output scripts where the
redeemScript or witnessScript is known, but does not know any of the
private keys involved in that script. These should be migrated to the
solvables wallet.
-rwxr-xr-x | test/functional/wallet_migration.py | 30 |
1 files changed, 30 insertions, 0 deletions
diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index 09a9aba24f..60daba79b7 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -1314,6 +1314,35 @@ class WalletMigrationTest(BitcoinTestFramework): assert_equal(watchonly.getaddressinfo(tr_addr)["ismine"], True) assert_equal(watchonly.getaddressinfo(tr_script_addr)["ismine"], True) + def test_solvable_no_privs(self): + self.log.info("Test migrating a multisig that we do not have any private keys for") + wallet = self.create_legacy_wallet("multisig_noprivs") + + _, pubkey = generate_keypair(compressed=True, wif=True) + + add_ms_res = wallet.addmultisigaddress(nrequired=1, keys=[pubkey.hex()]) + addr = add_ms_res["address"] + + # The multisig address should be ISMINE_NO but we should have the script info + addr_info = wallet.getaddressinfo(addr) + assert_equal(addr_info["ismine"], False) + assert "hex" in addr_info + + migrate_res, wallet = self.migrate_and_get_rpc("multisig_noprivs") + assert_equal(migrate_res["solvables_name"], "multisig_noprivs_solvables") + solvables = self.master_node.get_wallet_rpc(migrate_res["solvables_name"]) + + # The multisig should not be in the spendable wallet + addr_info = wallet.getaddressinfo(addr) + assert_equal(addr_info["ismine"], False) + assert "hex" not in addr_info + + # The multisig address should be in the solvables wallet + addr_info = solvables.getaddressinfo(addr) + assert_equal(addr_info["ismine"], True) + assert_equal(addr_info["solvable"], True) + assert "hex" in addr_info + def run_test(self): self.master_node = self.nodes[0] self.old_node = self.nodes[1] @@ -1345,6 +1374,7 @@ class WalletMigrationTest(BitcoinTestFramework): self.test_disallowed_p2wsh() self.test_miniscript() self.test_taproot() + self.test_solvable_no_privs() if __name__ == '__main__': WalletMigrationTest(__file__).main() |