Merge branch 'opreturnfee' into dev

This commit is contained in:
Duke
2025-05-07 11:20:35 -04:00

View File

@@ -475,36 +475,6 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
// fprintf(stderr,"%s: nTxSize = %u\n", __func__, nTxSize);
// Opret spam limits
const bool opretminfee = true;
if (opretminfee)
{
CFeeRate opretMinFeeRate = CFeeRate(10000000); // default opretMinFeeRate 0.1 HUSH
bool fSpamTx = false;
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
unsigned int nTxOpretSize = 0;
// calc total oprets size
BOOST_FOREACH(const CTxOut& txout, tx.vout) {
if (txout.scriptPubKey.IsOpReturn()) {
CScript::const_iterator it = txout.scriptPubKey.begin() + 1;
opcodetype op;
std::vector<uint8_t> opretData;
if (txout.scriptPubKey.GetOp(it, op, opretData)) {
//std::cerr << HexStr(opretData.begin(), opretData.end()) << std::endl;
nTxOpretSize += opretData.size();
}
}
}
if (feeRate < opretMinFeeRate) {
fSpamTx = true;
std::cerr << __func__ << ": " << tx.GetHash().ToString() << " nTxSize=" << nTxSize << " nTxOpretSize=" << nTxOpretSize << " feeRate=" << feeRate.ToString() << " opretMinFeeRate=" << opretMinFeeRate.ToString() << " fSpamTx=" << fSpamTx << std::endl;
continue;
}
// std::cerr << tx.GetHash().ToString() << " vecPriority.size() = " << vecPriority.size() << std::endl;
}
if (nBlockSize + nTxSize >= nBlockMaxSize-512) // room for extra autotx
{
@@ -548,6 +518,35 @@ CBlockTemplate* CreateNewBlock(CPubKey _pk,const CScript& _scriptPubKeyIn, int32
}
CAmount nTxFees = view.GetValueIn(chainActive.LastTip()->GetHeight(),&interest,tx,chainActive.LastTip()->nTime)-tx.GetValueOut();
// Opret spam limits
CAmount opretMinFee = 1 * COIN;
{
bool fSpamTx = false;
unsigned int nTxSize = ::GetSerializeSize(tx, SER_NETWORK, PROTOCOL_VERSION);
unsigned int nTxOpretSize = 0;
// calc total oprets size
BOOST_FOREACH(const CTxOut& txout, tx.vout) {
if (txout.scriptPubKey.IsOpReturn()) {
CScript::const_iterator it = txout.scriptPubKey.begin() + 1;
opcodetype op;
std::vector<uint8_t> opretData;
if (txout.scriptPubKey.GetOp(it, op, opretData)) {
//std::cerr << HexStr(opretData.begin(), opretData.end()) << std::endl;
nTxOpretSize += opretData.size();
}
}
}
if (nTxOpretSize > 0 && nTxFees < opretMinFee) {
fSpamTx = true;
std::cerr << __func__ << ": " << tx.GetHash().ToString() << " nTxSize=" << nTxSize << " nTxOpretSize=" << nTxOpretSize << " feeRate=" << feeRate.ToString() << " opretMinFee=" << opretMinFee << " nTxFees=" << nTxFees <<" fSpamTx=" << fSpamTx << std::endl;
continue;
}
// std::cerr << tx.GetHash().ToString() << " vecPriority.size() = " << vecPriority.size() << std::endl;
}
nTxSigOps += GetP2SHSigOpCount(tx, view);
if (nBlockSigOps + nTxSigOps >= MAX_BLOCK_SIGOPS-1)
{