Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 3 additions & 6 deletions src/policy/policy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<std::vector<unsigned char> > vSolutions;
if (!Solver(scriptPubKey, whichType, vSolutions))
Expand All @@ -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";
Expand All @@ -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;
}
Expand Down
4 changes: 2 additions & 2 deletions src/policy/policy.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/rpc/mining.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 1 addition & 1 deletion src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps remove witnessEnabled var and the -prematurewitness option above too?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

d'oh, thought I did, will do

return state.DoS(0, false, REJECT_NONSTANDARD, reason);

// Only accept nLockTime-using transactions that can be mined in the next
Expand Down