@@ -325,14 +325,17 @@ def test_other_watchonly(self):
325325 send = default .sendall (recipients = [default .getnewaddress ()], inputs = [received_sent_watchonly_utxo ])
326326 sent_watchonly_txid = send ["txid" ]
327327
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 )
329332 received_watchonly_tx_info = imports0 .gettransaction (received_watchonly_txid , True )
330333 received_sent_watchonly_tx_info = imports0 .gettransaction (received_sent_watchonly_utxo ["txid" ], True )
331334
332335 balances = imports0 .getbalances ()
333336 spendable_bal = balances ["mine" ]["trusted" ]
334337 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 )
336339
337340 # Mock time forward a bit so we can check that tx metadata is preserved
338341 self .nodes [0 ].setmocktime (int (time .time ()) + 100 )
@@ -344,8 +347,9 @@ def test_other_watchonly(self):
344347 assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , imports0 .gettransaction , received_watchonly_txid )
345348 assert_raises_rpc_error (- 5 , "Invalid or non-wallet transaction id" , imports0 .gettransaction , received_sent_watchonly_utxo ['txid' ])
346349 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 )
348351 imports0 .gettransaction (received_txid )
352+ imports0 .gettransaction (watchonly_spendable_txid )
349353 assert_equal (imports0 .getbalance (), spendable_bal )
350354
351355 assert_equal ("imports0_watchonly" in self .nodes [0 ].listwallets (), True )
@@ -361,9 +365,10 @@ def test_other_watchonly(self):
361365 assert_equal (received_sent_watchonly_tx_info ["time" ], received_sent_migrated_watchonly_tx_info ["time" ])
362366 assert_equal (received_sent_watchonly_tx_info ["timereceived" ], received_sent_migrated_watchonly_tx_info ["timereceived" ])
363367 watchonly .gettransaction (sent_watchonly_txid )
368+ watchonly .gettransaction (watchonly_spendable_txid )
364369 assert_equal (watchonly .getbalance (), watchonly_bal )
365370 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 )
367372
368373 # Check that labels were migrated and persisted to watchonly wallet
369374 self .nodes [0 ].unloadwallet ("imports0_watchonly" )
0 commit comments