@ -306,6 +306,10 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
opcode = = OP_RSHIFT )
opcode = = OP_RSHIFT )
return set_error ( serror , SCRIPT_ERR_DISABLED_OPCODE ) ; // Disabled opcodes.
return set_error ( serror , SCRIPT_ERR_DISABLED_OPCODE ) ; // Disabled opcodes.
// With SCRIPT_VERIFY_CONST_SCRIPTCODE, OP_CODESEPARATOR in non-segwit script is rejected even in an unexecuted branch
if ( opcode = = OP_CODESEPARATOR & & sigversion = = SIGVERSION_BASE & & ( flags & SCRIPT_VERIFY_CONST_SCRIPTCODE ) )
return set_error ( serror , SCRIPT_ERR_OP_CODESEPARATOR ) ;
if ( fExec & & 0 < = opcode & & opcode < = OP_PUSHDATA4 ) {
if ( fExec & & 0 < = opcode & & opcode < = OP_PUSHDATA4 ) {
if ( fRequireMinimal & & ! CheckMinimalPush ( vchPushValue , opcode ) ) {
if ( fRequireMinimal & & ! CheckMinimalPush ( vchPushValue , opcode ) ) {
return set_error ( serror , SCRIPT_ERR_MINIMALDATA ) ;
return set_error ( serror , SCRIPT_ERR_MINIMALDATA ) ;
@ -869,6 +873,9 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
case OP_CODESEPARATOR :
case OP_CODESEPARATOR :
{
{
// If SCRIPT_VERIFY_CONST_SCRIPTCODE flag is set, use of OP_CODESEPARATOR is rejected in pre-segwit
// script, even in an unexecuted branch (this is checked above the opcode case statement).
// Hash starts after the code separator
// Hash starts after the code separator
pbegincodehash = pc ;
pbegincodehash = pc ;
}
}
@ -889,7 +896,9 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
// Drop the signature in pre-segwit scripts but not segwit scripts
// Drop the signature in pre-segwit scripts but not segwit scripts
if ( sigversion = = SIGVERSION_BASE ) {
if ( sigversion = = SIGVERSION_BASE ) {
scriptCode . FindAndDelete ( CScript ( vchSig ) ) ;
int found = scriptCode . FindAndDelete ( CScript ( vchSig ) ) ;
if ( found > 0 & & ( flags & SCRIPT_VERIFY_CONST_SCRIPTCODE ) )
return set_error ( serror , SCRIPT_ERR_SIG_FINDANDDELETE ) ;
}
}
if ( ! CheckSignatureEncoding ( vchSig , flags , serror ) | | ! CheckPubKeyEncoding ( vchPubKey , flags , sigversion , serror ) ) {
if ( ! CheckSignatureEncoding ( vchSig , flags , serror ) | | ! CheckPubKeyEncoding ( vchPubKey , flags , sigversion , serror ) ) {
@ -953,7 +962,9 @@ bool EvalScript(std::vector<std::vector<unsigned char> >& stack, const CScript&
{
{
valtype & vchSig = stacktop ( - isig - k ) ;
valtype & vchSig = stacktop ( - isig - k ) ;
if ( sigversion = = SIGVERSION_BASE ) {
if ( sigversion = = SIGVERSION_BASE ) {
scriptCode . FindAndDelete ( CScript ( vchSig ) ) ;
int found = scriptCode . FindAndDelete ( CScript ( vchSig ) ) ;
if ( found > 0 & & ( flags & SCRIPT_VERIFY_CONST_SCRIPTCODE ) )
return set_error ( serror , SCRIPT_ERR_SIG_FINDANDDELETE ) ;
}
}
}
}