File tree Expand file tree Collapse file tree 1 file changed +9
-2
lines changed
Expand file tree Collapse file tree 1 file changed +9
-2
lines changed Original file line number Diff line number Diff line change @@ -3549,6 +3549,7 @@ bool CWallet::CreateTransactionInternal(
35493549 CMutableTransaction txNew;
35503550 FeeCalculation feeCalc;
35513551 int nBytes{0 };
3552+ CAmount fee_needed{0 };
35523553 {
35533554 std::set<CInputCoin> setCoins;
35543555 LOCK (cs_wallet);
@@ -3730,9 +3731,8 @@ bool CWallet::CreateTransactionInternal(
37303731 nBytes += GetSizeOfCompactSize (nExtraPayloadSize) + nExtraPayloadSize;
37313732 }
37323733
3733- nFeeRet = coin_selection_params.m_effective_feerate .GetFee (nBytes);
3734+ fee_needed = coin_selection_params.m_effective_feerate .GetFee (nBytes);
37343735
3735- CAmount fee_needed = nFeeRet;
37363736 if (nSubtractFeeFromAmount == 0 ) {
37373737 change_position->nValue -= fee_needed;
37383738 }
@@ -3752,6 +3752,8 @@ bool CWallet::CreateTransactionInternal(
37523752 fee_needed = coin_selection_params.m_effective_feerate .GetFee (nBytes);
37533753 }
37543754
3755+ nFeeRet = inputs_sum - nValue - change_amount;
3756+
37553757 // Update nFeeRet in case fee_needed changed due to dropping the change output
37563758 if (fee_needed <= change_and_fee - change_amount) {
37573759 nFeeRet = change_and_fee - change_amount;
@@ -3829,6 +3831,11 @@ bool CWallet::CreateTransactionInternal(
38293831 }
38303832 }
38313833
3834+ if (fee_needed > nFeeRet) {
3835+ error = _ (" Fee needed > fee paid" );
3836+ return false ;
3837+ }
3838+
38323839 if (nFeeRet > m_default_max_tx_fee) {
38333840 error = TransactionErrorString (TransactionError::MAX_FEE_EXCEEDED);
38343841 return false ;
You can’t perform that action at this time.
0 commit comments