@@ -325,14 +325,17 @@ def test_other_watchonly(self):
325
325
send = default .sendall (recipients = [default .getnewaddress ()], inputs = [received_sent_watchonly_utxo ])
326
326
sent_watchonly_txid = send ["txid" ]
327
327
328
- self .generate (self .nodes [0 ], 1 )
328
+ # Tx that has both a watchonly and spendable output
329
+ watchonly_spendable_txid = default .send (outputs = [{received_addr : 1 }, {import_addr :1 }])["txid" ]
330
+
331
+ self .generate (self .nodes [0 ], 2 )
329
332
received_watchonly_tx_info = imports0 .gettransaction (received_watchonly_txid , True )
330
333
received_sent_watchonly_tx_info = imports0 .gettransaction (received_sent_watchonly_utxo ["txid" ], True )
331
334
332
335
balances = imports0 .getbalances ()
333
336
spendable_bal = balances ["mine" ]["trusted" ]
334
337
watchonly_bal = balances ["watchonly" ]["trusted" ]
335
- assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 4 )
338
+ assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 6 )
336
339
337
340
# Mock time forward a bit so we can check that tx metadata is preserved
338
341
self .nodes [0 ].setmocktime (int (time .time ()) + 100 )
@@ -344,8 +347,9 @@ def test_other_watchonly(self):
344
347
assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , imports0 .gettransaction , received_watchonly_txid )
345
348
assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , imports0 .gettransaction , received_sent_watchonly_utxo ['txid' ])
346
349
assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , imports0 .gettransaction , sent_watchonly_txid )
347
- assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 1 )
350
+ assert_equal (len (imports0 .listtransactions (include_watchonly = True )), 2 )
348
351
imports0 .gettransaction (received_txid )
352
+ imports0 .gettransaction (watchonly_spendable_txid )
349
353
assert_equal (imports0 .getbalance (), spendable_bal )
350
354
351
355
assert_equal ("imports0_watchonly" in self .nodes [0 ].listwallets (), True )
@@ -361,9 +365,10 @@ def test_other_watchonly(self):
361
365
assert_equal (received_sent_watchonly_tx_info ["time" ], received_sent_migrated_watchonly_tx_info ["time" ])
362
366
assert_equal (received_sent_watchonly_tx_info ["timereceived" ], received_sent_migrated_watchonly_tx_info ["timereceived" ])
363
367
watchonly .gettransaction (sent_watchonly_txid )
368
+ watchonly .gettransaction (watchonly_spendable_txid )
364
369
assert_equal (watchonly .getbalance (), watchonly_bal )
365
370
assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , watchonly .gettransaction , received_txid )
366
- assert_equal (len (watchonly .listtransactions (include_watchonly = True )), 3 )
371
+ assert_equal (len (watchonly .listtransactions (include_watchonly = True )), 4 )
367
372
368
373
# Check that labels were migrated and persisted to watchonly wallet
369
374
self .nodes [0 ].unloadwallet ("imports0_watchonly" )
0 commit comments