diff options
author | glozow <gloriajzhao@gmail.com> | 2021-08-11 15:51:41 +0100 |
---|---|---|
committer | glozow <gloriajzhao@gmail.com> | 2021-09-02 16:23:27 +0100 |
commit | ac761f0a23c9c469fa00885edf3d5c9ae7c6a2b3 (patch) | |
tree | 02267b82f3a9754be5d06e6769b1f8d70c129af4 /src/policy/rbf.cpp | |
parent | 9c2f9f89846264b503d5573341bb78cf609cbc5e (diff) |
MOVEONLY: fee checks (Rules 3 and 4) to policy/rbf
Diffstat (limited to 'src/policy/rbf.cpp')
-rw-r--r-- | src/policy/rbf.cpp | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/src/policy/rbf.cpp b/src/policy/rbf.cpp index 5d1db6b58d..1e03e2331a 100644 --- a/src/policy/rbf.cpp +++ b/src/policy/rbf.cpp @@ -161,3 +161,29 @@ std::optional<std::string> PaysMoreThanConflicts(const CTxMemPool::setEntries& s return std::nullopt; } +std::optional<std::string> PaysForRBF(CAmount nConflictingFees, + CAmount nModifiedFees, + size_t nSize, + const uint256& hash) +{ + // The replacement must pay greater fees than the transactions it + // replaces - if we did the bandwidth used by those conflicting + // transactions would not be paid for. + if (nModifiedFees < nConflictingFees) + { + return strprintf("rejecting replacement %s, less fees than conflicting txs; %s < %s", + hash.ToString(), FormatMoney(nModifiedFees), FormatMoney(nConflictingFees)); + } + + // Finally in addition to paying more fees than the conflicts the + // new transaction must pay for its own bandwidth. + CAmount nDeltaFees = nModifiedFees - nConflictingFees; + if (nDeltaFees < ::incrementalRelayFee.GetFee(nSize)) + { + return strprintf("rejecting replacement %s, not enough additional fees to relay; %s < %s", + hash.ToString(), + FormatMoney(nDeltaFees), + FormatMoney(::incrementalRelayFee.GetFee(nSize))); + } + return std::nullopt; +} |