You are probably doing the right thing. I didn't want to say it wouldn't be sold out because you never know. I've ridden the Hungarian railroad to Vienna, Gyor, Edger and Pecs and have never been on a train that didn't have plenty of extra seats; but the minute I say that ................ well.................... I "think" the tickets at the station a couple of days early will set you back 24 to 29 euro if my memory is correct. Tickets in the other direction, purchased in Vienna, do cost more; again if my memory serves me correctly..
I have never purchased Hungarian train tickets on the internet (I buy them in country or have a friend pick them up for me in advance) but if I understand correctly you have to pick them up at the train station using some sort of kiosk. I would suggest that you do this early in your stay in Budapest. Besides, Keleti Station is worth the time to see. Don't forget to go to Nyugati Station too as it is one of Eiffel's creations.
Two hours seems to be a little excessive but it depends on where are you staying and how are you getting to the train station. I believe the new metro station at the Keleti is open. Should be pretty nice based on what I could see between the barricade boards a few weeks ago. There are some places that sell food in the station and you can check that out when you go to pick up your tickets.
Let me know if I can help with anything.
And we will be in Budapest in early/mid June. Maybe we cross paths.