diff --git a/src/main.cpp b/src/main.cpp index 28f6c05b4..1ae584992 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -92,8 +92,8 @@ uint64_t nPruneTarget = 0; bool fAlerts = DEFAULT_ALERTS; bool fEnableReplacement = DEFAULT_ENABLE_REPLACEMENT; -/** Fees smaller than this (in satoshi) are considered zero fee (for relaying, mining and transaction creation) */ CFeeRate minRelayTxFee = CFeeRate(DEFAULT_MIN_RELAY_TX_FEE); +CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; CTxMemPool mempool(::minRelayTxFee); @@ -1286,10 +1286,10 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState &state, const C LogPrint("mempool", "Rate limit dFreeCount: %g => %g\n", dFreeCount, dFreeCount+nSize); } - if (fRejectAbsurdFee && nFees > ::minRelayTxFee.GetFee(nSize) * 10000) + if (fRejectAbsurdFee && nFees > maxTxFee) return state.Invalid(false, REJECT_HIGHFEE, "absurdly-high-fee", - strprintf("%d > %d", nFees, ::minRelayTxFee.GetFee(nSize) * 10000)); + strprintf("%d > %d", nFees, maxTxFee)); // Calculate in-mempool ancestors, up to a limit. CTxMemPool::setEntries setAncestors; diff --git a/src/main.h b/src/main.h index 3438510a9..ff3cf033a 100644 --- a/src/main.h +++ b/src/main.h @@ -53,6 +53,8 @@ static const bool DEFAULT_WHITELISTRELAY = true; static const bool DEFAULT_WHITELISTFORCERELAY = true; /** Default for -minrelaytxfee, minimum relay fee for transactions */ static const unsigned int DEFAULT_MIN_RELAY_TX_FEE = 10000; +//! -maxtxfee default +static const CAmount DEFAULT_TRANSACTION_MAXFEE = 1 * COIN; //! Discourage users to set fees higher than this amount (in satoshis) per kB static const CAmount HIGH_TX_FEE_PER_KB = 0.1 * COIN; //! -maxtxfee will warn if called with a higher fee than this amount (in satoshis) @@ -158,7 +160,10 @@ extern unsigned int nBytesPerSigOp; extern bool fCheckBlockIndex; extern bool fCheckpointsEnabled; extern size_t nCoinCacheUsage; +/** A fee rate smaller than this is considered zero fee (for relaying, mining and transaction creation) */ extern CFeeRate minRelayTxFee; +/** Absolute maximum transaction fee (in satoshis) used by wallet and mempool (rejects high fee in sendrawtransaction) */ +extern CAmount maxTxFee; extern bool fAlerts; extern bool fEnableReplacement; extern int64_t nLastCoinStakeSearchInterval; diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 0080d9bf7..727562976 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -38,7 +38,6 @@ using namespace std; CWallet* pwalletMain = NULL; /** Transaction fee set by the user */ CFeeRate payTxFee(DEFAULT_TRANSACTION_FEE); -CAmount maxTxFee = DEFAULT_TRANSACTION_MAXFEE; unsigned int nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET; bool bSpendZeroConfChange = DEFAULT_SPEND_ZEROCONF_CHANGE; bool fSendFreeTransactions = DEFAULT_SEND_FREE_TRANSACTIONS; diff --git a/src/wallet/wallet.h b/src/wallet/wallet.h index 9bb06bd45..9da3f39a7 100644 --- a/src/wallet/wallet.h +++ b/src/wallet/wallet.h @@ -32,7 +32,6 @@ extern CWallet* pwalletMain; * Settings */ extern CFeeRate payTxFee; -extern CAmount maxTxFee; extern CAmount nReserveBalance; extern CAmount nMinimumInputValue; extern unsigned int nTxConfirmTarget; @@ -47,8 +46,6 @@ static const CAmount DEFAULT_TRANSACTION_FEE = 10000; static const CAmount DEFAULT_FALLBACK_FEE = 10000; //! -mintxfee default static const CAmount DEFAULT_TRANSACTION_MINFEE = 10000; -//! -maxtxfee default -static const CAmount DEFAULT_TRANSACTION_MAXFEE = 1 * COIN; //! minimum change amount static const CAmount MIN_CHANGE = CENT; //! Default for -spendzeroconfchange @@ -215,6 +212,7 @@ public: int GetDepthInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet); } bool IsInMainChain() const { const CBlockIndex *pindexRet; return GetDepthInMainChain(pindexRet) > 0; } int GetBlocksToMaturity() const; + /** Pass this transaction to the mempool. Fails if absolute fee exceeds maxTxFee. */ bool AcceptToMemoryPool(bool fLimitFree=true, bool fRejectAbsurdFee=true); bool hashUnset() const { return (hashBlock.IsNull() || hashBlock == ABANDON_HASH); } bool isAbandoned() const { return (hashBlock == ABANDON_HASH); }