def verify_script(signature_script: nil, output_script: nil)

      @stack = []
      @altstack = []

      if flag?(SCRIPT_VERIFY_SIGPUSHONLY) && !signature_script.data_only?
        return set_error(SCRIPT_ERR_SIG_PUSHONLY)
      end

      if extension = extension_to_handle_scripts(signature_script, output_script)
        return extension.handle_scripts(
          interpreter: self,
          signature_script: signature_script,
          output_script: output_script
        ) && verify_clean_stack_if_needed
      end

      if !run_script(signature_script)
        # error is set in run_script
        return false
      end

      if !did_execute_signature_script(signature_script)
        # error is set already
        return false
      end

      # This is implemented in P2SHExtension
      # stack_copy = if flag?(SCRIPT_VERIFY_P2SH)
      #   @stack.dup
      # end

      if extension = extension_to_handle_output_script(output_script)
        return extension.handle_output_script(
          interpreter: self,
          output_script: output_script
        ) && verify_clean_stack_if_needed
      end

      if !run_script(output_script)
        # error is set in run_script
        return false
      end

      if @stack.empty?
        return set_error(SCRIPT_ERR_EVAL_FALSE)
      end

      if cast_to_bool(@stack.last) == false
        return set_error(SCRIPT_ERR_EVAL_FALSE)
      end

      if !did_execute_output_script(output_script)
        # error is set already
        return false
      end

      # Additional validation for pay-to-script-hash (P2SH) transactions:
      # See P2SHExtension#did_execute_output_script.

      return verify_clean_stack_if_needed
    end
def verify_script(signature_script: nil, output_script: nil)

      @stack = []
      @altstack = []

      if flag?(SCRIPT_VERIFY_SIGPUSHONLY) && !signature_script.data_only?
        return set_error(SCRIPT_ERR_SIG_PUSHONLY)
      end

      if extension = extension_to_handle_scripts(signature_script, output_script)
        return extension.handle_scripts(
          interpreter: self,
          signature_script: signature_script,
          output_script: output_script
        ) && verify_clean_stack_if_needed
      end

      if !run_script(signature_script)
        # error is set in run_script
        return false
      end

      if !did_execute_signature_script(signature_script)
        # error is set already
        return false
      end

      # This is implemented in P2SHExtension
      # stack_copy = if flag?(SCRIPT_VERIFY_P2SH)
      #   @stack.dup
      # end

      if extension = extension_to_handle_output_script(output_script)
        return extension.handle_output_script(
          interpreter: self,
          output_script: output_script
        ) && verify_clean_stack_if_needed
      end

      if !run_script(output_script)
        # error is set in run_script
        return false
      end

      if @stack.empty?
        return set_error(SCRIPT_ERR_EVAL_FALSE)
      end

      if cast_to_bool(@stack.last) == false
        return set_error(SCRIPT_ERR_EVAL_FALSE)
      end

      if !did_execute_output_script(output_script)
        # error is set already
        return false
      end

      # Additional validation for pay-to-script-hash (P2SH) transactions:
      # See P2SHExtension#did_execute_output_script.

      return verify_clean_stack_if_needed
    end
ScriptError instance
 Instantiates interpreter with validation flags and an optional checker
 (required if the scripts use signature-checking opcodes).
 Checker can be transaction checker or block checker
 Returns true if succeeded or false in case of failure.
 If fails, sets the error attribute.