@@ -101,6 +101,7 @@ def run_test(self):
101101 self .test_simple_two_outputs ()
102102 self .test_change ()
103103 self .test_no_change ()
104+ self .test_change_position ()
104105 self .test_invalid_option ()
105106 self .test_invalid_change_address ()
106107 self .test_valid_change_address ()
@@ -121,7 +122,6 @@ def run_test(self):
121122 self .test_all_watched_funds ()
122123 self .test_option_feerate ()
123124
124-
125125 def test_simple (self ):
126126 self .log .info ("simple test" )
127127 dec_tx , fee , changepos = self .create_and_fund (2 , [], {self .nodes [0 ].getnewaddress (): 1.0 })
@@ -174,6 +174,16 @@ def test_no_change(self):
174174 assert_equal (changepos , - 1 ) # check (no) change
175175 assert check_outputs (outputs , dec_tx ) # check outputs
176176
177+ def test_change_position (self ):
178+ """Ensure setting changePosition in fundraw with an exact match is handled properly."""
179+ self .log .info ("test not-used changePosition option" )
180+ utx = get_unspent (self .nodes [2 ].listunspent (), 5 )
181+ inputs = [{'txid' : utx ['txid' ], 'vout' : utx ['vout' ]}]
182+ outputs = {self .nodes [0 ].getnewaddress (): 5.0 - float (self .test_no_change_fee ) - float (self .fee_tolerance )}
183+ rawtx = self .nodes [2 ].createrawtransaction (inputs , outputs )
184+ rawtxfund = self .nodes [2 ].fundrawtransaction (rawtx , {"changePosition" : 0 })
185+ assert_equal (rawtxfund ["changepos" ], - 1 )
186+
177187 def test_invalid_option (self ):
178188 self .log .info ("test with an invalid option" )
179189 outputs = {self .nodes [0 ].getnewaddress (): 1.0 }
0 commit comments