@@ -134,6 +134,33 @@ def run_test(self):
134
134
# in the label. This is a no-op.
135
135
change_label (node , labels [2 ].addresses [0 ], labels [2 ], labels [2 ])
136
136
137
+ self .log .info ('Check watchonly labels' )
138
+ node .createwallet (wallet_name = 'watch_only' , disable_private_keys = True , descriptors = False )
139
+ wallet_watch_only = node .get_wallet_rpc ('watch_only' )
140
+ BECH32_VALID = {
141
+ '✔️_VER15_PROG40' : 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqn2cjv3' ,
142
+ '✔️_VER16_PROG03' : 'bcrt1sqqqqqjq8pdp' ,
143
+ '✔️_VER16_PROB02' : 'bcrt1sqqqqqjq8pv' ,
144
+ }
145
+ BECH32_INVALID = {
146
+ '❌_VER15_PROG41' : 'bcrt10qqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqzc7xyq' ,
147
+ '❌_VER16_PROB01' : 'bcrt1sqqpl9r5c' ,
148
+ }
149
+ for l in BECH32_VALID :
150
+ ad = BECH32_VALID [l ]
151
+ wallet_watch_only .importaddress (label = l , rescan = False , address = ad )
152
+ node .generatetoaddress (1 , ad )
153
+ assert_equal (wallet_watch_only .getaddressesbylabel (label = l ), {ad : {'purpose' : 'receive' }})
154
+ assert_equal (wallet_watch_only .getreceivedbylabel (label = l ), 0 )
155
+ for l in BECH32_INVALID :
156
+ ad = BECH32_INVALID [l ]
157
+ assert_raises_rpc_error (
158
+ - 5 ,
159
+ "Invalid Bitcoin address or script" ,
160
+ lambda : wallet_watch_only .importaddress (label = l , rescan = False , address = ad ),
161
+ )
162
+
163
+
137
164
class Label :
138
165
def __init__ (self , name ):
139
166
# Label name
0 commit comments