aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main.cpp1
-rw-r--r--src/wallet.cpp14
2 files changed, 12 insertions, 3 deletions
diff --git a/src/main.cpp b/src/main.cpp
index fa893e5936..b57974f577 100644
--- a/src/main.cpp
+++ b/src/main.cpp
@@ -2567,6 +2567,7 @@ bool SendMessages(CNode* pto, bool fSendTrickle)
vGetData.clear();
}
}
+ mapAlreadyAskedFor[inv] = nNow;
pto->mapAskFor.erase(pto->mapAskFor.begin());
}
if (!vGetData.empty())
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 74f8b9f67e..8c4903b198 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -935,9 +935,17 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend, CW
dPriority += (double)nCredit * pcoin.first->GetDepthInMainChain();
}
- // Fill a vout back to self with any change
- int64 nChange = nValueIn - nTotalValue;
- if (nChange >= CENT)
+ int64 nChange = nValueIn - nValue - nFeeRet;
+ // if sub-cent change is required, the fee must be raised to at least MIN_TX_FEE
+ // or until nChange becomes zero
+ if (nFeeRet < MIN_TX_FEE && nChange > 0 && nChange < CENT)
+ {
+ int64 nMoveToFee = min(nChange, MIN_TX_FEE - nFeeRet);
+ nChange -= nMoveToFee;
+ nFeeRet += nMoveToFee;
+ }
+
+ if (nChange > 0)
{
// Note: We use a new key here to keep it from being obvious which side is the change.
// The drawback is that by not reusing a previous key, the change may be lost if a