aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJoão Barbosa <[email protected]>2019-07-02 15:16:36 +0100
committerJoão Barbosa <[email protected]>2019-08-25 02:51:07 +0100
commita11dbaa547ec01e7e11ca4dbe2433e7d987c82bb (patch)
treec00d28c6ebf7bd8a9636e5ae154af96fd501dcb4
parent0.18: [wallet] abort when attempting to fund a transaction above maxtxfee (diff)
downloaddiscoin-a11dbaa547ec01e7e11ca4dbe2433e7d987c82bb.tar.xz
discoin-a11dbaa547ec01e7e11ca4dbe2433e7d987c82bb.zip
0.18: wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction
Github-Pull: #16322 Rebased-From: 5c1b9714cb0a13be28324f91f4ec9ca66a1de8c7
-rw-r--r--src/wallet/wallet.cpp10
-rwxr-xr-xtest/functional/rpc_psbt.py2
-rwxr-xr-xtest/functional/wallet_bumpfee.py10
3 files changed, 16 insertions, 6 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index 7a1a3cd41..1c387594a 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2690,11 +2690,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
}
}
- if (nFeeRet > maxTxFee) {
- strFailReason = _("Fee exceeds maximum configured by -maxtxfee");
- return false;
- }
-
return true;
}
@@ -3131,6 +3126,11 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
}
}
+ if (nFeeRet > maxTxFee) {
+ strFailReason = _("Fee exceeds maximum configured by -maxtxfee");
+ return false;
+ }
+
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
// Lastly, ensure this tx will pass the mempool's chain limits
LockPoints lp;
diff --git a/test/functional/rpc_psbt.py b/test/functional/rpc_psbt.py
index 259d643e1..f4152503e 100755
--- a/test/functional/rpc_psbt.py
+++ b/test/functional/rpc_psbt.py
@@ -134,7 +134,7 @@ class PSBTTest(BitcoinTestFramework):
assert_greater_than(0.06, res["fee"])
# feeRate of 10 BTC / KB produces a total fee well above -maxtxfee
- # previously this was silenty capped at -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
diff --git a/test/functional/wallet_bumpfee.py b/test/functional/wallet_bumpfee.py
index 7d3d9b61e..cd93b2599 100755
--- a/test/functional/wallet_bumpfee.py
+++ b/test/functional/wallet_bumpfee.py
@@ -73,6 +73,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")
@@ -204,6 +205,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)