mirror of
https://github.com/bitcoin/bitcoin.git
synced 2025-01-09 11:27:28 -03:00
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.
This commit is contained in:
parent
89a6b9c41a
commit
3474524ee5
1 changed files with 29 additions and 0 deletions
|
@ -1320,6 +1320,34 @@ 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")
|
||||
|
||||
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 "hex" in addr_info
|
||||
|
||||
def run_test(self):
|
||||
self.master_node = self.nodes[0]
|
||||
self.old_node = self.nodes[1]
|
||||
|
@ -1351,6 +1379,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()
|
||||
|
|
Loading…
Reference in a new issue