diff options
author | Alex Morcos <morcos@chaincode.com> | 2017-07-27 17:01:39 -0400 |
---|---|---|
committer | Alex Morcos <morcos@chaincode.com> | 2017-07-27 22:04:17 -0400 |
commit | 49d903e6961b42feda9036897f3ff0103dfccd4b (patch) | |
tree | b9156b2173ab7acf456b44c52a579500cf7d0eb6 /src | |
parent | 0b11a07848754347add990a2b2cff4828ffa2be0 (diff) |
Eliminate fee overpaying edge case when subtracting fee from recipients
Diffstat (limited to 'src')
-rw-r--r-- | src/wallet/wallet.cpp | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 3e9c531f00..04e5992c6d 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2774,10 +2774,6 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT // selected to meet nFeeNeeded result in a transaction that // requires less fee than the prior iteration. - // TODO: The case where nSubtractFeeFromAmount > 0 remains - // to be addressed because it requires returning the fee to - // the payees and not the change output. - // If we have no change and a big enough excess fee, then // try to construct transaction again only without picking // new inputs. We now know we only need the smaller fee @@ -2804,6 +2800,8 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT else if (!pick_new_inputs) { // This shouldn't happen, we should have had enough excess // fee to pay for the new output and still meet nFeeNeeded + // Or we should have just subtracted fee from recipients and + // nFeeNeeded should not have changed strFailReason = _("Transaction fee and change calculation failed"); return false; } @@ -2820,6 +2818,12 @@ bool CWallet::CreateTransaction(const std::vector<CRecipient>& vecSend, CWalletT } } + // If subtracting fee from recipients, we now know what fee we + // need to subtract, we have no reason to reselect inputs + if (nSubtractFeeFromAmount > 0) { + pick_new_inputs = false; + } + // Include more fee and try again. nFeeRet = nFeeNeeded; continue; |