@@ -20,6 +20,7 @@ def run_test (self):
20
20
print ("Mining blocks..." )
21
21
self .nodes [0 ].generate (1 )
22
22
self .nodes [1 ].generate (1 )
23
+ timestamp = self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['mediantime' ]
23
24
24
25
# keyword definition
25
26
PRIV_KEY = 'privkey'
@@ -59,6 +60,9 @@ def run_test (self):
59
60
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
60
61
assert_equal (address_assert ['iswatchonly' ], True )
61
62
assert_equal (address_assert ['ismine' ], False )
63
+ assert_equal (address_assert ['timestamp' ], timestamp )
64
+ watchonly_address = address ['address' ]
65
+ watchonly_timestamp = timestamp
62
66
63
67
64
68
# ScriptPubKey + internal
@@ -73,6 +77,7 @@ def run_test (self):
73
77
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
74
78
assert_equal (address_assert ['iswatchonly' ], True )
75
79
assert_equal (address_assert ['ismine' ], False )
80
+ assert_equal (address_assert ['timestamp' ], timestamp )
76
81
77
82
# ScriptPubKey + !internal
78
83
print ("Should not import a scriptPubKey without internal flag" )
@@ -87,6 +92,7 @@ def run_test (self):
87
92
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
88
93
assert_equal (address_assert ['iswatchonly' ], False )
89
94
assert_equal (address_assert ['ismine' ], False )
95
+ assert_equal ('timestamp' in address_assert , False )
90
96
91
97
92
98
# Address + Public key + !Internal
@@ -103,6 +109,7 @@ def run_test (self):
103
109
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
104
110
assert_equal (address_assert ['iswatchonly' ], True )
105
111
assert_equal (address_assert ['ismine' ], False )
112
+ assert_equal (address_assert ['timestamp' ], timestamp )
106
113
107
114
108
115
# ScriptPubKey + Public key + internal
@@ -119,6 +126,7 @@ def run_test (self):
119
126
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
120
127
assert_equal (address_assert ['iswatchonly' ], True )
121
128
assert_equal (address_assert ['ismine' ], False )
129
+ assert_equal (address_assert ['timestamp' ], timestamp )
122
130
123
131
# ScriptPubKey + Public key + !internal
124
132
print ("Should not import a scriptPubKey without internal and with public key" )
@@ -135,11 +143,11 @@ def run_test (self):
135
143
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
136
144
assert_equal (address_assert ['iswatchonly' ], False )
137
145
assert_equal (address_assert ['ismine' ], False )
146
+ assert_equal ('timestamp' in address_assert , False )
138
147
139
148
# Address + Private key + !watchonly
140
149
print ("Should import an address with private key" )
141
150
address = self .nodes [0 ].validateaddress (self .nodes [0 ].getnewaddress ())
142
- timestamp = self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['mediantime' ]
143
151
result = self .nodes [1 ].importmulti ([{
144
152
"scriptPubKey" : {
145
153
"address" : address ['address' ]
@@ -170,6 +178,7 @@ def run_test (self):
170
178
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
171
179
assert_equal (address_assert ['iswatchonly' ], False )
172
180
assert_equal (address_assert ['ismine' ], False )
181
+ assert_equal ('timestamp' in address_assert , False )
173
182
174
183
# ScriptPubKey + Private key + internal
175
184
print ("Should import a scriptPubKey with internal and with private key" )
@@ -184,6 +193,7 @@ def run_test (self):
184
193
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
185
194
assert_equal (address_assert ['iswatchonly' ], False )
186
195
assert_equal (address_assert ['ismine' ], True )
196
+ assert_equal (address_assert ['timestamp' ], timestamp )
187
197
188
198
# ScriptPubKey + Private key + !internal
189
199
print ("Should not import a scriptPubKey without internal and with private key" )
@@ -199,6 +209,7 @@ def run_test (self):
199
209
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
200
210
assert_equal (address_assert ['iswatchonly' ], False )
201
211
assert_equal (address_assert ['ismine' ], False )
212
+ assert_equal ('timestamp' in address_assert , False )
202
213
203
214
204
215
# P2SH address
@@ -209,6 +220,7 @@ def run_test (self):
209
220
self .nodes [1 ].generate (100 )
210
221
transactionid = self .nodes [1 ].sendtoaddress (multi_sig_script ['address' ], 10.00 )
211
222
self .nodes [1 ].generate (1 )
223
+ timestamp = self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['mediantime' ]
212
224
transaction = self .nodes [1 ].gettransaction (transactionid )
213
225
214
226
print ("Should import a p2sh" )
@@ -222,6 +234,7 @@ def run_test (self):
222
234
address_assert = self .nodes [1 ].validateaddress (multi_sig_script ['address' ])
223
235
assert_equal (address_assert ['isscript' ], True )
224
236
assert_equal (address_assert ['iswatchonly' ], True )
237
+ assert_equal (address_assert ['timestamp' ], timestamp )
225
238
p2shunspent = self .nodes [1 ].listunspent (0 ,999999 , [multi_sig_script ['address' ]])[0 ]
226
239
assert_equal (p2shunspent ['spendable' ], False )
227
240
assert_equal (p2shunspent ['solvable' ], False )
@@ -235,6 +248,7 @@ def run_test (self):
235
248
self .nodes [1 ].generate (100 )
236
249
transactionid = self .nodes [1 ].sendtoaddress (multi_sig_script ['address' ], 10.00 )
237
250
self .nodes [1 ].generate (1 )
251
+ timestamp = self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['mediantime' ]
238
252
transaction = self .nodes [1 ].gettransaction (transactionid )
239
253
240
254
print ("Should import a p2sh with respective redeem script" )
@@ -246,6 +260,8 @@ def run_test (self):
246
260
"redeemscript" : multi_sig_script ['redeemScript' ]
247
261
}])
248
262
assert_equal (result [0 ]['success' ], True )
263
+ address_assert = self .nodes [1 ].validateaddress (multi_sig_script ['address' ])
264
+ assert_equal (address_assert ['timestamp' ], timestamp )
249
265
250
266
p2shunspent = self .nodes [1 ].listunspent (0 ,999999 , [multi_sig_script ['address' ]])[0 ]
251
267
assert_equal (p2shunspent ['spendable' ], False )
@@ -260,6 +276,7 @@ def run_test (self):
260
276
self .nodes [1 ].generate (100 )
261
277
transactionid = self .nodes [1 ].sendtoaddress (multi_sig_script ['address' ], 10.00 )
262
278
self .nodes [1 ].generate (1 )
279
+ timestamp = self .nodes [1 ].getblock (self .nodes [1 ].getbestblockhash ())['mediantime' ]
263
280
transaction = self .nodes [1 ].gettransaction (transactionid )
264
281
265
282
print ("Should import a p2sh with respective redeem script and private keys" )
@@ -272,6 +289,8 @@ def run_test (self):
272
289
"keys" : [ self .nodes [0 ].dumpprivkey (sig_address_1 ['address' ]), self .nodes [0 ].dumpprivkey (sig_address_2 ['address' ])]
273
290
}])
274
291
assert_equal (result [0 ]['success' ], True )
292
+ address_assert = self .nodes [1 ].validateaddress (multi_sig_script ['address' ])
293
+ assert_equal (address_assert ['timestamp' ], timestamp )
275
294
276
295
p2shunspent = self .nodes [1 ].listunspent (0 ,999999 , [multi_sig_script ['address' ]])[0 ]
277
296
assert_equal (p2shunspent ['spendable' ], False )
@@ -319,6 +338,7 @@ def run_test (self):
319
338
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
320
339
assert_equal (address_assert ['iswatchonly' ], False )
321
340
assert_equal (address_assert ['ismine' ], False )
341
+ assert_equal ('timestamp' in address_assert , False )
322
342
323
343
324
344
# ScriptPubKey + Public key + internal + Wrong pubkey
@@ -338,6 +358,7 @@ def run_test (self):
338
358
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
339
359
assert_equal (address_assert ['iswatchonly' ], False )
340
360
assert_equal (address_assert ['ismine' ], False )
361
+ assert_equal ('timestamp' in address_assert , False )
341
362
342
363
343
364
# Address + Private key + !watchonly + Wrong private key
@@ -357,6 +378,7 @@ def run_test (self):
357
378
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
358
379
assert_equal (address_assert ['iswatchonly' ], False )
359
380
assert_equal (address_assert ['ismine' ], False )
381
+ assert_equal ('timestamp' in address_assert , False )
360
382
361
383
362
384
# ScriptPubKey + Private key + internal + Wrong private key
@@ -375,6 +397,15 @@ def run_test (self):
375
397
address_assert = self .nodes [1 ].validateaddress (address ['address' ])
376
398
assert_equal (address_assert ['iswatchonly' ], False )
377
399
assert_equal (address_assert ['ismine' ], False )
400
+ assert_equal ('timestamp' in address_assert , False )
401
+
402
+ # restart nodes to check for proper serialization/deserialization of watch only address
403
+ stop_nodes (self .nodes )
404
+ self .nodes = start_nodes (2 , self .options .tmpdir )
405
+ address_assert = self .nodes [1 ].validateaddress (watchonly_address )
406
+ assert_equal (address_assert ['iswatchonly' ], True )
407
+ assert_equal (address_assert ['ismine' ], False )
408
+ assert_equal (address_assert ['timestamp' ], watchonly_timestamp );
378
409
379
410
# Bad or missing timestamps
380
411
print ("Should throw on invalid or missing timestamp values" )
0 commit comments