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 /src | |
parent | 2e4353d3f1558b2a1d41510ff8a5ba12e7caefff (diff) | |
parent | 0e7c7465bf2b9911da094d9790480f94e158f9a5 (diff) | |
download | bitcoin-1659b9b09966bc5db989b798a3918b5e66a58cec.tar.xz |
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 'src')
-rw-r--r-- | src/policy/fees.cpp | 1 | ||||
-rw-r--r-- | src/policy/fees.h | 1 | ||||
-rw-r--r-- | src/wallet/fees.cpp | 8 | ||||
-rw-r--r-- | src/wallet/wallet.cpp | 5 |
4 files changed, 6 insertions, 9 deletions
diff --git a/src/policy/fees.cpp b/src/policy/fees.cpp index aee6fbee1a..d9a5474056 100644 --- a/src/policy/fees.cpp +++ b/src/policy/fees.cpp @@ -38,7 +38,6 @@ std::string StringForFeeReason(FeeReason reason) { {FeeReason::PAYTXFEE, "PayTxFee set"}, {FeeReason::FALLBACK, "Fallback fee"}, {FeeReason::REQUIRED, "Minimum Required Fee"}, - {FeeReason::MAXTXFEE, "MaxTxFee limit"} }; auto reason_string = fee_reason_strings.find(reason); diff --git a/src/policy/fees.h b/src/policy/fees.h index 136fb481f7..d46738cefb 100644 --- a/src/policy/fees.h +++ b/src/policy/fees.h @@ -88,7 +88,6 @@ enum class FeeReason { PAYTXFEE, FALLBACK, REQUIRED, - MAXTXFEE, }; std::string StringForFeeReason(FeeReason reason); diff --git a/src/wallet/fees.cpp b/src/wallet/fees.cpp index d620e25f2b..0cac42ba72 100644 --- a/src/wallet/fees.cpp +++ b/src/wallet/fees.cpp @@ -21,13 +21,7 @@ CAmount GetRequiredFee(const CWallet& wallet, unsigned int nTxBytes) CAmount GetMinimumFee(const CWallet& wallet, unsigned int nTxBytes, const CCoinControl& coin_control, const CTxMemPool& pool, const CBlockPolicyEstimator& estimator, FeeCalculation* feeCalc) { - CAmount fee_needed = GetMinimumFeeRate(wallet, coin_control, pool, estimator, feeCalc).GetFee(nTxBytes); - // Always obey the maximum - if (fee_needed > maxTxFee) { - fee_needed = maxTxFee; - if (feeCalc) feeCalc->reason = FeeReason::MAXTXFEE; - } - return fee_needed; + return GetMinimumFeeRate(wallet, coin_control, pool, estimator, feeCalc).GetFee(nTxBytes); } CFeeRate GetRequiredFeeRate(const CWallet& wallet) diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 8d52f7eeca..d5f5df381a 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -3075,6 +3075,11 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CTransac } } + 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; |