diff --git a/src/init.cpp b/src/init.cpp index 734a797fa3a..b2f07a2d1e2 100644 --- a/src/init.cpp +++ b/src/init.cpp @@ -535,8 +535,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)); @@ -1348,6 +1348,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..f7219cc111e 100644 --- a/src/script/standard.cpp +++ b/src/script/standard.cpp @@ -32,7 +32,8 @@ using namespace std; typedef vector valtype; -unsigned nMaxDatacarrierBytes = MAX_OP_RETURN_RELAY; +bool fAcceptDatacarrier = DEFAULT_ACCEPT_DATACARRIER; +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() @@ -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..fb315322549 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; @@ -40,7 +42,10 @@ 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 */ + +extern bool fAcceptDatacarrier; extern unsigned nMaxDatacarrierBytes; /**