@@ -150,6 +150,7 @@ def run_test(self):
150
150
self .test_feerate_rounding ()
151
151
self .test_input_confs_control ()
152
152
self .test_duplicate_outputs ()
153
+ self .test_cannot_cover_fees ()
153
154
154
155
def test_duplicate_outputs (self ):
155
156
self .log .info ("Test deserializing and funding a transaction with duplicate outputs" )
@@ -1426,7 +1427,8 @@ def test_feerate_rounding(self):
1426
1427
# To test this does not happen, we subtract 202 sats from the input value. If working correctly, this should
1427
1428
# fail with insufficient funds rather than bitcoind asserting.
1428
1429
rawtx = w .createrawtransaction (inputs = [], outputs = [{self .nodes [0 ].getnewaddress (address_type = "bech32" ): 1 - 0.00000202 }])
1429
- assert_raises_rpc_error (- 4 , "Insufficient funds" , w .fundrawtransaction , rawtx , fee_rate = 1.85 )
1430
+ expected_err_msg = "The total transaction amount exceeds your balance when fees are included"
1431
+ assert_raises_rpc_error (- 4 , expected_err_msg , w .fundrawtransaction , rawtx , fee_rate = 1.85 )
1430
1432
1431
1433
def test_input_confs_control (self ):
1432
1434
self .nodes [0 ].createwallet ("minconf" )
@@ -1489,5 +1491,20 @@ def test_input_confs_control(self):
1489
1491
1490
1492
wallet .unloadwallet ()
1491
1493
1494
+ def test_cannot_cover_fees (self ):
1495
+ self .log .info ("Test tx amount exceeds available balance when fees are included" )
1496
+
1497
+ self .nodes [1 ].createwallet ("cannot_cover_fees" )
1498
+ wallet = self .nodes [1 ].get_wallet_rpc ("cannot_cover_fees" )
1499
+
1500
+ self .nodes [0 ].sendtoaddress (wallet .getnewaddress (), 0.3 )
1501
+ self .generate (self .nodes [0 ], 1 )
1502
+
1503
+ rawtx = wallet .createrawtransaction (inputs = [], outputs = [{self .nodes [0 ].getnewaddress (): 0.3 }])
1504
+ expected_err_msg = "The total transaction amount exceeds your balance when fees are included"
1505
+ assert_raises_rpc_error (- 4 , expected_err_msg , wallet .fundrawtransaction , rawtx )
1506
+ wallet .unloadwallet ()
1507
+
1508
+
1492
1509
if __name__ == '__main__' :
1493
1510
RawTransactionsTest ().main ()
0 commit comments