@@ -2774,10 +2774,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2774
2774
// selected to meet nFeeNeeded result in a transaction that
2775
2775
// requires less fee than the prior iteration.
2776
2776
2777
- // TODO: The case where nSubtractFeeFromAmount > 0 remains
2778
- // to be addressed because it requires returning the fee to
2779
- // the payees and not the change output.
2780
-
2781
2777
// If we have no change and a big enough excess fee, then
2782
2778
// try to construct transaction again only without picking
2783
2779
// new inputs. We now know we only need the smaller fee
@@ -2804,6 +2800,8 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2804
2800
else if (!pick_new_inputs) {
2805
2801
// This shouldn't happen, we should have had enough excess
2806
2802
// fee to pay for the new output and still meet nFeeNeeded
2803
+ // Or we should have just subtracted fee from recipients and
2804
+ // nFeeNeeded should not have changed
2807
2805
strFailReason = _ (" Transaction fee and change calculation failed" );
2808
2806
return false ;
2809
2807
}
@@ -2820,6 +2818,12 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT
2820
2818
}
2821
2819
}
2822
2820
2821
+ // If subtracting fee from recipients, we now know what fee we
2822
+ // need to subtract, we have no reason to reselect inputs
2823
+ if (nSubtractFeeFromAmount > 0 ) {
2824
+ pick_new_inputs = false ;
2825
+ }
2826
+
2823
2827
// Include more fee and try again.
2824
2828
nFeeRet = nFeeNeeded;
2825
2829
continue ;
0 commit comments