Skip to content

Commit d0a10c1

Browse files
committed
Merge pull request #6329
0c37634 acceptnonstdtxn option to skip (most) "non-standard transaction" checks, for testnet/regtest only (Luke Dashjr)
2 parents 5bd26ef + 0c37634 commit d0a10c1

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
@@ -394,6 +394,8 @@ std::string HelpMessage(HelpMessageMode mode)
394394
strUsage += HelpMessageOpt("-testnet", _("Use the test network"));
395395

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

@@ -817,6 +819,10 @@ bool AppInit2(boost::thread_group& threadGroup, CScheduler& scheduler)
817819
return InitError(strprintf(_("Invalid amount for -minrelaytxfee=<amount>: '%s'"), mapArgs["-minrelaytxfee"]));
818820
}
819821

822+
fRequireStandard = !GetBoolArg("-acceptnonstdtxn", !Params().RequireStandard());
823+
if (Params().RequireStandard() && !fRequireStandard)
824+
return InitError(strprintf("acceptnonstdtxn is not currently supported for %s chain", chainparams.NetworkIDString()));
825+
820826
#ifdef ENABLE_WALLET
821827
if (mapArgs.count("-mintxfee"))
822828
{

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;
@@ -900,7 +901,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
900901

901902
// Rather not work on nonstandard transactions (unless -testnet/-regtest)
902903
string reason;
903-
if (Params().RequireStandard() && !IsStandardTx(tx, reason))
904+
if (fRequireStandard && !IsStandardTx(tx, reason))
904905
return state.DoS(0,
905906
error("AcceptToMemoryPool: nonstandard transaction: %s", reason),
906907
REJECT_NONSTANDARD, reason);
@@ -971,7 +972,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
971972
}
972973

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

977978
// 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
@@ -111,6 +111,7 @@ extern bool fReindex;
111111
extern int nScriptCheckThreads;
112112
extern bool fTxIndex;
113113
extern bool fIsBareMultisigStd;
114+
extern bool fRequireStandard;
114115
extern bool fCheckBlockIndex;
115116
extern bool fCheckpointsEnabled;
116117
extern size_t nCoinCacheUsage;

0 commit comments

Comments
 (0)