aboutsummaryrefslogtreecommitdiff
path: root/src/wallet
diff options
context:
space:
mode:
authorSjors Provoost <sjors@sprovoost.nl>2019-06-28 22:44:38 -0400
committerSjors Provoost <sjors@sprovoost.nl>2019-08-19 16:15:07 +0200
commite9adb96f8854d21a02d80b4295f1a2e57579cc18 (patch)
treef71935ecce27e5ae4898ed5a67366aec970c5ab3 /src/wallet
parentc165df198d6e9ea7292af0578024113803b8a6a2 (diff)
[wallet] abort when attempting to fund a transaction above maxtxfee
FundTransaction calls GetMinimumFee which, when the fee rate is absurdly high, quietly reduced the fee to -maxtxfee. Becaue an absurdly high fee rate is usually the result of a fat finger, aborting seems safer behavior. Github-Pull: #16257 Rebased-From: 806b0052c3b45415862f74f20ba5f389e5b673de
Diffstat (limited to 'src/wallet')
-rw-r--r--src/wallet/fees.cpp8
-rw-r--r--src/wallet/wallet.cpp5
2 files changed, 6 insertions, 7 deletions
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..92dc0f5d31 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2671,6 +2671,11 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
}
}
+ if (nFeeRet > maxTxFee) {
+ strFailReason = _("Fee exceeds maximum configured by -maxtxfee");
+ return false;
+ }
+
return true;
}