From e748772fff87929366f707742cee3bb3cc0fe11b Mon Sep 17 00:00:00 2001 From: Duke Date: Sat, 17 May 2025 10:23:51 -0400 Subject: [PATCH] Validate -ac_minopreturnfee as a consensus rule --- src/main.cpp | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/src/main.cpp b/src/main.cpp index 513413421..ff3c3ea64 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -2678,6 +2678,31 @@ namespace Consensus { if (!MoneyRange(nFees)) return state.DoS(100, error("CheckInputs(): nFees out of range"), REJECT_INVALID, "bad-txns-fee-outofrange"); + + //NOTE: Since we have access to fee here, verify that opreturn pays + //required minimum fee, even though this is a check on outputs not + //inputs. If we don't do it here we would need to duplicate already + //done work somewhere else + + if ( ASSETCHAINS_MINOPRETURNFEE > 0 ) { + BOOST_FOREACH(const CTxOut& txout, tx.vout) { + const bool isopret = txout.scriptPubKey.IsOpReturn(); + + // HUSH+DRGX do not use -ac_minopreturnfee so this does not (yet) + // affect those chains, they will need a height activated consensus + // change + + if ( isopret ) { + // Is there any difference between nTxFee and nFees ? + // They seem to be 2 vars with the same value + fprintf(stderr,"%s: opreturn=1 nFees=%ld nTxFee=%ld\n", __func__, nFees, nTxFee); + if (nTxFee < ASSETCHAINS_MINOPRETURNFEE) { + return state.DoS(100,error("CheckInputs(): tx does not have required mininum fee for OP_RETURN"), REJECT_INVALID, "bad-txns-minopreturnfee"); + } + } + } + } + return true; } }// namespace Consensus