Skip to content

Commit

Permalink
Fix priority calculation in CreateTransaction
Browse files Browse the repository at this point in the history
Make this projection of priority in 1 block match the calculation in the low priority reject code.

Rebased-From: 2d9b0b7
Github-Pull: #5675
  • Loading branch information
morcos authored and laanwj committed Feb 3, 2015
1 parent 2448d34 commit b6347bf
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/wallet.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit b6347bf

Please sign in to comment.