The stardust is a given. As for sunlight, all the energy including somewhat arguably geothermal (using the suns gravity to help form the earth and I guess radioactive material being formed by other stars) comes from the sun and gets converted into chemical energy you eat so you’re stardust animated by sunlight (mainly).


Only when a moon orbits around a planet faster than the planet spin on its axis, then only will this moon transfers its orbital energy to the planet.
Our planet, by the means of tidal forces, transfers a small part of its rotating energy to the moon’s orbital energy.
… in this process most of the rotation energy lost by the Earth is converted to heat.