Skip to content

Commit

Permalink
Merge pull request #619 from KomodoPlatform/patch-data-carrier
Browse files Browse the repository at this point in the history
fix datacarrier related command-line args
  • Loading branch information
ca333 committed Aug 19, 2024
2 parents 6697cef + a97380f commit 1ca3fe8
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 5 deletions.
7 changes: 5 additions & 2 deletions src/init.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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=<n>", strprintf(_("Set minimum block size in bytes (default: %u)"), 0));
Expand Down Expand Up @@ -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);
Expand Down
8 changes: 6 additions & 2 deletions src/script/standard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,8 @@ using namespace std;

typedef vector<unsigned char> 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()

Expand Down Expand Up @@ -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;
}

Expand Down
7 changes: 6 additions & 1 deletion src/script/standard.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,8 @@

#include <stdint.h>

static const bool DEFAULT_ACCEPT_DATACARRIER = true;

class CKeyID;
class CScript;

Expand All @@ -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;

/**
Expand Down

0 comments on commit 1ca3fe8

Please sign in to comment.