From 52de36df8ea3bd32cf598dab8391032d2a9b5fda Mon Sep 17 00:00:00 2001 From: Ava Chow Date: Mon, 16 Dec 2024 15:07:19 -0500 Subject: [PATCH] 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. --- test/functional/wallet_migration.py | 30 +++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/test/functional/wallet_migration.py b/test/functional/wallet_migration.py index 025fe07d4a9b94..9860a8fa3c8777 100755 --- a/test/functional/wallet_migration.py +++ b/test/functional/wallet_migration.py @@ -1312,6 +1312,35 @@ def test_taproot(self): 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") + + privkey, 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] @@ -1343,6 +1372,7 @@ def run_test(self): self.test_disallowed_p2wsh() self.test_miniscript() self.test_taproot() + self.test_solvable_no_privs() if __name__ == '__main__': WalletMigrationTest(__file__).main()