19
19
from test_framework .key import ECPubKey
20
20
from test_framework .test_framework import BitcoinTestFramework
21
21
from test_framework .messages import COIN , CTransaction , CTxOut
22
- from test_framework .script_util import key_to_p2pkh_script , script_to_p2sh_script , script_to_p2wsh_script
22
+ from test_framework .script_util import key_to_p2pkh_script , key_to_p2pk_script , script_to_p2sh_script , script_to_p2wsh_script
23
23
from test_framework .util import (
24
24
assert_equal ,
25
25
assert_raises_rpc_error ,
26
26
sha256sum_file ,
27
27
)
28
28
from test_framework .wallet_util import (
29
29
get_generate_key ,
30
+ generate_keypair ,
30
31
)
31
32
32
33
@@ -1006,6 +1007,17 @@ def check_comments():
1006
1007
1007
1008
wallet .unloadwallet ()
1008
1009
1010
+ def test_migrate_simple_watch_only (self ):
1011
+ self .log .info ("Test migrating a watch-only p2pk script" )
1012
+ wallet = self .create_legacy_wallet ("bare_p2pk" , blank = True )
1013
+ _ , pubkey = generate_keypair ()
1014
+ p2pk_script = key_to_p2pk_script (pubkey )
1015
+ wallet .importaddress (address = p2pk_script .hex ())
1016
+ # Migrate wallet in the latest node
1017
+ res , _ = self .migrate_and_get_rpc ("bare_p2pk" )
1018
+ wo_wallet = self .master_node .get_wallet_rpc (res ['watchonly_name' ])
1019
+ assert_equal (wo_wallet .listdescriptors ()['descriptors' ][0 ]['desc' ], descsum_create (f'pk({ pubkey .hex ()} )' ))
1020
+ wo_wallet .unloadwallet ()
1009
1021
1010
1022
def run_test (self ):
1011
1023
self .master_node = self .nodes [0 ]
@@ -1032,6 +1044,8 @@ def run_test(self):
1032
1044
self .test_avoidreuse ()
1033
1045
self .test_preserve_tx_extra_info ()
1034
1046
self .test_blank ()
1047
+ self .test_migrate_simple_watch_only ()
1048
+
1035
1049
1036
1050
if __name__ == '__main__' :
1037
1051
WalletMigrationTest (__file__ ).main ()
0 commit comments