diff options
author | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-09-12 12:26:59 +0200 |
---|---|---|
committer | Wladimir J. van der Laan <laanwj@protonmail.com> | 2019-09-12 12:49:44 +0200 |
commit | 1659b9b09966bc5db989b798a3918b5e66a58cec (patch) | |
tree | b7b9836cc418de68283f3e6dad3e56110f4d118f /test/functional | |
parent | 2e4353d3f1558b2a1d41510ff8a5ba12e7caefff (diff) | |
parent | 0e7c7465bf2b9911da094d9790480f94e158f9a5 (diff) |
Merge #16639: [0.17] abort when attempting to fund a transaction above -maxtxfee
0e7c7465bf2b9911da094d9790480f94e158f9a5 wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction (João Barbosa)
e9adb96f8854d21a02d80b4295f1a2e57579cc18 [wallet] abort when attempting to fund a transaction above maxtxfee (Sjors Provoost)
Pull request description:
Backport #16257.
Cherry-picked from the 0.18 backport in #16414, but without the [wip] messages and without the last commit (which adds a test in a file that didn't exist in 0.17).
ACKs for top commit:
laanwj:
ACK 0e7c7465bf2b9911da094d9790480f94e158f9a5
Tree-SHA512: a0fd603518487854be0b3815f34a8dabd2ed258850c032b08894a7c55cb135df5d3c103f76c5294e8065fec6d610e064acf01d24c77f02eaf996698a1e45d512
Diffstat (limited to 'test/functional')
-rwxr-xr-x | test/functional/rpc_fundrawtransaction.py | 1 | ||||
-rwxr-xr-x | test/functional/rpc_psbt.py | 19 | ||||
-rwxr-xr-x | test/functional/wallet_bumpfee.py | 10 |
3 files changed, 29 insertions, 1 deletions
diff --git a/test/functional/rpc_fundrawtransaction.py b/test/functional/rpc_fundrawtransaction.py index 0c61e9ab62..019a9d4012 100755 --- a/test/functional/rpc_fundrawtransaction.py +++ b/test/functional/rpc_fundrawtransaction.py @@ -662,6 +662,7 @@ class RawTransactionsTest(BitcoinTestFramework): result = self.nodes[3].fundrawtransaction(rawtx) # uses min_relay_tx_fee (set by settxfee) result2 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 2*min_relay_tx_fee}) result3 = self.nodes[3].fundrawtransaction(rawtx, {"feeRate": 10*min_relay_tx_fee}) + assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[3].fundrawtransaction, rawtx, {"feeRate": 1}) result_fee_rate = result['fee'] * 1000 / count_bytes(result['hex']) assert_fee_amount(result2['fee'], count_bytes(result2['hex']), 2 * result_fee_rate) assert_fee_amount(result3['fee'], count_bytes(result3['hex']), 10 * result_fee_rate) diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py index ef895dd13a..1beda6e832 100755 --- a/test/functional/rpc_psbt.py +++ b/test/functional/rpc_psbt.py @@ -6,7 +6,15 @@ """ from test_framework.test_framework import BitcoinTestFramework -from test_framework.util import assert_equal, assert_raises_rpc_error, find_output, disconnect_nodes, connect_nodes_bi, sync_blocks +from test_framework.util import ( + assert_equal, + assert_greater_than, + assert_raises_rpc_error, + connect_nodes_bi, + disconnect_nodes, + find_output, + sync_blocks, +) import json import os @@ -122,6 +130,15 @@ class PSBTTest(BitcoinTestFramework): assert_equal(walletprocesspsbt_out['complete'], True) self.nodes[1].sendrawtransaction(self.nodes[1].finalizepsbt(walletprocesspsbt_out['psbt'])['hex']) + # feeRate of 0.1 BTC / KB produces a total fee slightly below -maxtxfee (~0.05280000): + res = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99}, 0, {"feeRate": 0.1}) + assert_greater_than(res["fee"], 0.05) + assert_greater_than(0.06, res["fee"]) + + # feeRate of 10 BTC / KB produces a total fee well above -maxtxfee + # previously this was silently capped at -maxtxfee + assert_raises_rpc_error(-4, "Fee exceeds maximum configured by -maxtxfee", self.nodes[1].walletcreatefundedpsbt, [{"txid":txid,"vout":p2wpkh_pos},{"txid":txid,"vout":p2sh_p2wpkh_pos},{"txid":txid,"vout":p2pkh_pos}], {self.nodes[1].getnewaddress():29.99}, 0, {"feeRate": 10}) + # partially sign multisig things with node 1 psbtx = self.nodes[1].walletcreatefundedpsbt([{"txid":txid,"vout":p2wsh_pos},{"txid":txid,"vout":p2sh_pos},{"txid":txid,"vout":p2sh_p2wsh_pos}], {self.nodes[1].getnewaddress():29.99})['psbt'] walletprocesspsbt_out = self.nodes[1].walletprocesspsbt(psbtx) diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py index e478347cd7..944fc7b131 100755 --- a/test/functional/wallet_bumpfee.py +++ b/test/functional/wallet_bumpfee.py @@ -76,6 +76,7 @@ class BumpFeeTest(BitcoinTestFramework): test_unconfirmed_not_spendable(rbf_node, rbf_node_address) test_bumpfee_metadata(rbf_node, dest_address) test_locked_wallet_fails(rbf_node, dest_address) + test_maxtxfee_fails(self, rbf_node, dest_address) self.log.info("Success") @@ -206,6 +207,15 @@ def test_settxfee(rbf_node, dest_address): rbf_node.settxfee(Decimal("0.00000000")) # unset paytxfee +def test_maxtxfee_fails(test, rbf_node, dest_address): + test.restart_node(1, ['-maxtxfee=0.00003'] + test.extra_args[1]) + rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT) + rbfid = spend_one_input(rbf_node, dest_address) + assert_raises_rpc_error(-4, "Specified or calculated fee 0.0000332 is too high (cannot be higher than maxTxFee 0.00003)", rbf_node.bumpfee, rbfid) + test.restart_node(1, test.extra_args[1]) + rbf_node.walletpassphrase(WALLET_PASSPHRASE, WALLET_PASSPHRASE_TIMEOUT) + + def test_rebumping(rbf_node, dest_address): # check that re-bumping the original tx fails, but bumping the bumper succeeds rbfid = spend_one_input(rbf_node, dest_address) |