Validate -ac_minopreturnfee as a consensus rule

This commit is contained in:
Duke
2025-05-17 10:23:51 -04:00
parent dd4aac4f5f
commit e748772fff

View File

@@ -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