diff --git a/src/dogecoin-fees.cpp b/src/dogecoin-fees.cpp index 28e25b5a0..f13bd8d57 100644 --- a/src/dogecoin-fees.cpp +++ b/src/dogecoin-fees.cpp @@ -92,7 +92,7 @@ CAmount GetDogecoinMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool } CAmount nMinFee = ::minRelayTxFeeRate.GetFee(nBytes); - nMinFee += GetDogecoinDustFee(tx.vout, ::minRelayTxFeeRate); + nMinFee += GetDogecoinDustFee(tx.vout, nDustLimit, ::minRelayTxFeeRate); if (fAllowFree) { @@ -109,12 +109,12 @@ CAmount GetDogecoinMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool return nMinFee; } -CAmount GetDogecoinDustFee(const std::vector &vout, CFeeRate &baseFeeRate) { +CAmount GetDogecoinDustFee(const std::vector &vout, const CAmount dustLimit, CFeeRate &baseFeeRate) { CAmount nFee = 0; - // To limit dust spam, add base fee for each output less than a COIN + // To limit dust spam, add base fee for each output less than the (soft) dustlimit BOOST_FOREACH(const CTxOut& txout, vout) - if (txout.IsDust(::minRelayTxFeeRate)) + if (txout.IsDust(dustLimit)) nFee += baseFeeRate.GetFeePerK(); return nFee; diff --git a/src/dogecoin-fees.h b/src/dogecoin-fees.h index b8f98b69b..447761490 100644 --- a/src/dogecoin-fees.h +++ b/src/dogecoin-fees.h @@ -28,6 +28,6 @@ CFeeRate GetDogecoinWalletFeeRate(); CAmount GetDogecoinMinWalletFee(unsigned int nBytes_); #endif // ENABLE_WALLET CAmount GetDogecoinMinRelayFee(const CTransaction& tx, unsigned int nBytes, bool fAllowFree); -CAmount GetDogecoinDustFee(const std::vector &vout, CFeeRate &baseFeeRate); +CAmount GetDogecoinDustFee(const std::vector &vout, const CAmount dustLimit, CFeeRate &baseFeeRate); #endif // BITCOIN_DOGECOIN_FEES_H diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 506eb6f17..85d03a52a 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -105,7 +105,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes else if ((whichType == TX_MULTISIG) && (!fIsBareMultisigStd)) { reason = "bare-multisig"; return false; - } else if (txout.IsDust(dustRelayFee)) { + } else if (txout.IsDust(nDustLimit)) { reason = "dust"; return false; } diff --git a/src/primitives/transaction.h b/src/primitives/transaction.h index 63e34697a..26c12a83c 100644 --- a/src/primitives/transaction.h +++ b/src/primitives/transaction.h @@ -206,6 +206,15 @@ public: return (nValue < GetDustThreshold(minRelayTxFeeRate)); } + // Dogecoin: allow comparison against different dustlimit parameters + bool IsDust(const CAmount dustLimit) const + { + if (scriptPubKey.IsUnspendable()) + return false; + + return (nValue < dustLimit); + } + friend bool operator==(const CTxOut& a, const CTxOut& b) { return (a.nValue == b.nValue && diff --git a/src/wallet/wallet.cpp b/src/wallet/wallet.cpp index 1beeb4362..45639b11c 100644 --- a/src/wallet/wallet.cpp +++ b/src/wallet/wallet.cpp @@ -2853,7 +2853,7 @@ bool CWallet::AddAccountingEntry(const CAccountingEntry& acentry, CWalletDB *pwa CAmount CWallet::GetRequiredFee(const CMutableTransaction& tx, unsigned int nTxBytes) { // Dogecoin: Add an increased fee for each dust output - return std::max(minTxFee.GetFee(nTxBytes) + GetDogecoinDustFee(tx.vout, minTxFee), ::minRelayTxFeeRate.GetFee(nTxBytes)); + return std::max(minTxFee.GetFee(nTxBytes) + GetDogecoinDustFee(tx.vout, nDustLimit, minTxFee), ::minRelayTxFeeRate.GetFee(nTxBytes)); } CAmount CWallet::GetRequiredFee(unsigned int nTxBytes)