From 6fb6a2e2b679bdc31be46db85ade4b4a16ce8adc Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Fri, 24 May 2024 22:33:03 +0200 Subject: [PATCH 1/2] fix datacarrier related command-line args --- src/init.cpp | 7 +++++-- src/script/standard.cpp | 6 +++++- src/script/standard.h | 7 +++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/src/init.cpp b/src/init.cpp index 9b2ea04b034..40727ceee3e 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -537,8 +537,8 @@ std::string HelpMessage(HelpMessageMode mode) strUsage += HelpMessageOpt("-testnet", _("Use the test network")); strUsage += HelpMessageGroup(_("Node relay options:")); - strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), 1)); - strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY)); + strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), DEFAULT_ACCEPT_DATACARRIER)); + strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default for KMD: %u, for ACs: %u)"), MAX_OP_RETURN_RELAY_KMD, MAX_OP_RETURN_RELAY_AC)); strUsage += HelpMessageGroup(_("Block creation options:")); strUsage += HelpMessageOpt("-blockminsize=", strprintf(_("Set minimum block size in bytes (default: %u)"), 0)); @@ -1361,6 +1361,9 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler) #endif // ENABLE_WALLET fIsBareMultisigStd = GetBoolArg("-permitbaremultisig", true); + + fAcceptDatacarrier = GetBoolArg("-datacarrier", DEFAULT_ACCEPT_DATACARRIER); + nMaxDatacarrierBytes = chainName.isKMD() ? MAX_OP_RETURN_RELAY_KMD : MAX_OP_RETURN_RELAY_AC; nMaxDatacarrierBytes = GetArg("-datacarriersize", nMaxDatacarrierBytes); fAlerts = GetBoolArg("-alerts", DEFAULT_ALERTS); diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 2e547d9234b..12f6df4f52b 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -32,6 +32,7 @@ using namespace std; typedef vector valtype; +bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY; bool komodo_is_vSolutionsFixActive(); // didn't want to bring komodo headers here, it's a special case to bypass bad code in Solver() and ExtractDestination() @@ -346,7 +347,10 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) return false; if (m < 1 || m > n) return false; - } + } else if (whichType == TX_NULL_DATA && + (!fAcceptDatacarrier || scriptPubKey.size() > nMaxDatacarrierBytes)) + return false; + return whichType != TX_NONSTANDARD; } diff --git a/src/script/standard.h b/src/script/standard.h index 2eb1f40ce4e..5756b841d9f 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -28,6 +28,8 @@ #include +static const bool DEFAULT_ACCEPT_DATACARRIER = true; + class CKeyID; class CScript; @@ -41,6 +43,11 @@ class CScriptID : public uint160 }; static const unsigned int MAX_OP_RETURN_RELAY = 8192; //! bytes + +static const unsigned int MAX_OP_RETURN_RELAY_KMD = 140; /* 76 bytes of nota size + 64 bytes chain name */ +static const unsigned int MAX_OP_RETURN_RELAY_AC = 208; /* 144 bytes of nota size + 64 bytes chain name */ + +extern bool fAcceptDatacarrier; extern unsigned nMaxDatacarrierBytes; /** From a97380f485b9bf794ca9d07470dfe08a9ab1ba32 Mon Sep 17 00:00:00 2001 From: DeckerSU Date: Thu, 13 Jun 2024 19:49:16 +0200 Subject: [PATCH 2/2] get rid of unused MAX_OP_RETURN_RELAY --- src/script/standard.cpp | 2 +- src/script/standard.h | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/src/script/standard.cpp b/src/script/standard.cpp index 12f6df4f52b..f7219cc111e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -33,7 +33,7 @@ using namespace std; typedef vector valtype; bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; -unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY; +unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY_KMD; bool komodo_is_vSolutionsFixActive(); // didn't want to bring komodo headers here, it's a special case to bypass bad code in Solver() and ExtractDestination() diff --git a/src/script/standard.h b/src/script/standard.h index 5756b841d9f..fb315322549 100644 --- a/src/script/standard.h +++ b/src/script/standard.h @@ -42,8 +42,6 @@ class CScriptID : public uint160 CScriptID(const uint160& in) : uint160(in) {} }; -static const unsigned int MAX_OP_RETURN_RELAY = 8192; //! bytes - static const unsigned int MAX_OP_RETURN_RELAY_KMD = 140; /* 76 bytes of nota size + 64 bytes chain name */ static const unsigned int MAX_OP_RETURN_RELAY_AC = 208; /* 144 bytes of nota size + 64 bytes chain name */