From b8ba4ebee7affbb475f6aa5bc0a236c4f6e0a8a9 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 13 Mar 2018 11:59:44 -0400 Subject: [PATCH 1/2] don't enforce standardness on coinbase --- src/rpc/mining.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/rpc/mining.cpp b/src/rpc/mining.cpp index 4b6158f8bb6..2fa8ebc59bb 100644 --- a/src/rpc/mining.cpp +++ b/src/rpc/mining.cpp @@ -377,6 +377,7 @@ UniValue testproposedblock(const JSONRPCRequest& request) if ((!request.params[1].isNull() && !request.params[1].get_bool()) || (request.params[1].isNull() && !GetBoolArg("-acceptnonstdtxn", !chainparams.RequireStandard()))) { for (auto& transaction : block.vtx) { + if (transaction->IsCoinBase()) continue; std::string reason; if (!IsStandardTx(*transaction, reason)) { throw JSONRPCError(RPC_VERIFY_ERROR, "Block proposal included a non-standard transaction: " + reason); From fa34426ab1146b602ea021ae8a5c1899fd738147 Mon Sep 17 00:00:00 2001 From: Gregory Sanders Date: Tue, 13 Mar 2018 12:20:07 -0400 Subject: [PATCH 2/2] remove witnessEnabled standardness logic --- src/policy/policy.cpp | 9 +++------ src/policy/policy.h | 4 ++-- src/validation.cpp | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp index 15ff49d3ccb..e55a241ed31 100644 --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -33,7 +33,7 @@ CAsset policyAsset; * DUP CHECKSIG DROP ... repeated 100 times... OP_1 */ -bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType, const bool witnessEnabled) +bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType) { std::vector > vSolutions; if (!Solver(scriptPubKey, whichType, vSolutions)) @@ -54,13 +54,10 @@ bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType, const bool w else if (whichType == TX_TRUE) return false; - else if (!witnessEnabled && (whichType == TX_WITNESS_V0_KEYHASH || whichType == TX_WITNESS_V0_SCRIPTHASH)) - return false; - return whichType != TX_NONSTANDARD; } -bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnessEnabled) +bool IsStandardTx(const CTransaction& tx, std::string& reason) { if (tx.nVersion > CTransaction::MAX_STANDARD_VERSION || tx.nVersion < 1) { reason = "version"; @@ -87,7 +84,7 @@ bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnes txnouttype whichType; BOOST_FOREACH(const CTxOut& txout, tx.vout) { - if (!::IsStandard(txout.scriptPubKey, whichType, witnessEnabled) && !txout.IsFee()) { + if (!::IsStandard(txout.scriptPubKey, whichType) && !txout.IsFee()) { reason = "scriptpubkey"; return false; } diff --git a/src/policy/policy.h b/src/policy/policy.h index c9b9a75b593..0fab24c0261 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -77,12 +77,12 @@ static const unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_ static const unsigned int STANDARD_LOCKTIME_VERIFY_FLAGS = LOCKTIME_VERIFY_SEQUENCE | LOCKTIME_MEDIAN_TIME_PAST; -bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType, const bool witnessEnabled = false); +bool IsStandard(const CScript& scriptPubKey, txnouttype& whichType); /** * Check for standard transaction types * @return True if all outputs (scriptPubKeys) use only standard transaction forms */ -bool IsStandardTx(const CTransaction& tx, std::string& reason, const bool witnessEnabled = false); +bool IsStandardTx(const CTransaction& tx, std::string& reason); /** * Check for standard transaction types * @param[in] mapInputs Map of previous transactions that have outputs we're spending diff --git a/src/validation.cpp b/src/validation.cpp index 4f6a318e412..99d76246c9c 100644 --- a/src/validation.cpp +++ b/src/validation.cpp @@ -1075,7 +1075,7 @@ bool AcceptToMemoryPoolWorker(CTxMemPool& pool, CValidationState& state, const C // Rather not work on nonstandard transactions (unless -testnet/-regtest) std::string reason; - if (fRequireStandard && !IsStandardTx(tx, reason, witnessEnabled)) + if (fRequireStandard && !IsStandardTx(tx, reason)) return state.DoS(0, false, REJECT_NONSTANDARD, reason); // Only accept nLockTime-using transactions that can be mined in the next