From 5aed3df9704158b15db2b605f23ca5bbf058a15a Mon Sep 17 00:00:00 2001 From: Sunny King Date: Sat, 19 Nov 2011 00:38:40 +0000 Subject: [PATCH] PPCoin: Disallow free transaction; minimum transaction fee at 1 coin --- src/init.cpp | 2 +- src/main.cpp | 9 ++++----- src/main.h | 2 +- src/rpc.cpp | 11 ++++++----- src/wallet.cpp | 6 +++--- 5 files changed, 15 insertions(+), 15 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index e60b55f..3062dc9 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -509,7 +509,7 @@ bool AppInit2(int argc, char* argv[]) wxMessageBox(_("Invalid amount for -paytxfee="), "Bitcoin"); return false; } - if (nTransactionFee > 0.25 * COIN) + if (nTransactionFee >= 10 * COIN) wxMessageBox(_("Warning: -paytxfee is set very high. This is the transaction fee you will pay if you send a transaction."), "Bitcoin", wxOK | wxICON_EXCLAMATION); } diff --git a/src/main.cpp b/src/main.cpp index 862003d..dd6b7a3 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -55,7 +55,7 @@ int64 nHPSTimerStart; // Settings int fGenerateBitcoins = false; -int64 nTransactionFee = 0; +int64 nTransactionFee = MIN_TX_FEE; CAddress addrIncoming; int fLimitProcessors = false; int nLimitProcessors = 1; @@ -413,7 +413,7 @@ bool CTransaction::AcceptToMemoryPool(CTxDB& txdb, bool fCheckInputs, bool* pfMi } // Don't accept it if it can't get into a block - if (nFees < GetMinFee(1000, true, true)) + if (nFees < GetMinFee(1000, false, true)) return error("AcceptToMemoryPool() : not enough fees"); // Continuously rate-limit free transactions @@ -2775,9 +2775,8 @@ CBlock* CreateNewBlock(CReserveKey& reservekey) if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS) continue; - // Transaction fee required depends on block size - bool fAllowFree = (nBlockSize + nTxSize < 4000 || CTransaction::AllowFree(dPriority)); - int64 nMinFee = tx.GetMinFee(nBlockSize, fAllowFree, true); + // ppcoin: simplify transaction fee - allow free = false + int64 nMinFee = tx.GetMinFee(nBlockSize, false, true); // Connecting shouldn't fail due to dependency on other memory pool transactions // because we're already processing them in order of dependency diff --git a/src/main.h b/src/main.h index 77d9f36..e9912ab 100644 --- a/src/main.h +++ b/src/main.h @@ -531,7 +531,7 @@ public: unsigned int nBytes = ::GetSerializeSize(*this, SER_NETWORK); unsigned int nNewBlockSize = nBlockSize + nBytes; - int64 nMinFee = (1 + (int64)nBytes / 1000) * nBaseFee; + int64 nMinFee = nBaseFee; // ppcoin: simplify transaction fee if (fAllowFree) { diff --git a/src/rpc.cpp b/src/rpc.cpp index 6f951b7..81c66ec 100644 --- a/src/rpc.cpp +++ b/src/rpc.cpp @@ -71,7 +71,7 @@ void PrintConsole(const char* format, ...) int64 AmountFromValue(const Value& value) { double dAmount = value.get_real(); - if (dAmount <= 0.0 || dAmount > 21000000.0) + if (dAmount <= 0.0 || dAmount > MAX_MONEY) throw JSONRPCError(-3, "Invalid amount"); int64 nAmount = roundint64(dAmount * COIN); if (!MoneyRange(nAmount)) @@ -497,12 +497,13 @@ Value settxfee(const Array& params, bool fHelp) if (fHelp || params.size() < 1 || params.size() > 1) throw runtime_error( "settxfee \n" - " is a real and is rounded to the nearest 0.00000001"); + " is a real and is rounded to the nearest 0.0001\n" + "Minimum and default transaction fee is 1 coin"); // Amount - int64 nAmount = 0; - if (params[0].get_real() != 0.0) - nAmount = AmountFromValue(params[0]); // rejects 0.0 amounts + int64 nAmount = MIN_TX_FEE; + if (params[0].get_real() != 0.0) // rejects 0.0 amounts + nAmount = max(nAmount, AmountFromValue(params[0])); nTransactionFee = nAmount; return true; diff --git a/src/wallet.cpp b/src/wallet.cpp index 6ef75ef..561a7b7 100644 --- a/src/wallet.cpp +++ b/src/wallet.cpp @@ -1,4 +1,5 @@ // Copyright (c) 2009-2011 Satoshi Nakamoto & Bitcoin developers +// Copyright (c) 2011 The PPCoin developers // Distributed under the MIT/X11 software license, see the accompanying // file license.txt or http://www.opensource.org/licenses/mit-license.php. @@ -816,9 +817,8 @@ bool CWallet::CreateTransaction(const vector >& vecSend, CW dPriority /= nBytes; // Check that enough fee is included - int64 nPayFee = nTransactionFee * (1 + (int64)nBytes / 1000); - bool fAllowFree = CTransaction::AllowFree(dPriority); - int64 nMinFee = wtxNew.GetMinFee(1, fAllowFree); + int64 nPayFee = nTransactionFee; // ppcoin: simplify tx fee + int64 nMinFee = wtxNew.GetMinFee(1, false); if (nFeeRet < max(nPayFee, nMinFee)) { nFeeRet = max(nPayFee, nMinFee); -- 1.7.1