@@ -651,7 +651,7 @@ def run_test(self):
651
651
assert_equal (len (self .nodes [3 ].listunspent (1 )), 1 )
652
652
653
653
inputs = []
654
- outputs = {self .nodes [2 ].getnewaddress () : 1 }
654
+ outputs = {self .nodes [3 ].getnewaddress () : 1 }
655
655
rawtx = self .nodes [3 ].createrawtransaction (inputs , outputs )
656
656
result = self .nodes [3 ].fundrawtransaction (rawtx ) # uses min_relay_tx_fee (set by settxfee)
657
657
result2 = self .nodes [3 ].fundrawtransaction (rawtx , {"feeRate" : 2 * min_relay_tx_fee })
@@ -660,6 +660,32 @@ def run_test(self):
660
660
assert_fee_amount (result2 ['fee' ], count_bytes (result2 ['hex' ]), 2 * result_fee_rate )
661
661
assert_fee_amount (result3 ['fee' ], count_bytes (result3 ['hex' ]), 10 * result_fee_rate )
662
662
663
+ #############################
664
+ # Test address reuse option #
665
+ #############################
666
+
667
+ result3 = self .nodes [3 ].fundrawtransaction (rawtx , {"reserveChangeKey" : False })
668
+ res_dec = self .nodes [0 ].decoderawtransaction (result3 ["hex" ])
669
+ changeaddress = ""
670
+ for out in res_dec ['vout' ]:
671
+ if out ['value' ] > 1.0 :
672
+ changeaddress += out ['scriptPubKey' ]['addresses' ][0 ]
673
+ assert (changeaddress != "" )
674
+ nextaddr = self .nodes [3 ].getnewaddress ()
675
+ # frt should not have removed the key from the keypool
676
+ assert (changeaddress == nextaddr )
677
+
678
+ result3 = self .nodes [3 ].fundrawtransaction (rawtx )
679
+ res_dec = self .nodes [0 ].decoderawtransaction (result3 ["hex" ])
680
+ changeaddress = ""
681
+ for out in res_dec ['vout' ]:
682
+ if out ['value' ] > 1.0 :
683
+ changeaddress += out ['scriptPubKey' ]['addresses' ][0 ]
684
+ assert (changeaddress != "" )
685
+ nextaddr = self .nodes [3 ].getnewaddress ()
686
+ # Now the change address key should be removed from the keypool
687
+ assert (changeaddress != nextaddr )
688
+
663
689
######################################
664
690
# Test subtractFeeFromOutputs option #
665
691
######################################
0 commit comments