@@ -92,6 +92,7 @@ def run_test(self):
9292 self .test_option_feerate ()
9393 self .test_address_reuse ()
9494 self .test_option_subtract_fee_from_outputs ()
95+ self .test_subtract_fee_with_presets ()
9596
9697 def test_change_position (self ):
9798 """Ensure setting changePosition in fundraw with an exact match is handled properly."""
@@ -741,5 +742,17 @@ def test_option_subtract_fee_from_outputs(self):
741742 # The total subtracted from the outputs is equal to the fee.
742743 assert_equal (share [0 ] + share [2 ] + share [3 ], result [0 ]['fee' ])
743744
745+ def test_subtract_fee_with_presets (self ):
746+ self .log .info ("Test fundrawtxn subtract fee from outputs with preset inputs that are sufficient" )
747+
748+ addr = self .nodes [0 ].getnewaddress ()
749+ txid = self .nodes [0 ].sendtoaddress (addr , 10 )
750+ vout = find_vout_for_address (self .nodes [0 ], txid , addr )
751+
752+ rawtx = self .nodes [0 ].createrawtransaction ([{'txid' : txid , 'vout' : vout }], [{self .nodes [0 ].getnewaddress (): 5 }])
753+ fundedtx = self .nodes [0 ].fundrawtransaction (rawtx , {'subtractFeeFromOutputs' : [0 ]})
754+ signedtx = self .nodes [0 ].signrawtransactionwithwallet (fundedtx ['hex' ])
755+ self .nodes [0 ].sendrawtransaction (signedtx ['hex' ])
756+
744757if __name__ == '__main__' :
745758 RawTransactionsTest ().main ()
0 commit comments