When the propellant explodes it creates a hot high pressure gas, and the pressure of this gas pushes the bullet along the barrel.
The energy of the bullet is equal to the work done on it, so the energy at some distance $d$ along the barrel will be:
$$ E = \tfrac{1}{2}mv^2 = A \int_0^d P(x)\,dx $$
where $A$ is the area of the bullet, though actually calculating the integral will be hard. The propellant does not burn instantly so the pressure is some complicated function of time as well as distance moved by the bullet. There will also be some frictional term to subtract from that energy, though this is likely to be a small correction.
You ask:
as the rest of the energy goes into pushing against the walls of the barrel which is then just wasted as vibrational energy and then eventually into heat
but the gas does no work on the walls of the barrel so no energy is lost that way. However there will be some heat loss into the walls of the barrel and that will cool the gas, lower its pressure and reduce the amount of work that can be done on the bullet. However the duration of the bullet's travel down the barrel is very short, so there probably isn't much heat lost this way. Most of the energy will go into kinetic energy of the bullet.