From 9dabfe49c066301ef75bcfcb089fd308366127c4 Mon Sep 17 00:00:00 2001 From: Johnson Lau Date: Fri, 27 Apr 2018 03:56:29 +0800 Subject: Add constant scriptCode policy in non-segwit scripts This disables OP_CODESEPARATOR in non-segwit scripts (even in an unexecuted branch), and makes a positive FindAndDelete result invalid. This ensures that the scriptCode serialized in SignatureHash() is always the same as the script passing to the EvalScript. --- src/policy/policy.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/policy') diff --git a/src/policy/policy.h b/src/policy/policy.h index e4eda4b635..6ba3ba7450 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -63,7 +63,8 @@ static constexpr unsigned int STANDARD_SCRIPT_VERIFY_FLAGS = MANDATORY_SCRIPT_VE SCRIPT_VERIFY_LOW_S | SCRIPT_VERIFY_WITNESS | SCRIPT_VERIFY_DISCOURAGE_UPGRADABLE_WITNESS_PROGRAM | - SCRIPT_VERIFY_WITNESS_PUBKEYTYPE; + SCRIPT_VERIFY_WITNESS_PUBKEYTYPE | + SCRIPT_VERIFY_CONST_SCRIPTCODE; /** For convenience, standard but not mandatory verify flags. */ static constexpr unsigned int STANDARD_NOT_MANDATORY_VERIFY_FLAGS = STANDARD_SCRIPT_VERIFY_FLAGS & ~MANDATORY_SCRIPT_VERIFY_FLAGS; -- cgit v1.2.3 From 7485488e907e236133a016ba7064c89bf9ab6da3 Mon Sep 17 00:00:00 2001 From: Johnson Lau Date: Fri, 27 Apr 2018 03:31:36 +0800 Subject: Policy to reject extremely small transactions A transaction with 1 segwit input and 1 P2WPHK output has non-witness size of 82 bytes. Anything smaller than this have unnecessary malloc overhead and are not relayed/mined. --- src/policy/policy.h | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/policy') diff --git a/src/policy/policy.h b/src/policy/policy.h index 6ba3ba7450..5ce019df4c 100644 --- a/src/policy/policy.h +++ b/src/policy/policy.h @@ -22,6 +22,8 @@ static const unsigned int DEFAULT_BLOCK_MAX_WEIGHT = MAX_BLOCK_WEIGHT - 4000; static const unsigned int DEFAULT_BLOCK_MIN_TX_FEE = 1000; /** The maximum weight for transactions we're willing to relay/mine */ static const unsigned int MAX_STANDARD_TX_WEIGHT = 400000; +/** The minimum non-witness size for transactions we're willing to relay/mine (1 segwit input + 1 P2WPKH output = 82 bytes) */ +static const unsigned int MIN_STANDARD_TX_NONWITNESS_SIZE = 82; /** 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 */ -- cgit v1.2.3