if (tx.IsCoinBase() || !tx.IsFinal())\r
continue;\r
\r
- // Transaction fee requirements, mainly only needed for flood control\r
- // Under 10K (about 80 inputs) is free for first 100 transactions\r
- // Base rate is 0.01 per KB\r
- int64 nMinFee = tx.GetMinFee(pblock->vtx.size() < 100);\r
+ // Transaction fee based on block size\r
+ int64 nMinFee = tx.GetMinFee(nBlockSize);\r
\r
map<uint256, CTxIndex> mapTestPoolTmp(mapTestPool);\r
if (!tx.ConnectInputs(txdb, mapTestPoolTmp, CDiskTxPos(1,1,1), 0, nFees, false, true, nMinFee))\r
if (nValue < 0)\r
return false;\r
int64 nValueOut = nValue;\r
- nValue += nFee;\r
+ int64 nTotalValue = nValue + nFee;\r
\r
// Choose coins to use\r
set<CWalletTx*> setCoins;\r
- if (!SelectCoins(nValue, setCoins))\r
+ if (!SelectCoins(nTotalValue, setCoins))\r
return false;\r
int64 nValueIn = 0;\r
foreach(CWalletTx* pcoin, setCoins)\r
wtxNew.vout.push_back(CTxOut(nValueOut, scriptPubKey));\r
\r
// Fill a vout back to self with any change\r
- if (nValueIn > nValue)\r
+ if (nValueIn > nTotalValue)\r
{\r
// New private key\r
if (keyRet.IsNull())\r
// Fill a vout to ourself\r
CScript scriptPubKey;\r
scriptPubKey << keyRet.GetPubKey() << OP_CHECKSIG;\r
- wtxNew.vout.push_back(CTxOut(nValueIn - nValue, scriptPubKey));\r
+ wtxNew.vout.push_back(CTxOut(nValueIn - nTotalValue, scriptPubKey));\r
}\r
\r
// Fill a vout to the payee\r
SignSignature(*pcoin, wtxNew, nIn++);\r
\r
// Check that enough fee is included\r
- if (nFee < wtxNew.GetMinFee(true))\r
+ if (nFee < wtxNew.GetMinFee())\r
{\r
- nFee = nFeeRequiredRet = wtxNew.GetMinFee(true);\r
+ nFee = nFeeRequiredRet = wtxNew.GetMinFee();\r
continue;\r
}\r
\r
return nValueOut;\r
}\r
\r
- int64 GetMinFee(bool fDiscount=false) const\r
+ int64 GetMinFee(unsigned int nBlockSize=1) const\r
{\r
// Base fee is 1 cent per kilobyte\r
unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK);\r
int64 nMinFee = (1 + (int64)nBytes / 1000) * CENT;\r
\r
- // First 100 transactions in a block are free\r
- if (fDiscount && nBytes < 10000)\r
+ // Transactions under 60K are free as long as block size is under 80K\r
+ // (about 27,000bc if made of 50bc inputs)\r
+ if (nBytes < 60000 && nBlockSize < 80000)\r
+ nMinFee = 0;\r
+\r
+ // Transactions under 3K are free as long as block size is under 200K\r
+ if (nBytes < 3000 && nBlockSize < 200000)\r
nMinFee = 0;\r
\r
// To limit dust spam, require a 0.01 fee if any output is less than 0.01\r