aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWladimir J. van der Laan <laanwj@gmail.com>2015-02-26 11:15:13 +0100
committerWladimir J. van der Laan <laanwj@gmail.com>2015-02-26 11:15:24 +0100
commit47fdeb4a9cd7edc3b54005d535d24e579f618b56 (patch)
treec855c5cbeb86efd3ed106dce6753d5454bb689b1
parent74f29c27372cb88e7f4a6f14ee40b699e3c58eb0 (diff)
parent9cd1dd9f6b5aace6c0e780bf4365fb2900757c1a (diff)
downloadbitcoin-47fdeb4a9cd7edc3b54005d535d24e579f618b56.tar.xz
Merge pull request #5807
9cd1dd9 Fix priority calculation in CreateTransaction (Alex Morcos)
-rw-r--r--src/wallet.cpp8
1 files changed, 6 insertions, 2 deletions
diff --git a/src/wallet.cpp b/src/wallet.cpp
index 80f011e7df..0e92c8307b 100644
--- a/src/wallet.cpp
+++ b/src/wallet.cpp
@@ -1281,10 +1281,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64_t> >& vecSend,
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
{
int64_t 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;
}
int64_t nChange = nValueIn - nValue - nFeeRet;