aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2019-07-10 13:58:59 +0200
committerWladimir J. van der Laan <laanwj@gmail.com>2019-07-10 14:00:52 +0200
commit6c1e45c4c41676f80ac6fb8d48cfbcf839593f19 (patch)
tree0acefc1aa618a46a0cb5e70fdfd4cf612b4819ba /src
parentd1fc827300e2cefc6f0983e0e62d999b58ee5444 (diff)
parent0d101a340c44841cbbc5982d55354b1787bc39e2 (diff)
downloadbitcoin-6c1e45c4c41676f80ac6fb8d48cfbcf839593f19.tar.xz
Merge #16322: wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction
0d101a340c44841cbbc5982d55354b1787bc39e2 test: Add test for maxtxfee option (MarcoFalke) 177550101b600ccb32886695326eb72cd9752c8b wallet: Remove unreachable code in CreateTransaction (MarcoFalke) 5c1b9714cb0a13be28324f91f4ec9ca66a1de8c7 wallet: Fix -maxtxfee check by moving it to CWallet::CreateTransaction (João Barbosa) Pull request description: Follow up to #16257, this PR makes `bumpfee` aware of `-maxtxfee`. It also prevents dangling locked unspents when calling `fundrawtransaction` - because the previous check was after `LockCoin`. ACKs for top commit: MarcoFalke: re-ACK 0d101a340c44841cbbc5982d55354b1787bc39e2, only change is small test fixup Tree-SHA512: 3464b24ae7cd4e72ed41438c6661828ba1304af020f05da62720b23668ae734e16cf47c6d97e150cc84ef631ee099b16fc786c858f3d089905845437338fd512
Diffstat (limited to 'src')
-rw-r--r--src/qt/walletmodel.cpp7
-rw-r--r--src/wallet/wallet.cpp18
2 files changed, 10 insertions, 15 deletions
diff --git a/src/qt/walletmodel.cpp b/src/qt/walletmodel.cpp
index c1b798bad6..57406179f7 100644
--- a/src/qt/walletmodel.cpp
+++ b/src/qt/walletmodel.cpp
@@ -221,9 +221,12 @@ WalletModel::SendCoinsReturn WalletModel::prepareTransaction(WalletModelTransact
return TransactionCreationFailed;
}
- // Reject absurdly high fee
- if (nFeeRequired > m_wallet->getDefaultMaxTxFee())
+ // Reject absurdly high fee. (This can never happen because the
+ // wallet never creates transactions with fee greater than
+ // m_default_max_tx_fee. This merely a belt-and-suspenders check).
+ if (nFeeRequired > m_wallet->getDefaultMaxTxFee()) {
return AbsurdFee;
+ }
}
return SendCoinsReturn(OK);
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp
index aedb22c31c..a9bd1e3164 100644
--- a/src/wallet/wallet.cpp
+++ b/src/wallet/wallet.cpp
@@ -2696,11 +2696,6 @@ bool CWallet::FundTransaction(CMutableTransaction& tx, CAmount& nFeeRet, int& nC
}
}
- if (nFeeRet > this->m_default_max_tx_fee) {
- strFailReason = TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED);
- return false;
- }
-
return true;
}
@@ -3010,14 +3005,6 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
return false;
}
- // If we made it here and we aren't even able to meet the relay fee on the next pass, give up
- // because we must be at the maximum allowed fee.
- if (nFeeNeeded < chain().relayMinFee().GetFee(nBytes))
- {
- strFailReason = _("Transaction too large for fee policy");
- return false;
- }
-
if (nFeeRet >= nFeeNeeded) {
// Reduce fee to only the needed amount if possible. This
// prevents potential overpayment in fees if the coins
@@ -3134,6 +3121,11 @@ bool CWallet::CreateTransaction(interfaces::Chain::Lock& locked_chain, const std
}
}
+ if (nFeeRet > m_default_max_tx_fee) {
+ strFailReason = TransactionErrorString(TransactionError::MAX_FEE_EXCEEDED);
+ return false;
+ }
+
if (gArgs.GetBoolArg("-walletrejectlongchains", DEFAULT_WALLET_REJECT_LONG_CHAINS)) {
// Lastly, ensure this tx will pass the mempool's chain limits
if (!chain().checkChainLimits(tx)) {