Skip to content

Commit

Permalink
test: Test migration of a solvable script with no privkeys
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
achow101 committed Jan 21, 2025
1 parent b91d43b commit 86c5428
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions test/functional/wallet_migration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down Expand Up @@ -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()

0 comments on commit 86c5428

Please sign in to comment.