@@ -285,9 +285,76 @@ def run_test (self):
285
285
assert_equal (result [0 ]['error' ]['code' ], - 8 )
286
286
assert_equal (result [0 ]['error' ]['message' ], 'Incompatibility found between watchonly and keys' )
287
287
288
- # TODO Consistency tests?
289
288
289
+ # Address + Public key + !Internal + Wrong pubkey
290
+ print ("Should not import an address with a wrong public key" )
291
+ address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
292
+ address2 = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
293
+ result = self .nodes [1 ].importmulti ([{
294
+ "scriptPubKey" : {
295
+ "address" : address ['address' ]
296
+ },
297
+ "pubkeys" : [ address2 ['pubkey' ] ]
298
+ }])
299
+ assert_equal (result [0 ]['success' ], False )
300
+ assert_equal (result [0 ]['error' ]['code' ], - 5 )
301
+ assert_equal (result [0 ]['error' ]['message' ], 'Consistency check failed' )
302
+ address_assert = self .nodes [1 ].validateaddress (address ['address' ])
303
+ assert_equal (address_assert ['iswatchonly' ], False )
304
+ assert_equal (address_assert ['ismine' ], False )
305
+
306
+
307
+ # ScriptPubKey + Public key + internal + Wrong pubkey
308
+ print ("Should not import a scriptPubKey with internal and with a wrong public key" )
309
+ address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
310
+ address2 = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
311
+ request = [{
312
+ "scriptPubKey" : address ['scriptPubKey' ],
313
+ "pubkeys" : [ address2 ['pubkey' ] ],
314
+ "internal" : True
315
+ }];
316
+ result = self .nodes [1 ].importmulti (request )
317
+ assert_equal (result [0 ]['success' ], False )
318
+ assert_equal (result [0 ]['error' ]['code' ], - 5 )
319
+ assert_equal (result [0 ]['error' ]['message' ], 'Consistency check failed' )
320
+ address_assert = self .nodes [1 ].validateaddress (address ['address' ])
321
+ assert_equal (address_assert ['iswatchonly' ], False )
322
+ assert_equal (address_assert ['ismine' ], False )
290
323
291
324
325
+ # Address + Private key + !watchonly + Wrong private key
326
+ print ("Should not import an address with a wrong private key" )
327
+ address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
328
+ address2 = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
329
+ result = self .nodes [1 ].importmulti ([{
330
+ "scriptPubKey" : {
331
+ "address" : address ['address' ]
332
+ },
333
+ "keys" : [ self .nodes [0 ].dumpprivkey (address2 ['address' ]) ]
334
+ }])
335
+ assert_equal (result [0 ]['success' ], False )
336
+ assert_equal (result [0 ]['error' ]['code' ], - 5 )
337
+ assert_equal (result [0 ]['error' ]['message' ], 'Consistency check failed' )
338
+ address_assert = self .nodes [1 ].validateaddress (address ['address' ])
339
+ assert_equal (address_assert ['iswatchonly' ], False )
340
+ assert_equal (address_assert ['ismine' ], False )
341
+
342
+
343
+ # ScriptPubKey + Private key + internal + Wrong private key
344
+ print ("Should not import a scriptPubKey with internal and with a wrong private key" )
345
+ address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
346
+ address2 = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
347
+ result = self .nodes [1 ].importmulti ([{
348
+ "scriptPubKey" : address ['scriptPubKey' ],
349
+ "keys" : [ self .nodes [0 ].dumpprivkey (address2 ['address' ]) ],
350
+ "internal" : True
351
+ }])
352
+ assert_equal (result [0 ]['success' ], False )
353
+ assert_equal (result [0 ]['error' ]['code' ], - 5 )
354
+ assert_equal (result [0 ]['error' ]['message' ], 'Consistency check failed' )
355
+ address_assert = self .nodes [1 ].validateaddress (address ['address' ])
356
+ assert_equal (address_assert ['iswatchonly' ], False )
357
+ assert_equal (address_assert ['ismine' ], False )
358
+
292
359
if __name__ == '__main__' :
293
360
ImportMultiTest ().main ()
0 commit comments