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 @@ -625,6 +625,7 @@ bool CWallet::CreateTransactionInternal(
625625 CMutableTransaction txNew;
626626 FeeCalculation feeCalc;
627627 int nBytes{0 };
628+ CAmount fee_needed{0 };
628629 {
629630 std::set<CInputCoin> setCoins;
630631 LOCK (cs_wallet);
@@ -806,9 +807,8 @@ bool CWallet::CreateTransactionInternal(
806807 nBytes += GetSizeOfCompactSize (nExtraPayloadSize) + nExtraPayloadSize;
807808 }
808809
809- nFeeRet = coin_selection_params.m_effective_feerate .GetFee (nBytes);
810+ fee_needed = coin_selection_params.m_effective_feerate .GetFee (nBytes);
810811
811- CAmount fee_needed = nFeeRet;
812812 if (nSubtractFeeFromAmount == 0 ) {
813813 change_position->nValue -= fee_needed;
814814 }
@@ -828,6 +828,8 @@ bool CWallet::CreateTransactionInternal(
828828 fee_needed = coin_selection_params.m_effective_feerate .GetFee (nBytes);
829829 }
830830
831+ nFeeRet = inputs_sum - nValue - change_amount;
832+
831833 // Update nFeeRet in case fee_needed changed due to dropping the change output
832834 if (fee_needed <= change_and_fee - change_amount) {
833835 nFeeRet = change_and_fee - change_amount;
@@ -903,6 +905,11 @@ bool CWallet::CreateTransactionInternal(
903905 }
904906 }
905907
908+ if (fee_needed > nFeeRet) {
909+ error = _ (" Fee needed > fee paid" );
910+ return false ;
911+ }
912+
906913 if (nFeeRet > m_default_max_tx_fee) {
907914 error = TransactionErrorString (TransactionError::MAX_FEE_EXCEEDED);
908915 return false ;
You can’t perform that action at this time.
0 commit comments