On the origin of solar flare X-rays