Browse Source

Merge pull request #3008 from gavinandresen/CENTrule

Two small free transaction policy changes
0.10
Gavin Andresen 11 years ago
parent
commit
d3b0fa1d82
  1. 15
      src/main.cpp
  2. 7
      src/wallet.cpp

15
src/main.cpp

@ -722,15 +722,18 @@ int64 GetMinFee(const CTransaction& tx, bool fAllowFree, enum GetMinFee_mode mod
{ {
// There is a free transaction area in blocks created by most miners, // There is a free transaction area in blocks created by most miners,
// * If we are relaying we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 1000 // * If we are relaying we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 1000
// to be considered to fall into this category // to be considered to fall into this category. We don't want to encourage sending
// * If we are creating a transaction we allow transactions up to DEFAULT_BLOCK_PRIORITY_SIZE - 17000 // multiple transactions instead of one big transaction to avoid fees.
// (= 10000) to be considered safe and assume they can likely make it into this section // * If we are creating a transaction we allow transactions up to 1,000 bytes
if (nBytes < (mode == GMF_SEND ? (DEFAULT_BLOCK_PRIORITY_SIZE - 17000) : (DEFAULT_BLOCK_PRIORITY_SIZE - 1000))) // to be considered safe and assume they can likely make it into this section.
if (nBytes < (mode == GMF_SEND ? 1000 : (DEFAULT_BLOCK_PRIORITY_SIZE - 1000)))
nMinFee = 0; nMinFee = 0;
} }
// To limit dust spam, require base fee if any output is less than 0.01 // This code can be removed after enough miners have upgraded to version 0.9.
if (nMinFee < nBaseFee) // Until then, be safe when sending and require a fee if any output
// is less than CENT:
if (nMinFee < nBaseFee && mode == GMF_SEND)
{ {
BOOST_FOREACH(const CTxOut& txout, tx.vout) BOOST_FOREACH(const CTxOut& txout, tx.vout)
if (txout.nValue < CENT) if (txout.nValue < CENT)

7
src/wallet.cpp

@ -1231,9 +1231,10 @@ bool CWallet::CreateTransaction(const vector<pair<CScript, int64> >& vecSend,
} }
int64 nChange = nValueIn - nValue - nFeeRet; int64 nChange = nValueIn - nValue - nFeeRet;
// if sub-cent change is required, the fee must be raised to at least nMinTxFee // The following if statement should be removed once enough miners
// or until nChange becomes zero // have upgraded to the 0.9 GetMinFee() rules. Until then, this avoids
// NOTE: this depends on the exact behaviour of GetMinFee // creating free transactions that have change outputs less than
// CENT bitcoins.
if (nFeeRet < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT) if (nFeeRet < CTransaction::nMinTxFee && nChange > 0 && nChange < CENT)
{ {
int64 nMoveToFee = min(nChange, CTransaction::nMinTxFee - nFeeRet); int64 nMoveToFee = min(nChange, CTransaction::nMinTxFee - nFeeRet);

Loading…
Cancel
Save