@@ -28,6 +28,44 @@ def set_test_params(self):
2828 def skip_test_if_missing_module (self ):
2929 self .skip_if_no_wallet ()
3030
31+ def invalid_label_name_test (self ):
32+ node = self .nodes [0 ]
33+ address = node .getnewaddress ()
34+ pubkey = node .getaddressinfo (address )['pubkey' ]
35+ rpc_calls = [
36+ [node .getnewaddress ],
37+ [node .setlabel , address ],
38+ [node .getaddressesbylabel ],
39+ [node .importpubkey , pubkey ],
40+ [node .addmultisigaddress , 1 , [pubkey ]],
41+ [node .getreceivedbylabel ],
42+ [node .listsinceblock , node .getblockhash (0 ), 1 , False , True , False ],
43+ ]
44+ if self .options .descriptors :
45+ response = node .importdescriptors ([{
46+ 'desc' : f'pkh({ pubkey } )' ,
47+ 'label' : '*' ,
48+ 'timestamp' : 'now' ,
49+ }])
50+ else :
51+ rpc_calls .extend ([
52+ [node .importprivkey , node .dumpprivkey (address )],
53+ [node .importaddress , address ],
54+ ])
55+
56+ response = node .importmulti ([{
57+ 'scriptPubKey' : {'address' : address },
58+ 'label' : '*' ,
59+ 'timestamp' : 'now' ,
60+ }])
61+
62+ assert_equal (response [0 ]['success' ], False )
63+ assert_equal (response [0 ]['error' ]['code' ], - 11 )
64+ assert_equal (response [0 ]['error' ]['message' ], "Invalid label name" )
65+
66+ for rpc_call in rpc_calls :
67+ assert_raises_rpc_error (- 11 , "Invalid label name" , * rpc_call , "*" )
68+
3169 def run_test (self ):
3270 # Check that there's no UTXO on the node
3371 node = self .nodes [0 ]
@@ -138,6 +176,8 @@ def run_test(self):
138176 # in the label. This is a no-op.
139177 change_label (node , labels [2 ].addresses [0 ], labels [2 ], labels [2 ])
140178
179+ self .invalid_label_name_test ()
180+
141181 if self .options .descriptors :
142182 # This is a descriptor wallet test because of segwit v1+ addresses
143183 self .log .info ('Check watchonly labels' )
0 commit comments