Browse Source

Merge pull request #2945 from gmaxwell/fee-logic_encourage_sweeping

[Fee logic] Don't count txins for priority to encourage sweeping.
0.10
Gavin Andresen 11 years ago
parent
commit
bd48a4fe49
  1. 16
      src/miner.cpp
  2. 10
      src/wallet.cpp

16
src/miner.cpp

@ -238,9 +238,21 @@ CBlockTemplate* CreateNewBlock(const CScript& scriptPubKeyIn)
} }
if (fMissingInputs) continue; if (fMissingInputs) continue;
// Priority is sum(valuein * age) / txsize // Priority is sum(valuein * age) / modified_txsize
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION); unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
dPriority /= nTxSize; unsigned int nTxSizeMod = nTxSize;
// In order to avoid disincentivizing cleaning up the UTXO set we don't count
// the constant overhead for each txin and up to 110 bytes of scriptSig (which
// is enough to cover a compressed pubkey p2sh redemption) for priority.
// Providing any more cleanup incentive than making additional inputs free would
// risk encouraging people to create junk outputs to redeem later.
BOOST_FOREACH(const CTxIn& txin, tx.vin)
{
unsigned int offset = 41U + min(110U, (unsigned int)txin.scriptSig.size());
if (nTxSizeMod > offset)
nTxSizeMod -= offset;
}
dPriority /= nTxSizeMod;
// This is a more accurate fee-per-kilobyte than is used by the client code, because the // This is a more accurate fee-per-kilobyte than is used by the client code, because the
// client code rounds up the size to the nearest 1K. That's good, because it gives an // client code rounds up the size to the nearest 1K. That's good, because it gives an

10
src/wallet.cpp

@ -1300,7 +1300,15 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend,
strFailReason = _("Transaction too large"); strFailReason = _("Transaction too large");
return false; return false;
} }
dPriority /= nBytes; unsigned int nTxSizeMod = nBytes;
// See miner.c's dPriority logic for the matching network-node side code.
BOOST_FOREACH(const CTxIn& txin, (*(CTransaction*)&wtxNew).vin)
{
unsigned int offset = 41U + min(110U, (unsigned int)txin.scriptSig.size());
if (nTxSizeMod > offset)
nTxSizeMod -= offset;
}
dPriority /= nTxSizeMod;
// Check that enough fee is included // Check that enough fee is included
int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000); int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000);

Loading…
Cancel
Save