wallet_fallbackfee.py
1 #!/usr/bin/env python3 2 # Copyright (c) 2017-2022 The Bitcoin Core developers 3 # Distributed under the MIT software license, see the accompanying 4 # file COPYING or http://www.opensource.org/licenses/mit-license.php. 5 """Test wallet replace-by-fee capabilities in conjunction with the fallbackfee.""" 6 7 from test_framework.blocktools import COINBASE_MATURITY 8 from test_framework.test_framework import BitcoinTestFramework 9 from test_framework.util import assert_raises_rpc_error 10 11 class WalletRBFTest(BitcoinTestFramework): 12 def add_options(self, parser): 13 self.add_wallet_options(parser) 14 15 def set_test_params(self): 16 self.num_nodes = 1 17 self.setup_clean_chain = True 18 19 def skip_test_if_missing_module(self): 20 self.skip_if_no_wallet() 21 22 def run_test(self): 23 self.generate(self.nodes[0], COINBASE_MATURITY + 1) 24 25 # sending a transaction without fee estimations must be possible by default on regtest 26 self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1) 27 28 # test sending a tx with disabled fallback fee (must fail) 29 self.restart_node(0, extra_args=["-fallbackfee=0"]) 30 assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendtoaddress(self.nodes[0].getnewaddress(), 1)) 31 assert_raises_rpc_error(-4, "Fee estimation failed", lambda: self.nodes[0].fundrawtransaction(self.nodes[0].createrawtransaction([], {self.nodes[0].getnewaddress(): 1}))) 32 assert_raises_rpc_error(-6, "Fee estimation failed", lambda: self.nodes[0].sendmany("", {self.nodes[0].getnewaddress(): 1})) 33 34 if __name__ == '__main__': 35 WalletRBFTest().main()