aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlex Morcos <morcos@chaincode.com>2015-01-16 12:17:57 -0500
committerWladimir J. van der Laan <laanwj@gmail.com>2015-02-03 09:04:20 +0100
commitb6347bf8138395117fa6d3a753c8aa266b05ada0 (patch)
treedff2e29c1cd01582a5f15b944664f038ec30d5f8
parent2448d34298c12a8ef6e21788db5e70ffb554d8b2 (diff)
downloadbitcoin-b6347bf8138395117fa6d3a753c8aa266b05ada0.tar.xz
Fix priority calculation in CreateTransaction
Make this projection of priority in 1 block match the calculation in the low priority reject code. Rebased-From: 2d9b0b7f03a268e557c6dce1dfa29401b5c9178b Github-Pull: #5675
-rw-r--r--src/wallet.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index dd87fab44b..abdeed8f57 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1418,10 +1418,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend,
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
CAmount nCredit = pcoin.first->vout[pcoin.second].nValue;
- //The priority after the next block (depth+1) is used instead of the current,
+ //The coin age after the next block (depth+1) is used instead of the current,
//reflecting an assumption the user would accept a bit more delay for
//a chance at a free transaction.
- dPriority += (double)nCredit * (pcoin.first->GetDepthInMainChain()+1);
+ //But mempool inputs might still be in the mempool, so their age stays 0
+ int age = pcoin.first->GetDepthInMainChain();
+ if (age != 0)
+ age += 1;
+ dPriority += (double)nCredit * age;
}
CAmount nChange = nValueIn - nValue - nFeeRet;