Skip to content

Commit

Permalink
Add RequireStandard chain parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
jtimon committed Jun 4, 2014
1 parent 21913a9 commit cfeb823
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 2 deletions.
2 changes: 2 additions & 0 deletions src/chainparams.cpp
Expand Up @@ -226,6 +226,7 @@ class CTestNetParams : public CMainParams {
}

virtual bool AllowMinDifficultyBlocks() const { return true; }
virtual bool RequireStandard() const { return false; }
virtual Network NetworkID() const { return CChainParams::TESTNET; }
};
static CTestNetParams testNetParams;
Expand Down Expand Up @@ -262,6 +263,7 @@ class CRegTestParams : public CTestNetParams {
virtual bool MiningRequiresPeers() const { return false; }
virtual bool MineBlocksOnDemand() const { return true; }
virtual bool DefaultCheckMemPool() const { return true; }
virtual bool RequireStandard() const { return false; }
virtual Network NetworkID() const { return CChainParams::REGTEST; }
};
static CRegTestParams regTestParams;
Expand Down
2 changes: 2 additions & 0 deletions src/chainparams.h
Expand Up @@ -72,6 +72,8 @@ class CChainParams
virtual bool DefaultCheckMemPool() const { return false; }
/* Allow mining of a min-difficulty block */
virtual bool AllowMinDifficultyBlocks() const { return false; }
/* Make standard checks */
virtual bool RequireStandard() const { return true; }
const string& DataDir() const { return strDataDir; }
/* Make miner stop after a block is found. In RPC, don't return
* until nGenProcLimit blocks are generated */
Expand Down
4 changes: 2 additions & 2 deletions src/main.cpp
Expand Up @@ -833,7 +833,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa

// Rather not work on nonstandard transactions (unless -testnet/-regtest)
string reason;
if (Params().NetworkID() == CChainParams::MAIN && !IsStandardTx(tx, reason))
if (Params().RequireStandard() && !IsStandardTx(tx, reason))
return state.DoS(0,
error("AcceptToMemoryPool : nonstandard transaction: %s", reason),
REJECT_NONSTANDARD, reason);
Expand Down Expand Up @@ -894,7 +894,7 @@ bool AcceptToMemoryPool(CTxMemPool& pool, CValidationState &state, const CTransa
}

// Check for non-standard pay-to-script-hash in inputs
if (Params().NetworkID() == CChainParams::MAIN && !AreInputsStandard(tx, view))
if (Params().RequireStandard() && !AreInputsStandard(tx, view))
return error("AcceptToMemoryPool: : nonstandard transaction input");

// Note: if you modify this code to accept non-standard transactions, then
Expand Down

0 comments on commit cfeb823

Please sign in to comment.