Skip to content

Commit 0c37634

Browse files
committed
acceptnonstdtxn option to skip (most) "non-standard transaction" checks, for testnet/regtest only
1 parent 9b5659d commit 0c37634

File tree

3 files changed

+10
-2
lines changed

3 files changed

+10
-2
lines changed

src/init.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -395,6 +395,8 @@ std::string HelpMessage(HelpMessageMode mode)
395395
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
396396

397397
strUsage += HelpMessageGroup(_("Node relay options:"));
398+
if (showDebug)
399+
strUsage += HelpMessageOpt("-acceptnonstdtxn", strprintf("Relay and mine \"non-standard\" transactions (%sdefault: %u)", "testnet/regtest only; ", !Params(CBaseChainParams::TESTNET).RequireStandard()));
398400
strUsage += HelpMessageOpt("-datacarrier", strprintf(_("Relay and mine data carrier transactions (default: %u)"), 1));
399401
strUsage += HelpMessageOpt("-datacarriersize", strprintf(_("Maximum size of data in data carrier transactions we relay and mine (default: %u)"), MAX_OP_RETURN_RELAY));
400402

@@ -803,6 +805,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
803805
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
804806
}
805807

808+
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard());
809+
if (Params().RequireStandard() && !fRequireStandard)
810+
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
811+
806812
#ifdef ENABLE_WALLET
807813
if (mapArgs.count("-mintxfee"))
808814
{

src/main.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ bool fTxIndex = false;
5757
bool fHavePruned = false;
5858
bool fPruneMode = false;
5959
bool fIsBareMultisigStd = true;
60+
bool fRequireStandard = true;
6061
bool fCheckBlockIndex = false;
6162
bool fCheckpointsEnabled = true;
6263
size_t nCoinCacheUsage = 5000 * 300;
@@ -898,7 +899,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
898899

899900
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
900901
string reason;
901-
if (Params().RequireStandard() && !IsStandardTx(tx, reason))
902+
if (fRequireStandard && !IsStandardTx(tx, reason))
902903
return state.DoS(0,
903904
error("AcceptToMemoryPool: nonstandard transaction: %s", reason),
904905
REJECT_NONSTANDARD, reason);
@@ -969,7 +970,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
969970
}
970971

971972
// Check for non-standard pay-to-script-hash in inputs
972-
if (Params().RequireStandard() && !AreInputsStandard(tx, view))
973+
if (fRequireStandard && !AreInputsStandard(tx, view))
973974
return error("AcceptToMemoryPool: nonstandard transaction input");
974975

975976
// Check that the transaction doesn't have an excessive number of

src/main.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ extern bool fReindex;
109109
extern int nScriptCheckThreads;
110110
extern bool fTxIndex;
111111
extern bool fIsBareMultisigStd;
112+
extern bool fRequireStandard;
112113
extern bool fCheckBlockIndex;
113114
extern bool fCheckpointsEnabled;
114115
extern size_t nCoinCacheUsage;

0 commit comments

Comments
 (0)