diff --git a/src/consensus/tx_verify.cpp b/src/consensus/tx_verify.cpp --- a/src/consensus/tx_verify.cpp +++ b/src/consensus/tx_verify.cpp @@ -153,31 +153,12 @@ } uint64_t GetSigOpCountWithoutP2SH(const CTransaction &tx, uint32_t flags) { - uint64_t nSigOps = 0; - for (const auto &txin : tx.vin) { - nSigOps += txin.scriptSig.GetSigOpCount(flags, false); - } - for (const auto &txout : tx.vout) { - nSigOps += txout.scriptPubKey.GetSigOpCount(flags, false); - } - return nSigOps; + return 0; } uint64_t GetP2SHSigOpCount(const CTransaction &tx, const CCoinsViewCache &view, uint32_t flags) { - if ((flags & SCRIPT_VERIFY_P2SH) == 0 || tx.IsCoinBase()) { - return 0; - } - - uint64_t nSigOps = 0; - for (auto &i : tx.vin) { - const CTxOut &prevout = view.GetOutputFor(i); - if (prevout.scriptPubKey.IsPayToScriptHash()) { - nSigOps += prevout.scriptPubKey.GetSigOpCount(flags, i.scriptSig); - } - } - - return nSigOps; + return 0; } uint64_t GetTransactionSigOpCount(const CTransaction &tx, diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -43,10 +43,6 @@ */ static const unsigned int MAX_TX_IN_SCRIPT_SIG_SIZE = 1650; -/** - * Maximum number of signature check operations in an IsStandard() P2SH script. - */ -static const unsigned int MAX_P2SH_SIGOPS = 15; /** * The maximum number of sigops we're willing to relay/mine in a single tx. */ diff --git a/src/policy/policy.cpp b/src/policy/policy.cpp --- a/src/policy/policy.cpp +++ b/src/policy/policy.cpp @@ -154,11 +154,6 @@ txnouttype whichType = Solver(prev.scriptPubKey, vSolutions); if (whichType == TX_NONSTANDARD) { return false; - } else if (whichType == TX_SCRIPTHASH) { - if (prev.scriptPubKey.GetSigOpCount(flags, in.scriptSig) > - MAX_P2SH_SIGOPS) { - return false; - } } } diff --git a/src/script/script.h b/src/script/script.h --- a/src/script/script.h +++ b/src/script/script.h @@ -546,20 +546,6 @@ return (opcodetype)(OP_1 + n - 1); } - /** - * Pre-version-0.6, Bitcoin always counted CHECKMULTISIGs as 20 sigops. With - * pay-to-script-hash, that changed: CHECKMULTISIGs serialized in scriptSigs - * are counted more accurately, assuming they are of the form - * ... OP_N CHECKMULTISIG ... - */ - uint32_t GetSigOpCount(uint32_t flags, bool fAccurate) const; - - /** - * Accurately count sigOps, including sigOps in pay-to-script-hash - * transactions: - */ - uint32_t GetSigOpCount(uint32_t flags, const CScript &scriptSig) const; - bool IsPayToScriptHash() const; bool IsCommitment(const std::vector &data) const; bool IsWitnessProgram(int &version, std::vector &program) const; diff --git a/src/script/script.cpp b/src/script/script.cpp --- a/src/script/script.cpp +++ b/src/script/script.cpp @@ -370,36 +370,6 @@ return true; } -uint32_t CScript::GetSigOpCount(uint32_t flags, bool fAccurate) const { - return 0; -} - -uint32_t CScript::GetSigOpCount(uint32_t flags, - const CScript &scriptSig) const { - if ((flags & SCRIPT_VERIFY_P2SH) == 0 || !IsPayToScriptHash()) { - return GetSigOpCount(flags, true); - } - - // This is a pay-to-script-hash scriptPubKey; - // get the last item that the scriptSig - // pushes onto the stack: - const_iterator pc = scriptSig.begin(); - std::vector vData; - while (pc < scriptSig.end()) { - opcodetype opcode; - if (!scriptSig.GetOp(pc, opcode, vData)) { - return 0; - } - if (opcode > OP_16) { - return 0; - } - } - - /// ... and return its opcount: - CScript subscript(vData.begin(), vData.end()); - return subscript.GetSigOpCount(flags, true); -} - bool CScript::IsPayToScriptHash() const { // Extra-fast test for pay-to-script-hash CScripts: return (this->size() == 23 && (*this)[0] == OP_HASH160 && diff --git a/src/test/script_p2sh_tests.cpp b/src/test/script_p2sh_tests.cpp --- a/src/test/script_p2sh_tests.cpp +++ b/src/test/script_p2sh_tests.cpp @@ -331,7 +331,7 @@ } CMutableTransaction txFrom; - txFrom.vout.resize(7); + txFrom.vout.resize(4); // First three are standard: CScript pay1 = GetScriptForDestination(key[0].GetPubKey().GetID()); @@ -363,32 +363,6 @@ txFrom.vout[3].scriptPubKey = GetScriptForDestination(CScriptID(oneAndTwo)); txFrom.vout[3].nValue = 4000 * SATOSHI; - // vout[4] is max sigops: - CScript fifteenSigops; - fifteenSigops << OP_1; - for (unsigned i = 0; i < MAX_P2SH_SIGOPS; i++) { - fifteenSigops << ToByteVector(key[i % 3].GetPubKey()); - } - fifteenSigops << OP_15 << OP_CHECKMULTISIG; - keystore.AddCScript(fifteenSigops); - txFrom.vout[4].scriptPubKey = - GetScriptForDestination(CScriptID(fifteenSigops)); - txFrom.vout[4].nValue = 5000 * SATOSHI; - - // vout[5/6] are non-standard because they exceed MAX_P2SH_SIGOPS - CScript sixteenSigops; - sixteenSigops << OP_16 << OP_CHECKMULTISIG; - keystore.AddCScript(sixteenSigops); - txFrom.vout[5].scriptPubKey = - GetScriptForDestination(CScriptID(sixteenSigops)); - txFrom.vout[5].nValue = 5000 * SATOSHI; - CScript twentySigops; - twentySigops << OP_CHECKMULTISIG; - keystore.AddCScript(twentySigops); - txFrom.vout[6].scriptPubKey = - GetScriptForDestination(CScriptID(twentySigops)); - txFrom.vout[6].nValue = 6000 * SATOSHI; - AddCoins(coins, CTransaction(txFrom), 0); CMutableTransaction txTo;