mirror of
https://github.com/dogecoin/dogecoin.git
synced 2026-02-18 11:18:39 +00:00
fees: Allow dust comparison against a given dust limit
Prepares for having more than one dust limit configured, yet allowing the same function to return whether or not an output is dust. Implements the check with nDustLimit (-dustlimit) for relay related queries, and - for lack of alternatives - uses the same parameter for CWallet::GetRequiredFee until a wallet-specific dust limit is introduced
This commit is contained in:
parent
c05cd54411
commit
e83ddb7e8f
@ -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<CTxOut> &vout, CFeeRate &baseFeeRate) {
|
||||
CAmount GetDogecoinDustFee(const std::vector<CTxOut> &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;
|
||||
|
||||
@ -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<CTxOut> &vout, CFeeRate &baseFeeRate);
|
||||
CAmount GetDogecoinDustFee(const std::vector<CTxOut> &vout, const CAmount dustLimit, CFeeRate &baseFeeRate);
|
||||
|
||||
#endif // BITCOIN_DOGECOIN_FEES_H
|
||||
|
||||
@ -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;
|
||||
}
|
||||
|
||||
@ -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 &&
|
||||
|
||||
@ -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)
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user