Merge pull request #5675
2d9b0b7
Fix priority calculation in CreateTransaction (Alex Morcos)
This commit is contained in:
commit
4e2b1fff98
1 changed files with 6 additions and 2 deletions
|
@ -1445,10 +1445,14 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, CAmount> >& vecSend,
|
||||||
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
|
BOOST_FOREACH(PAIRTYPE(const CWalletTx*, unsigned int) pcoin, setCoins)
|
||||||
{
|
{
|
||||||
CAmount nCredit = pcoin.first->vout[pcoin.second].nValue;
|
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
|
//reflecting an assumption the user would accept a bit more delay for
|
||||||
//a chance at a free transaction.
|
//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;
|
CAmount nChange = nValueIn - nValue - nFeeRet;
|
||||||
|
|
Loading…
Reference in a new issue