diff --git a/src/policy/policy.h b/src/policy/policy.h --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -86,7 +86,8 @@ SCRIPT_VERIFY_NULLDUMMY | SCRIPT_VERIFY_SIGPUSHONLY | SCRIPT_VERIFY_MINIMALDATA | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_NOPS | SCRIPT_VERIFY_CLEANSTACK | SCRIPT_VERIFY_CHECKLOCKTIMEVERIFY | - SCRIPT_VERIFY_CHECKSEQUENCEVERIFY | SCRIPT_VERIFY_CHECKDATASIG_SIGOPS; + SCRIPT_VERIFY_CHECKSEQUENCEVERIFY | SCRIPT_VERIFY_CHECKDATASIG_SIGOPS | + SCRIPT_DISALLOW_SEGWIT_RECOVERY; /** * For convenience, standard but not mandatory verify flags. diff --git a/src/validation.cpp b/src/validation.cpp --- a/src/validation.cpp +++ b/src/validation.cpp @@ -722,10 +722,6 @@ extraFlags |= SCRIPT_ENABLE_SCHNORR; } - if (fRequireStandard) { - extraFlags |= SCRIPT_DISALLOW_SEGWIT_RECOVERY; - } - // Make sure whatever we need to activate is actually activated. const uint32_t scriptVerifyFlags = STANDARD_SCRIPT_VERIFY_FLAGS | extraFlags; @@ -1239,14 +1235,8 @@ // This differs from MANDATORY_SCRIPT_VERIFY_FLAGS as it contains // additional upgrade flags (see AcceptToMemoryPoolWorker variable // extraFlags). - // Although it is not (currently) a standard flag, - // SCRIPT_ALLOW_SEGWIT_RECOVERY is treated similarly to the - // set of standard-not-mandatory flags. It needs to be removed in - // order to check if we need to penalize, but not ban, the peer that - // sent us the transaction. - uint32_t mandatoryFlags = flags & - ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS & - ~SCRIPT_DISALLOW_SEGWIT_RECOVERY; + uint32_t mandatoryFlags = + flags & ~STANDARD_NOT_MANDATORY_VERIFY_FLAGS; if (flags != mandatoryFlags) { // Check whether the failure was caused by a non-mandatory // script verification check. If so, don't trigger DoS diff --git a/test/functional/abc-segwit-recovery.py b/test/functional/abc-segwit-recovery.py --- a/test/functional/abc-segwit-recovery.py +++ b/test/functional/abc-segwit-recovery.py @@ -71,8 +71,10 @@ self.tip = None self.blocks = {} # We have 2 nodes: - # 1) node_nonstd (nodes[0]) accepts non-standard txns. We check it - # accepts segwit spending txns. + # 1) node_nonstd (nodes[0]) accepts non-standard txns. It does not + # accept Segwit recovery transactions, since it is included in + # standard flags, and transactions that violate these flags are + # never accepted into the mempool. # 2) node_std (nodes[1]) doesn't accept non-standard txns and # doesn't have us whitelisted. It's used to test for bans, as we # connect directly to it via mininode and send a segwit spending @@ -284,11 +286,12 @@ check_for_no_ban_on_rejected_tx(txspend, 64, CLEANSTACK_ERROR) check_for_no_ban_on_rejected_tx(txspend_case0, 64, EVAL_FALSE_ERROR) - # Segwit spending txns are accepted in the mempool of nodes not checking - # for standardness, but rejected in nodes that check. - node_nonstd.sendrawtransaction(ToHex(txspend)) - node_nonstd.sendrawtransaction(ToHex(txspend_case0)) - check_mempool_equal(node_nonstd, [txspend, txspend_case0]) + # Segwit recovery txns are never accepted into the mempool, + # as they are included in standard flags. + assert_raises_rpc_error(-26, RPC_CLEANSTACK_ERROR, + node_nonstd.sendrawtransaction, ToHex(txspend)) + assert_raises_rpc_error(-26, RPC_EVAL_FALSE_ERROR, + node_nonstd.sendrawtransaction, ToHex(txspend_case0)) assert_raises_rpc_error(-26, RPC_CLEANSTACK_ERROR, node_std.sendrawtransaction, ToHex(txspend)) assert_raises_rpc_error(-26, RPC_EVAL_FALSE_ERROR,