Skip to content

Commit af76664

Browse files
committed
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.
1 parent 17f01b0 commit af76664

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

test/functional/wallet_migration.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1314,6 +1314,35 @@ def test_taproot(self):
13141314
assert_equal(watchonly.getaddressinfo(tr_addr)["ismine"], True)
13151315
assert_equal(watchonly.getaddressinfo(tr_script_addr)["ismine"], True)
13161316

1317+
def test_solvable_no_privs(self):
1318+
self.log.info("Test migrating a multisig that we do not have any private keys for")
1319+
wallet = self.create_legacy_wallet("multisig_noprivs")
1320+
1321+
_, pubkey = generate_keypair(compressed=True, wif=True)
1322+
1323+
add_ms_res = wallet.addmultisigaddress(nrequired=1, keys=[pubkey.hex()])
1324+
addr = add_ms_res["address"]
1325+
1326+
# The multisig address should be ISMINE_NO but we should have the script info
1327+
addr_info = wallet.getaddressinfo(addr)
1328+
assert_equal(addr_info["ismine"], False)
1329+
assert "hex" in addr_info
1330+
1331+
migrate_res, wallet = self.migrate_and_get_rpc("multisig_noprivs")
1332+
assert_equal(migrate_res["solvables_name"], "multisig_noprivs_solvables")
1333+
solvables = self.master_node.get_wallet_rpc(migrate_res["solvables_name"])
1334+
1335+
# The multisig should not be in the spendable wallet
1336+
addr_info = wallet.getaddressinfo(addr)
1337+
assert_equal(addr_info["ismine"], False)
1338+
assert "hex" not in addr_info
1339+
1340+
# The multisig address should be in the solvables wallet
1341+
addr_info = solvables.getaddressinfo(addr)
1342+
assert_equal(addr_info["ismine"], True)
1343+
assert_equal(addr_info["solvable"], True)
1344+
assert "hex" in addr_info
1345+
13171346
def run_test(self):
13181347
self.master_node = self.nodes[0]
13191348
self.old_node = self.nodes[1]
@@ -1345,6 +1374,7 @@ def run_test(self):
13451374
self.test_disallowed_p2wsh()
13461375
self.test_miniscript()
13471376
self.test_taproot()
1377+
self.test_solvable_no_privs()
13481378

13491379
if __name__ == '__main__':
13501380
WalletMigrationTest(__file__).main()

0 commit comments

Comments
 (0)