Match fee calculation to legacy code

Purge all support for zero-fee transactions
Disable IsDust() for backwards compatibility
This commit is contained in:
J Ross Nicoll 2015-09-03 21:34:03 +01:00
parent 070af086a2
commit ce196a9bfc
9 changed files with 46 additions and 31 deletions

View file

@ -150,9 +150,10 @@ CAmount GetDogecoinBlockSubsidy(int nHeight, const Consensus::Params& consensusP
int64_t GetDogecoinDustFee(const std::vector<CTxOut> &vout, CFeeRate &baseFeeRate) {
int64_t nFee = 0;
// To limit dust spam, add base fee for each output less than DUST_SOFT_LIMIT
// To limit dust spam, add base fee for each dust output
BOOST_FOREACH(const CTxOut& txout, vout)
if (txout.IsDust(::minRelayTxFee))
// if (txout.IsDust(::minRelayTxFee))
if (txout.nValue < COIN)
nFee += baseFeeRate.GetFeePerK();
return nFee;

View file

@ -346,7 +346,9 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-salvagewallet", _("Attempt to recover private keys from a corrupt wallet.dat") + " " + _("on startup"));
strUsage += HelpMessageOpt("-sendfreetransactions", strprintf(_("Send transactions as zero-fee transactions if possible (default: %u)"), 0));
strUsage += HelpMessageOpt("-spendzeroconfchange", strprintf(_("Spend unconfirmed change when sending transactions (default: %u)"), 1));
strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
// Dogecoin: Disable TX confirm target as the dust prevention fees make
// the fee estimation code produce bizarre results.
// strUsage += HelpMessageOpt("-txconfirmtarget=<n>", strprintf(_("If paytxfee is not set, include enough fee so transactions begin confirmation on average within n blocks (default: %u)"), DEFAULT_TX_CONFIRM_TARGET));
strUsage += HelpMessageOpt("-maxtxfee=<amt>", strprintf(_("Maximum total fees to use in a single wallet transaction; setting this too low may abort large transactions (default: %s)"),
FormatMoney(maxTxFee)));
strUsage += HelpMessageOpt("-upgradewallet", _("Upgrade wallet to latest format") + " " + _("on startup"));
@ -355,7 +357,7 @@ std::string HelpMessage(HelpMessageMode mode)
strUsage += HelpMessageOpt("-walletnotify=<cmd>", _("Execute command when a wallet transaction changes (%s in cmd is replaced by TxID)"));
strUsage += HelpMessageOpt("-zapwallettxes=<mode>", _("Delete all wallet transactions and only recover those parts of the blockchain through -rescan on startup") +
" " + _("(1 = keep tx meta data e.g. account owner and payment request information, 2 = drop tx meta data)"));
#endif
strUsage += HelpMessageGroup(_("Debugging/Testing options:"));
@ -869,7 +871,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
mapArgs["-maxtxfee"], ::minRelayTxFee.ToString()));
}
}
nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
// Dogecoin: Disable txconfirmtarget
// nTxConfirmTarget = GetArg("-txconfirmtarget", DEFAULT_TX_CONFIRM_TARGET);
nTxConfirmTarget = DEFAULT_TX_CONFIRM_TARGET;
bSpendZeroConfChange = GetBoolArg("-spendzeroconfchange", true);
fSendFreeTransactions = GetBoolArg("-sendfreetransactions", false);

View file

@ -872,8 +872,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
CAmount nMinFee = ::minRelayTxFee.GetFee(nBytes);
nMinFee += GetDogecoinDustFee(tx.vout, ::minRelayTxFee);
// Dogecoin: Disable free transactions
/* if (fAllowFree)
if (fAllowFree)
{
// 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
@ -881,7 +880,7 @@ CAmount GetMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowF
// multiple transactions instead of one big transaction to avoid fees.
if (nBytes < (DEFAULT_BLOCK_PRIORITY_SIZE - 1000))
nMinFee = 0;
} */
}
if (!MoneyRange(nMinFee))
nMinFee = MAX_MONEY;

View file

@ -51,7 +51,7 @@ struct CNodeStateStats;
static const unsigned int DEFAULT_BLOCK_MAX_SIZE = 750000;
static const unsigned int DEFAULT_BLOCK_MIN_SIZE = 0;
/** Default for -blockprioritysize, maximum space for zero/low-fee transactions **/
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 50000;
static const unsigned int DEFAULT_BLOCK_PRIORITY_SIZE = 27000;
/** Default for accepting alerts from the P2P network. */
static const bool DEFAULT_ALERTS = true;
/** The maximum size for transactions we're willing to relay/mine */

View file

@ -145,13 +145,18 @@ public:
// need a CTxIn of at least 148 bytes to spend:
// so dust is a txout less than 546 satoshis
// with default minRelayTxFee.
size_t nSize = GetSerializeSize(SER_DISK,0)+148u;
return 3*minRelayTxFee.GetFee(nSize);
// size_t nSize = GetSerializeSize(SER_DISK,0)+148u;
// return 3*minRelayTxFee.GetFee(nSize);
// Dogecoin: Dust is 1 COIN
return COIN;
}
bool IsDust(const CFeeRate &minRelayTxFee) const
{
return (nValue < GetDustThreshold(minRelayTxFee));
// Dogecoin: IsDust() detection disabled, allows any valid dust to be relayed.
// The fees imposed on each dust txo is considered sufficient spam deterrant.
// return (nValue < GetDustThreshold(minRelayTxFee));
return false;
}
friend bool operator==(const CTxOut& a, const CTxOut& b)

View file

@ -551,14 +551,15 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nPayFee = CWallet::GetMinimumFee(txDummy, nBytes, nTxConfirmTarget, mempool);
// Allow free?
double dPriorityNeeded = mempoolEstimatePriority;
if (dPriorityNeeded <= 0)
dPriorityNeeded = AllowFreeThreshold(); // not enough data, back to hard-coded
fAllowFree = (dPriority >= dPriorityNeeded);
// Dogecoin: No free transactions
// double dPriorityNeeded = mempoolEstimatePriority;
// if (dPriorityNeeded <= 0)
// dPriorityNeeded = AllowFreeThreshold(); // not enough data, back to hard-coded
// fAllowFree = (dPriority >= dPriorityNeeded);
if (fSendFreeTransactions)
if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
nPayFee = 0;
// if (fSendFreeTransactions)
// if (fAllowFree && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
// nPayFee = 0;
if (nPayAmount > 0)
{
@ -570,8 +571,9 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
if (nChange > 0 && nChange < CENT)
{
CTxOut txout(nChange, (CScript)vector<unsigned char>(24, 0));
if (txout.IsDust(::minRelayTxFee))
{
// Dogecoin: Anything below 1 DOGE is considered dust
// if (txout.IsDust(::minRelayTxFee))
// {
if (CoinControlDialog::fSubtractFeeFromAmount) // dust-change will be raised until no dust
nChange = txout.GetDustThreshold(::minRelayTxFee);
else
@ -579,7 +581,7 @@ void CoinControlDialog::updateLabels(WalletModel *model, QDialog* dialog)
nPayFee += nChange;
nChange = 0;
}
}
//}
}
if (nChange == 0 && !CoinControlDialog::fSubtractFeeFromAmount)

View file

@ -340,8 +340,9 @@ BOOST_AUTO_TEST_CASE(test_IsStandard)
string reason;
BOOST_CHECK(IsStandardTx(t, reason));
t.vout[0].nValue = 501; // dust
BOOST_CHECK(!IsStandardTx(t, reason));
// Dogecoin: Dogecoin allows dust transactions
// t.vout[0].nValue = 501; // dust
// BOOST_CHECK(!IsStandardTx(t, reason));
t.vout[0].nValue = COIN; // not dust
BOOST_CHECK(IsStandardTx(t, reason));

View file

@ -1923,7 +1923,8 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
dPriority = wtxNew.ComputePriority(dPriority, nBytes);
// Can we complete this as a free transaction?
if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
// Dogecoin: Disable free transactions
/* if (fSendFreeTransactions && nBytes <= MAX_FREE_TRANSACTION_CREATE_SIZE)
{
// Not enough fee: enough priority?
double dPriorityNeeded = mempool.estimatePriority(nTxConfirmTarget);
@ -1934,7 +1935,7 @@ bool CWallet::CreateTransaction(const vector<CRecipient>& vecSend,
// Small enough, and priority high enough, to send for free
if (dPriorityNeeded > 0 && dPriority >= dPriorityNeeded)
break;
}
} */
CAmount nFeeNeeded = GetMinimumFee(txNew, nBytes, nTxConfirmTarget, mempool);
@ -2023,8 +2024,9 @@ CAmount CWallet::GetMinimumFee(const CMutableTransaction& tx, unsigned int nTxBy
if (fPayAtLeastCustomFee && nFeeNeeded > 0 && nFeeNeeded < payTxFee.GetFeePerK())
nFeeNeeded = payTxFee.GetFeePerK();
// User didn't set: use -txconfirmtarget to estimate...
if (nFeeNeeded == 0)
nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
// Dogecoin: Disable txconfirmtarget
//if (nFeeNeeded == 0)
// nFeeNeeded = pool.estimateFee(nConfirmTarget).GetFee(nTxBytes);
// ... unless we don't have enough mempool data, in which case fall
// back to a hard-coded fee
if (nFeeNeeded == 0) {

View file

@ -42,15 +42,15 @@ extern bool fPayAtLeastCustomFee;
//! -paytxfee default
static const CAmount DEFAULT_TRANSACTION_FEE = 0;
//! -paytxfee will warn if called with a higher fee than this amount (in satoshis) per KB
static const CAmount nHighTransactionFeeWarning = 10 * COIN;
static const CAmount nHighTransactionFeeWarning = 25 * COIN;
//! -maxtxfee default
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 100 * COIN;
static const CAmount DEFAULT_TRANSACTION_MAXFEE = 250 * COIN;
//! -txconfirmtarget default
static const unsigned int DEFAULT_TX_CONFIRM_TARGET = 2;
//! -maxtxfee will warn if called with a higher fee than this amount (in satoshis)
static const CAmount nHighTransactionMaxFeeWarning = 100 * nHighTransactionFeeWarning;
//! Largest (in bytes) free transaction we're willing to create
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 1000;
static const unsigned int MAX_FREE_TRANSACTION_CREATE_SIZE = 0;
class CAccountingEntry;
class CBlockIndex;